# Set sample genotype to missing based on different conditions for SNPs and INDELS

**URL:** <https://discuss.hail.is/t/set-sample-genotype-to-missing-based-on-different-conditions-for-snps-and-indels/857>\
**Category:** Hail Query & hailctl\
**Created:** [February 12, 2019, 3:15pm UTC](https://discuss.hail.is/t/set-sample-genotype-to-missing-based-on-different-conditions-for-snps-and-indels/857 "2019-02-12T15:15:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monica\_Sudarsanam](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@Monica\_Sudarsanam](https://discuss.hail.is/u/Monica_Sudarsanam)\
**Post date:** [February 12, 2019, 3:15pm UTC](https://discuss.hail.is/t/set-sample-genotype-to-missing-based-on-different-conditions-for-snps-and-indels/857/1 "2019-02-12T15:15:51Z")

</div>

Hello everyone,

I am using hail 0.2 and i would like to set some genotypes to missing based on different conditions for SNPs and INDELS. I want to set genotype to missing if genotype DP \< 20 for SNP non-ref and DP\< 30 for INDEL non-ref genotypes.

I would appreciate any help i could get. Thanks a lot in advance 🙂

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [February 12, 2019, 4:52pm UTC](https://discuss.hail.is/t/set-sample-genotype-to-missing-based-on-different-conditions-for-snps-and-indels/857/2 "2019-02-12T16:52:40Z")

</div>

by “set genotype to missing”, do you mean filter the genotypes (entries)?

Then you can do:

```python
mt = mt.filter_entries(hl.case()
     .when(hl.is_snp(mt.alleles[0], mt.alleles[1]), mt.DP < 20)
     .when(hl.is_indel(mt.alleles[0], mt.alleles[1]), mt.DP < 30)
     .default(True)) # keep if neither condition is met

```

---

<div class="post-metadata">

**Author:** ![Monica\_Sudarsanam](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@Monica\_Sudarsanam](https://discuss.hail.is/u/Monica_Sudarsanam)\
**Post date:** [February 15, 2019, 3:01pm UTC](https://discuss.hail.is/t/set-sample-genotype-to-missing-based-on-different-conditions-for-snps-and-indels/857/3 "2019-02-15T15:01:47Z")

</div>

> [@tpoterba](#):
>
> mt = mt.filter\_entries(hl.case() .when(hl.is\_snp(mt.alleles[0], mt.alleles[1]), mt.DP \< 20) .when(hl.is\_indel(mt.alleles[0], mt.alleles[1]), mt.DP \< 30) .default(True))

Thanks a lot
