# Plot.scatter not showing all samples when visualizing PCA

**URL:** <https://discuss.hail.is/t/plot-scatter-not-showing-all-samples-when-visualizing-pca/3147>\
**Category:** Hail Query & hailctl\
**Created:** [February 28, 2023, 3:23pm UTC](https://discuss.hail.is/t/plot-scatter-not-showing-all-samples-when-visualizing-pca/3147 "2023-02-28T15:23:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![igorm](https://avatars.discourse-cdn.com/v4/letter/i/e47774/32.png) [@igorm](https://discuss.hail.is/u/igorm)\
**Post date:** [February 28, 2023, 3:23pm UTC](https://discuss.hail.is/t/plot-scatter-not-showing-all-samples-when-visualizing-pca/3147/1 "2023-02-28T15:23:22Z")

</div>

Hi,

I have annotated 32 samples (among thousands) and conduct PCA on the db. But only 11 show on the scatter plot. Could this be bug or am I missing something?

Here is the code:

```python
len(mt.filter_cols(mt.group == "case").s.collect())
32 # the rest have no annotation in mt.group

eigenvalues, pcs _ = hl.hwe_normalized_pca(mt.GT)
mt = mt.annotate_cols(scores = pcs[mt.s].scores)

p = hl.plot.scatter(mt.scores[0],
                    mt.scores[1],
                    hover_fields=dict([('name', mt.s)]),
                    label=mt.group,
                    title='PCA', xlabel='PC1', ylabel='PC2')
show(p)

```

When I turn off the NA group I can only count 11 “case” samples on the plot. There should be 32. (If I do mt.filter\_cols and create new mt with only annotated samples and then do PCA, I will get all the 32 on the plot.)

 ![bokeh_plot (10)](https://canada1.discourse-cdn.com/flex036/uploads/hail/original/1X/fb34d59f04379a2b2e94001ab4e6a1573f0ff772.png)

Thanks

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [February 28, 2023, 8:26pm UTC](https://discuss.hail.is/t/plot-scatter-not-showing-all-samples-when-visualizing-pca/3147/2 "2023-02-28T20:26:49Z")

</div>

Hail’s scatter plot, by default, collapses points that are directly on top one another, since they wouldn’t render as separate points. I think the tooltip should indicate that there are two samples. Is that the case?

Hmm. Also possible that we don’t handle missing-value labels correctly. Can you try converging the missing value labels to a string? e.g.: `label=hl.coalesce(mt.group, "MISSING")`.
