`_scvi_local_l_mean` and `_scvi_local_l_var` only depend on batch?

Hello! I have noticed that the variables _scvi_local_l_mean and _scvi_local_l_var that get added to adata.obs on versions >0.7 seem to only depend on batch (see the screenshot belows which shows adata.obs with cells from two batches).

My understanding is that these are priors for the library size in each cell, so they should differ for each cell, not for each batch. What have I understood wrong?

This is the expected behavior. Consider a dataset with one batch. We assume that

\ell_n \sim \mathrm{LogNormal}(\mu, \sigma^2)

where \mu is equal to the average of the log library size in that batch, and likewise \sigma^2 the variance of the log library size in that batch (both over all cells).

The reason you see each cell having the same value in a batch is related to how we load the data into the model.

1 Like