# PCA filtering samples?

**URL:** <https://discuss.hail.is/t/pca-filtering-samples/1374>\
**Category:** Hail Query & hailctl\
**Created:** [April 14, 2020, 5:37pm UTC](https://discuss.hail.is/t/pca-filtering-samples/1374 "2020-04-14T17:37:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ch-kr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/ch-kr/32/317_2.png) [@ch-kr](https://discuss.hail.is/u/ch-kr)\
**Post date:** [April 14, 2020, 5:37pm UTC](https://discuss.hail.is/t/pca-filtering-samples/1374/1 "2020-04-14T17:37:30Z")

</div>

Hey hail team,

I am running `hl.hwe_normalized_pca`, and it appears to be filtering samples. Is that expected behavior?

This is the code I am running:

```auto
logger.info("Running PCA for PC-Relate...")
pruned_qc_mt = remove_hard_filter_samples(
    data_source,
    freeze,
    hl.read_matrix_table(qc_mt_path(data_source, freeze, ld_pruned=True)),
    gt_field="GT",
 ).unfilter_entries()
 eig, scores, _ = hl.hwe_normalized_pca(
     pruned_qc_mt.GT, k=10, compute_loadings=False
 )
 scores.write(
    relatedness_pca_scores_ht_path(data_source, freeze), args.overwrite
 )

```

The input QC MT has 302329 samples, and the scores HT has 301762. There are only 486 samples that should be removed with `remove_hard_filter_samples`. Why are 81 samples missing from the scores HT?

---

<div class="post-metadata">

**Author:** ![konradjk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/konradjk/32/12_2.png) [@konradjk](https://discuss.hail.is/u/konradjk)\
**Post date:** [April 14, 2020, 5:39pm UTC](https://discuss.hail.is/t/pca-filtering-samples/1374/2 "2020-04-14T17:39:17Z")

</div>

Shouldn’t. Can you `count_cols` just after `remove_hard_filter_samples`?

---

<div class="post-metadata">

**Author:** ![ch-kr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/ch-kr/32/317_2.png) [@ch-kr](https://discuss.hail.is/u/ch-kr)\
**Post date:** [April 14, 2020, 5:58pm UTC](https://discuss.hail.is/t/pca-filtering-samples/1374/3 "2020-04-14T17:58:02Z")

</div>

Thanks Konrad! Figured it out, the samples are getting erroneously filtered pretty far upstream
