# Transferring lables from refrence dataset to query dataset with a more diverse cell population using scANVI

**URL:** <https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413>\
**Category:** scvi-tools\
**Tags:** scanvi\
**Created:** [July 25, 2024, 4:51am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413 "2024-07-25T04:51:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pouria](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@pouria](https://discourse.scverse.org/u/pouria)\
**Post date:** [July 25, 2024, 4:51am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/1 "2024-07-25T04:51:55Z")

</div>

Hello,

Firstly, thank you for providing such an excellent set of tools and tutorials.

I’m currently using scANVI to transfer cell labels from a reference dataset of NK cells (labeled according to NK cell subtypes) to a query dataset consisting of CD45+ cells from peripheral blood. In the initial results, all cells in the query dataset have been labeled as different NK cell subtypes.

I have a few questions regarding this process:

1. Is it problematic to use a reference dataset with a much narrower variety of cells than the query dataset? Ideally, I only want to label the NK cells in the query dataset.

2. Can I restrict the labeling to cells that meet a higher probability threshold?

3. When using scanvi.predict to return probabilities, what would be a reliable probability threshold to consider the labeling as accurate?

Thank you for your assistance.

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [July 25, 2024, 5:23am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/2 "2024-07-25T05:23:15Z")

</div>

Hi, scANVI is not developed for this use case. Specifically, probabilities are not calibrated and can’t predict an unobserved cell-type.  
The number of tools that can detect query-specific cell-types is quite limited. To address this need, we have developed popV and have tested it in similar cases beyond the actual manuscript with good results. [GitHub - YosefLab/PopV](https://github.com/YosefLab/PopV/tree/main). You will likely need to disable using a cell ontology as the NK cell subsets are not part of the Cell Ontology. We have tested it in these settings and it was rather straightforward to find a good decision boundary (usually \>5/7 algorithms will highlight a confident transferred label).

---

<div class="post-metadata">

**Author:** ![pouria](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@pouria](https://discourse.scverse.org/u/pouria)\
**Post date:** [July 31, 2024, 7:12am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/3 "2024-07-31T07:12:36Z")

</div>

Thank you so much, will give this a try!

---

<div class="post-metadata">

**Author:** ![pouria](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@pouria](https://discourse.scverse.org/u/pouria)\
**Post date:** [July 31, 2024, 7:26am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/4 "2024-07-31T07:26:01Z")

</div>

Do you think ther would be any added value in annotating NK cells first using PopV with the built in cell onotology to narrow the query dataset down to only NK cells and in a second run, not use cell ontology, but use the refrence dataset and \>5/7 algorithm boundary as you suggest?

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [August 1, 2024, 4:12pm UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/5 "2024-08-01T16:12:44Z")

</div>

I think both results will be best case very similar. I assume NK cells are defined more stringently in your dataset as you are interested in these cells. I would directly go towards your reference dataset as in Tabula sapiens I disagreed with some Tcell labels.

---

<div class="post-metadata">

**Author:** ![pouria](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@pouria](https://discourse.scverse.org/u/pouria)\
**Post date:** [September 27, 2024, 8:07am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/6 "2024-09-27T08:07:45Z")

</div>

Read you’re paper on BioArchive, I appreciate the work, and would love to use PopV. For some reason my installation doesn’t work. Can’t find the proper modules when following you tutorials. Also the google collab notebooks don’t work. Do you have any suggestions? Thank you for all your help thus far.

---

<div class="post-metadata">

**Author:** ![pouria](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@pouria](https://discourse.scverse.org/u/pouria)\
**Post date:** [September 27, 2024, 8:09am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/7 "2024-09-27T08:09:25Z")

</div>

Have to emphasise that I’m an MD and not a bioinformatician, could be a very easy fix, because I lack basic coding skills.

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [September 27, 2024, 5:33pm UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/8 "2024-09-27T17:33:26Z")

</div>

Thank for your interest in using it. I’m likewise an MD and no worries. There were some outdated Colab notebooks circulation. Can you try: [Google Colab](https://colab.research.google.com/github/czbiohub/PopV/blob/main/tabula_sapiens_tutorial.ipynb#scrollTo=TFNOSbM8fn4s). I just ran it on Colab an no issues were showing up. Can you confirm that you use the same link?

---

<div class="post-metadata">

**Author:** ![pouria](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@pouria](https://discourse.scverse.org/u/pouria)\
**Post date:** [October 17, 2024, 7:53am UTC](https://discourse.scverse.org/t/transferring-lables-from-refrence-dataset-to-query-dataset-with-a-more-diverse-cell-population-using-scanvi/2413/9 "2024-10-17T07:53:51Z")

</div>

Sorry for my lag in response, have been occupied with experiments in the lab. Thank you for sending the the latest google colab, I will try it out and get back to you when I find the time. Really appreciate all your help!
