# Integration of Multiple Multiome Datasets

**URL:** <https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685>\
**Category:** Multiome\
**Tags:** integration, multivi, totalvi\
**Created:** [August 16, 2023, 4:12am UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685 "2023-08-16T04:12:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjuhh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jjuhh/32/396_2.png) [@jjuhh](https://discourse.scverse.org/u/jjuhh)\
**Post date:** [August 16, 2023, 4:12am UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685/1 "2023-08-16T04:12:23Z")

</div>

Thank you for developing a bunch of amazing tools in the single-cell field!

I encountered an issue related to the integration of multiple multiome datasets.

As I understand, totalVI is specialized in CITE-seq(protein + scRNA), and multiVI is designed for paired and unpaired data to improve the usage of single-modality data. I’m curious whether the focus on applying totalVI to CITE-seq is influenced by the relatively small size of the protein matrix, thereby limiting its applicability to other types of datasets?

I have a total 9 multiome datasets and want to integrate them without introducing batch effects, similar to what scVI does.

May I ask what the best approach to integrate these multiome datasets would be?

Additionally, there is normalization options in `cellranger-arc aggr` such as `--normalize=depth|none[default:depth]`. I believe that overcorrecting with `--normalize=depth` could potentially affect the subsequent integration step with scVI tools. Could you provide some advice regarding this?

Thank you!!  
Juhyun

---

<div class="post-metadata">

**Author:** ![martinkim0](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/martinkim0/32/881_2.png) [@martinkim0](https://discourse.scverse.org/u/martinkim0)\
**Post date:** [August 18, 2023, 9:16pm UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685/2 "2023-08-18T21:16:18Z")

</div>

Hi, thanks for your question. Yes, totalVI is only suitable for analyzing paired CITE-seq data since it jointly models both RNA and protein expression in the same latent space. In addition to this, it generates RNA and protein counts from learned negative binomial distributions, including foreground and background protein parameters. You can find more information in our [user guide](https://docs.scvi-tools.org/en/stable/user_guide/models/totalvi.html).

MultiVI accepts paired and unpaired data for RNA, ATAC, and protein expression. It does so by inferring modality-specific latent representations and then merging them into a common one, thus making it suitable for modeling unpaired data. What are the modalities present across your datasets? If the datasets are unpaired, then MultiVI would be the appropriate choice.

Regarding depth normalization, all scvi-tools models expect raw count data as input, so normalization is not recommended.

---

<div class="post-metadata">

**Author:** ![jjuhh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jjuhh/32/396_2.png) [@jjuhh](https://discourse.scverse.org/u/jjuhh)\
**Post date:** [November 9, 2023, 10:04pm UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685/3 "2023-11-09T22:04:29Z")

</div>

Apologies for the delayed response. I utilized fully paired multiome data from four different libraries and employed MOFA+ to integrate the datasets. But I also attempted to use MultiVI for the integration, as described [here](https://www.sc-best-practices.org/multimodal_integration/paired_integration.html#multiome-data).

However, I encountered an error message when I used the same code from the page.  
 ![스크린샷 2023-11-09 오후 4.59.51](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/f28558c2f9e46ffec5c7744ccfaec82b83049f2c.png)  
 ![스크린샷 2023-11-09 오후 5.00.07](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/d69680395b7cb9291393097600885e5233b5c0a8.png)

I assumed that the error was caused by using the modality (in my case, all cells are assigned as ‘paired’) as a single batch during `scvi.model.MULTIVI.setup_anndata`. Therefore, I also tried using `fully_paired=True` in the `scvi.model.MULTIVI` function. However, I encountered the same error during training

1. Could you please provide any advice on resolving this error?
2. In your opinion, what is the most effective way to integrate several fully paired multiome datasets?

- version info  
scvi : v1.0.4  
pandas : v2.1.0

---

<div class="post-metadata">

**Author:** ![martinkim0](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/martinkim0/32/881_2.png) [@martinkim0](https://discourse.scverse.org/u/martinkim0)\
**Post date:** [November 14, 2023, 7:27pm UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685/4 "2023-11-14T19:27:43Z")

</div>

Hi @jjuhh, sorry you are running into this error. We have noticed an increased frequency of NaN errors, particularly in MultiVI and GIMVI, and are looking into a solution for these. I believe this is occurring for scvi-tools \>= 1.0.0. Could you try the following and see if the issue resolves?

- Try setting `scvi.settings.seed = 0` in `scvi-tools==1.0.4`
- Try installing `scvi-tools==0.20.3`

---

<div class="post-metadata">

**Author:** ![jjuhh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jjuhh/32/396_2.png) [@jjuhh](https://discourse.scverse.org/u/jjuhh)\
**Post date:** [November 14, 2023, 8:18pm UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685/5 "2023-11-14T20:18:00Z")

</div>

Thank you for your response and for paying attention to this issue.

I was able to resolve the problem by simply running `scvi.modelMULTIVI.setup_anndata()` without specifying `batch="modality"` before the `scvi.train()` step.

I believe this error arose from using only one batch (in my case, all cells are ‘paired’ in modality column) rather than multiple batches. It seems that the `fully_paired = True` flag in `scvi.model.MULTIVI()` is currently ignored. If this flag becomes functional in the future, errors like the one I encountered may not occur.

On another note, I have a question: Can I use the code below to integrate fully paired-multiome data? Does it make sense?

```auto
scvi.model.MULTIVI.setup_anndata(
    adata_mvi,
    categorical_covariate_keys=["sampleName"],
    layer="counts"
)

%%time
mvi = scvi.model.MULTIVI(
    adata_mvi,
    fully_paired = True, # allows the simplification of the model if the data is fully paired. "Currently ignored."
    n_genes=(adata_mvi.var["feature_types"] == "Gene Expression").sum(),
    n_regions=(adata_mvi.var["feature_types"] == "Peaks").sum()
)

%%time
mvi.train(early_stopping=True,
          use_gpu='cuda:1',
          adversarial_mixing=False,
          plan_kwargs={"reduce_lr_on_plateau":True, "optimizer":"AdamW"},
          batch_size=500
         )

```

Thank you!

---

<div class="post-metadata">

**Author:** ![asur](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@asur](https://discourse.scverse.org/u/asur)\
**Post date:** [March 6, 2024, 9:45pm UTC](https://discourse.scverse.org/t/integration-of-multiple-multiome-datasets/1685/6 "2024-03-06T21:45:43Z")

</div>

Just curious if there was any update on this from the developers. So far the git branch on 1.2 doesn’t show the `fully_paired` flag as active.
