# Semi supervised integration update

**URL:** <https://discourse.scverse.org/t/semi-supervised-integration-update/431>\
**Category:** scvi-tools\
**Tags:** scanvi\
**Created:** [May 2, 2022, 8:18am UTC](https://discourse.scverse.org/t/semi-supervised-integration-update/431 "2022-05-02T08:18:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![castaway1990](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@castaway1990](https://discourse.scverse.org/u/castaway1990)\
**Post date:** [May 2, 2022, 8:18am UTC](https://discourse.scverse.org/t/semi-supervised-integration-update/431/1 "2022-05-02T08:18:48Z")

</div>

Hi everyone,

I am trying to leverage the approach suggested in [Benchmarking atlas-level data integration in single-cell genomics | Nature Methods](https://doi.org/10.1038/s41592-021-01336-8) and [Semi-supervised integration with scANVI · Issue #698 · scverse/scvi-tools · GitHub](https://github.com/scverse/scvi-tools/issues/698), and using labels as metadata to guide the integration. The notebook from the paper is a little bit clunky to me and uses either custom wrappers or api that seem no longer present in the latest version.

I was wondering if running the standard preprocessing and then the following code below would do fine (providing actually no cells with “Unknown” label in adata.obs[“myLabel”]).

```auto
scvi.model.SCVI.setup_anndata(
    adata,
    layer="counts",
    categorical_covariate_keys = ["batch","individual"],
    labels_key = "myLabel"
    
)

lvae = scvi.model.SCANVI(adata, "Unknown", n_latent=30, n_layers=2)
lvae.train(max_epochs=100, n_samples_per_label=100)
latentSCANVI = lvae.get_latent_representation()
adata.obsm["X_scANVI"] = latentSCANVI

```

This way of supervised integration could be the way to go for many integration issues. It would be great to try and clarify/streamline it a little bit for the community 🙂

Thank you!  
Davide

---

<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:** [May 2, 2022, 8:15pm UTC](https://discourse.scverse.org/t/semi-supervised-integration-update/431/2 "2022-05-02T20:15:02Z")

</div>

Hi Davide,

Perhaps this is what you’re looking for?

> **[Atlas-level integration of lung data](https://docs.scvi-tools.org/en/stable/tutorials/notebooks/harmonization.html#Integration-with-scANVI)**
>
> An important task of single-cell analysis is the integration of several samples, which we can perform with scVI. For integration, scVI treats the data as unlabelled. When our dataset is fully label...

---

<div class="post-metadata">

**Author:** ![castaway1990](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@castaway1990](https://discourse.scverse.org/u/castaway1990)\
**Post date:** [May 3, 2022, 7:27am UTC](https://discourse.scverse.org/t/semi-supervised-integration-update/431/3 "2022-05-03T07:27:14Z")

</div>

Yes, thanks a lot! Definitelly my bad 🙂
