Get_normalized_expression function arguments


I had a few questions about the get_normalized_expression function that I hoped to get some clarification for. From the totalVI tutorial (CITE-seq analysis with totalVI — scvi-tools), n_samples is set to 25 and transform_batch is given the list of both datasets.

First, does n_samples refer to the number of cells (surely it can’t be number of biological samples, as the example dataset only has 2 individuals?), and if yes, why is the default 1 / why is the suggested number in the tutorial 25 / what might be a recommended number to set this as?

Second, how exactly should the transform_batch argument be used? I understand from the documentation and github (how to get corrected expression matrix after batch removal · Issue #786 · YosefLab/scvi-tools · GitHub) that it is about which batch to condition over. Intuitively, it seems to be that it would make the most sense to condition over all the batches as is also done in the tutorial, but would there be any situation where that might not be recommended?

Many thanks in advance.

n_samples refers to Monte Carlo sampling for each cell. The normalized expression is a random variable, and we return the average over 25 samples in this case. It’s an unbiased estimate of the expectation, but you need a LOT more samples to reduce the variance of this estimate. So empirically, 25 just seemed to work well.

Generally, you would take all the batches, but you could have the case where one cell type is only seen in one batch. In this case, you’d want to call the function separately for that cell type, and not use the transform batch param in that case.

That’s super useful to know - thank you!