Sampling from conditional posterior of p(x_n | z_n, s_n, l_n, and covariates)

Thanks for such a great tool and forum for questions.

I’m trying to use scVI to control for batch effect while explicitly preserving biologic information found in a set of categorical and continuous covariates for each cell - the generative process would be that x_n depends on z_n, s_n, l_n, and the set of covariates. I think entering categorical and continuous covariates to the scVI setup_anndata function will allow for this explicit modeling, and I was wondering if it was possible to then sample from this conditional posterior.

Thanks again!

Yes you can just use the posterior_predictive_sample() method. However, consider this will generate new data that will contain the effects that your are trying to remove. On the other hand, the latent representation of cells will be corrected.