# Impact of batch on TotalVI results

**URL:** <https://discourse.scverse.org/t/impact-of-batch-on-totalvi-results/3404>\
**Category:** scvi-tools\
**Tags:** totalvi\
**Created:** [January 4, 2025, 3:30am UTC](https://discourse.scverse.org/t/impact-of-batch-on-totalvi-results/3404 "2025-01-04T03:30:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JenniferF](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jenniferf/32/853_2.png) [@JenniferF](https://discourse.scverse.org/u/JenniferF)\
**Post date:** [January 4, 2025, 3:30am UTC](https://discourse.scverse.org/t/impact-of-batch-on-totalvi-results/3404/1 "2025-01-04T03:30:57Z")

</div>

Good evening, thank you for maintaining TotalVI! We are applying a pre-existing model and classifier built from TotalVI to a new dataset. This new dataset includes samples across several different cancer types, patients, techniques (multiome, single-cell, single-nuclei), and labs. Some cancers have samples from multiple techniques while others do not. We would like to compare our cell types across cancers as best as possible. When we run with batch set to different variables, we obtain very different results. Since our conclusions will differ based upon what we ultimately choose as batch, we would like to understand better what the batch variable is doing.

Are you able to provide guidance or information on what the batch variable is doing in the model to help us to select the best batch option? Any input is very much appreciated, thank you!

---

<div class="post-metadata">

**Author:** ![ori-kron-wis](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ori-kron-wis/32/1099_2.png) [@ori-kron-wis](https://discourse.scverse.org/u/ori-kron-wis)\
**Post date:** [January 5, 2025, 10:32am UTC](https://discourse.scverse.org/t/impact-of-batch-on-totalvi-results/3404/2 "2025-01-05T10:32:03Z")

</div>

Hey Jennifer,

Selecting best batch option might depend also on what you are looking for, as for example if you are analysing the biological aspect of your data, you should use only the technical data as batch (donor, sites etc…), on the other hand you can also use a flag to indicate which techniques even exists per sample , as this might also be a source of bias.

As to what specifically batch\_key is doing, well, that depends on each model but overall in all cases its try to remove the noise originated in a technical aspects, or the removal of unwanted variation.

See the following resources for more information:

> **[User guide](https://docs.scvi-tools.org/en/stable/user_guide/index.html)**
>
> scvi-tools is composed of models that can perform one or many analysis tasks. In the user guide, we provide an overview of each model with emphasis on the math behind the model, how it connects to ...

> **[totalVI](https://docs.scvi-tools.org/en/stable/user_guide/models/totalvi.html)**
>
> totalVI 1(total Variational Inference; Python class TOTALVI) posits a flexible generative model of CITE-seq RNA and protein data that can subsequently be used for many common downstream tasks. The ...

> **[Frequently asked questions](https://docs.scvi-tools.org/en/stable/faq.html#what-is-the-difference-between-batch-key-and-categorical-covariate-keys)**
>
> This section contains answers to frequently asked questions. Don’t see what you’re looking for here? Feel free to check out our Discourse or chat with us directly on Zulip. What is the difference b...
