Hello,
I am attempting to run the following block of code as part of a WES variant QC script, but I continue to generate the following error. What is the correct way to probe whether the genotypes listed under ds.GT are equal to a particular string if not with the β==β operator?
Thank you in advance.
'GRNC_cond2': lambda ds: ((ds.GT == './0') | (ds.GT == './1') | (ds.GT == '0/.') | (ds.GT == '1/.'))
File "/gpfs/fs1/home/mg1646/.conda/envs/variantqc_hailenv/lib/python3.8/site-packages/hail/expr/expressions/base_expression.py", line 781, in __eq__
return self._compare_op("==", other)
File "/gpfs/fs1/home/mg1646/.conda/envs/variantqc_hailenv/lib/python3.8/site-packages/hail/expr/expressions/base_expression.py", line 587, in _compare_op
raise TypeError(f"Invalid '{op}' comparison, cannot compare expressions "
TypeError: Invalid '==' comparison, cannot compare expressions of type 'call' and 'str'
Code here:
# dict of lambdas for filter expressions
genotype_exprs = {
# DP: Genotypes below reading depth
'GDP' : lambda ds: ds.DP < args.depth_threshold,
# GDP: heterozygous genotypes outside of allelic balance
'GAB' : lambda ds: (
ds.GT.is_het() & (
(ds.AD[0]/ds.DP > max(1 - args.allelic_balance, args.allelic_balance))
| (ds.AD[0]/ds.DP < min(1 - args.allelic_balance, args.allelic_balance))
)
),
# GGQ: Genotypes below quality threshold
'GGQ': lambda ds: ds.GQ < args.genotype_quality,
# GNP: Male het chrX nonpar variants
'GNP': lambda ds: ds.GT.is_het() & ds.locus.in_x_nonpar() & (ds.sa.GENDER == "Male"),
# GRNC: Genotypes with RNC == 1
'GRNC_cond1': lambda ds: ds.RNC[0] == "11",
'GRNC_cond2': lambda ds: ((ds.GT == './0') | (ds.GT == './1') | (ds.GT == '0/.') | (ds.GT == '1/.'))
}