Skip to content

Commit

Permalink
use het sites
Browse files Browse the repository at this point in the history
  • Loading branch information
karthigayini committed May 22, 2024
1 parent a0750e1 commit 2af3b32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion biometrics/biometrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def run_genotyping(args, samples):
discordance_threshold=args.discordance_threshold,
threads=args.threads,
zmin=args.zmin,
zmax=args.zmax)
zmax=args.zmax,
het=args.het)
cluster_handler = Cluster(args.discordance_threshold)
comparisons = genotyper.compare_samples(samples)

Expand Down
3 changes: 3 additions & 0 deletions biometrics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def get_args():
parser_genotype.add_argument(
'--zmax', type=float,
help='''Maximum z value for the colorscale on the heatmap.''')
parser_genotype.add_argument(
'--het', type=bool,
help='''Use Heterozygous sites too to calculate discordance rate''')

# cluster parser

Expand Down
9 changes: 6 additions & 3 deletions biometrics/genotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

class Genotyper:

def __init__(self, no_db_compare, discordance_threshold=0.05, threads=1, zmin=None, zmax=None):
def __init__(self, no_db_compare, discordance_threshold=0.05, threads=1, zmin=None, zmax=None,het=False):
self.no_db_compare = no_db_compare
self.discordance_threshold = discordance_threshold
self.threads = threads
self.zmax = zmax
self.zmin = zmin
self.sample_type_ratio = 1
self.comparisons = None
self.het=het

def are_samples_same_group(self, sample1, sample2):

Expand Down Expand Up @@ -253,8 +254,10 @@ def compare_samples(self, samples):
comparisons = pd.DataFrame(comparisons)

# compute discordance rate

comparisons['DiscordanceRate'] = comparisons['HomozygousMismatch'] / (comparisons['HomozygousInRef'] + EPSILON)
if self.het:
comparisons['DiscordanceRate'] = comparisons['HomozygousMismatch'] / (comparisons['HomozygousInRef'] + EPSILON)
else:
comparisons['DiscordanceRate'] = comparisons['HomozygousMismatch'] + comparisons['HeterozygousMismatch'] / (comparisons['TotalMatch'] + EPSILON)

# data['DiscordanceRate'] = data['DiscordanceRate'].map(lambda x: round(x, 6))
comparisons.loc[comparisons['HomozygousInRef'] < 10, 'DiscordanceRate'] = np.nan
Expand Down

0 comments on commit 2af3b32

Please sign in to comment.