# SCANVI inferred cell types don't make sense

**URL:** <https://discourse.scverse.org/t/scanvi-inferred-cell-types-dont-make-sense/3300>\
**Category:** scvi-tools\
**Tags:** scanvi\
**Created:** [October 16, 2024, 1:31am UTC](https://discourse.scverse.org/t/scanvi-inferred-cell-types-dont-make-sense/3300 "2024-10-16T01:31:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tangxj](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@tangxj](https://discourse.scverse.org/u/tangxj)\
**Post date:** [October 16, 2024, 1:31am UTC](https://discourse.scverse.org/t/scanvi-inferred-cell-types-dont-make-sense/3300/1 "2024-10-16T01:31:36Z")

</div>

Hi, I used scANVI to infer unknown cells from a trained scVi model. I then checked a small cluster to compare the original cell type “celltype\_manual” and the inferred cell type ‘C\_scANVI’

```auto
> adata.obs[adata.obs['leiden_0.2']=='19'][['celltype_manual','C_scANVI']].drop_duplicates()
|celltype_manual|C_scANVI|
|---|---|
|Neuron|Endothelial|
|Neuron|Ependymal|
|Neuron|SMC|
|Neuron|Neuron|
|Neuron|Fibroblast|
|Neuron|OPC|
|unknown|Endothelial|
|unknown|Ependymal|
|unknown|Immune_cells|
|unknown|SMC|
|unknown|Oligodendrocyte|
|unknown|Astrocyte|
|Oligodendrocyte|Endothelial|
|Oligodendrocyte|Oligodendrocyte|

```

The celltype\_manual came from the original meta data of published data sets, so should be taken as truth here. However the inferred cell type by scANVI looks like random. And even if that’s true, such cell types shouldn’t be clustered into one small cluster #19.

My codes for set up scanvi\_model and train simply followed the label transfer tutorial.

> scanvi\_model = scvi.model.SCANVI.from\_scvi\_model( model, adata=adata, labels\_key=“celltype\_manual”, unlabeled\_category=“unknown”)  
> scanvi\_model.train(max\_epochs=20, n\_samples\_per\_label=100, accelerator=‘gpu’)

Could you please let me know what might be wrong? I think the only problem might be I didn’t specify the labels\_key to be the celltype\_manual when setting up the model. Is that the reason?

---

<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:** [October 17, 2024, 3:33am UTC](https://discourse.scverse.org/t/scanvi-inferred-cell-types-dont-make-sense/3300/2 "2024-10-17T03:33:28Z")

</div>

Please also try a KNN classifier in latent space (see e.g. PopV code for a simple classifier). We and others found that the scANVI classifier sometimes doesn’t perform well. This is especially true before release 1.1 of scVI-tools.
