Do nothing if it is homozygous reference 0/0

Hello hail team!

I am trying to set some of the genotypes to missing based on different conditions for SNPs and INDELS.
I want hail to set the genotypes to missing for SNPs only if
SNP HET non-ref allelic balance < 0.25 ,
SNP HOM non-ref allelic balance < 0.90 and

For INDELS
INDEL HET non-ref allelic balance < 0.30,
INDEL HOM non-ref allelic balance < 0.95

and finally, i want hail to do nothing for homozygous reference SNPs/INDELs (homozygous reference 0/0)

I would appreciate any help and thanks in advance.

Here’s a pipeline that should do what you want:

mt = mt.annotate_entries(
    GT=hl.case()
        .when(mt.GT.is_het(),
              hl.case()
              .when(hl.is_snp(mt.alleles[0], mt.alleles[1]), mt.AD[0] / mt.DP < 0.25)
              .when(hl.is_indel(mt.alleles[0], mt.alleles[1]), mt.AD[0] / mt.DP < 0.30)
              .default(True))
        .when(mt.GT.is_hom_var(),
              hl.case()
              .when(hl.is_snp(mt.alleles[0], mt.alleles[1]), mt.AD[0] / mt.DP < 0.9)
              .when(hl.is_indel(mt.alleles[0], mt.alleles[1]), mt.AD[0] / mt.DP < 0.95)
              .default(True))
    .default(True))
1 Like

Thanks a lot