# Label transfer from CITE-seq

**URL:** <https://discourse.scverse.org/t/label-transfer-from-cite-seq/725>\
**Category:** CITE-seq\
**Tags:** scanvi, scarches\
**Created:** [September 6, 2022, 12:46pm UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725 "2022-09-06T12:46:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![FelixTheStudent](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/felixthestudent/32/164_2.png) [@FelixTheStudent](https://discourse.scverse.org/u/FelixTheStudent)\
**Post date:** [September 6, 2022, 12:46pm UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725/1 "2022-09-06T12:46:08Z")

</div>

Hi all,

I’m looking for a way to transfer labels from a CITE-seq reference to a CITE-seq query. Initially I thought this should not be much different than the usual workflow with [scvi](https://docs.scvi-tools.org/en/stable/tutorials/notebooks/scarches_scvi_tools.html) or [scArches](https://scarches.readthedocs.io/en/latest/scanvi_surgery_pipeline.html). I thought I’d simply replace scVI with totalVI in one of these tutorials and am done.

But then I realized that the `from_scvi_model` function does not have a corresponding function for totalVI, so I’m stuck.

Is there a simple solution that I have missed? If not, why is it harder to transfer labels for CITE-seq?

Thanks for the great work!

Best,

Felix

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [September 11, 2022, 10:54pm UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725/2 "2022-09-11T22:54:11Z")

</div>

So this is correct that as of now you cannot train a classifier on top of totalVI in a way that also affects the encoder (as in a model analogous to scANVI for totalVI).

In this tutorial I train a RF classifier on top of the latent space and show how to store it as an attribute of the model class (so it saves/loads).

> **[CITE-seq reference mapping with totalVI](https://docs.scvi-tools.org/en/stable/tutorials/notebooks/totalVI_reference_mapping.html)**
>
> With totalVI, we can train a reference model that can be used for mapping new query data. Here we dive into this functionality. If you use totalVI, please consider citing: Gayoso, A., Steier, Z., L...

I also want to add that this is a requested feature so we can look into it more as an enhancement this fall.

> <https://github.com/scverse/scvi-tools/issues/1549>
>
> I've written this a few times in the past, but I can't say this often enough: Th…ank you for sharing your excellent analysis software with the community!
> 
> I'm writing to inquire about the possibility of exposing the labels\_key in the totalVI model.
> 
> My reason for coveting this feature is the following: I have CITE-seq data from cells for which I have some a priori information on coarse cell type, i.e. my libraries consist of two different cell types that I've sorted (via FACS) and labeled with hash tag olives before multiplexing them into a single library.
> 
> \[Perhaps anecdotally\] I notice that when I integrate several of these libraries via scVI, using batch and label keys, the boundary between the two cell types remain crisp. When I try this with totalVI, using batch key \[and the additional CITE-seq data\] there is more mixing between the \[closely related\] cell types.
> 
> Thanks in advance for considering this request.

---

<div class="post-metadata">

**Author:** ![FelixTheStudent](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/felixthestudent/32/164_2.png) [@FelixTheStudent](https://discourse.scverse.org/u/FelixTheStudent)\
**Post date:** [September 12, 2022, 8:00am UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725/3 "2022-09-12T08:00:54Z")

</div>

Thanks, this is great!

For my understanding: If the encoder does not get retrained, what happens in your tutorial’s section [Query model training](https://docs.scvi-tools.org/en/stable/tutorials/notebooks/totalVI_reference_mapping.html#Query-model-training)? I imagine the network weights learned on the reference are simply applied to the raw counts of the query to compute the latent space. Or is something more complex going on, such as (re)training the decoder?

Thanks again!  
Best,

Felix

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [September 12, 2022, 2:34pm UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725/4 "2022-09-12T14:34:59Z")

</div>

What is happening is that the encoder sees the batch categories and is fine-tuning weights for the new query batch categories.

This is described in the scArches paper:

> **[Mapping single-cell data to reference atlases by transfer learning - Nature...](https://www.nature.com/articles/s41587-021-01001-7)**
>
> Single-cell data are readily integrated with cell atlases using scArches.

---

<div class="post-metadata">

**Author:** ![FelixTheStudent](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/felixthestudent/32/164_2.png) [@FelixTheStudent](https://discourse.scverse.org/u/FelixTheStudent)\
**Post date:** [September 15, 2022, 1:45pm UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725/5 "2022-09-15T13:45:43Z")

</div>

The tutorial you shared does not load scArches, and also does not call any model from it. Are you saying it still somehow use scArches in its section ‘Query model training’ (linked in my last post)? I feel this is a crucial point for me to understand how the scvi-tools and scArches modules work together.

Thanks!

Felix

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [September 16, 2022, 7:12pm UTC](https://discourse.scverse.org/t/label-transfer-from-cite-seq/725/6 "2022-09-16T19:12:40Z")

</div>

> [@FelixTheStudent](#):
>
> Are you saying it still somehow use scArches in its section ‘Query model training’

`load_query_data` is precisely doing scArches architecture surgery. Any scvi-tools model that is being used from the scarches codebase is just calling the code in scvi-tools, so there is really no difference between the packages except the few models that are unique to scarches codebase.
