This is a test version of Biostars. For the public version, visit https://www.biostars.org.
remove batch effect

Good afternoon,

I integrated about 20 studies on different organs and used merge to combine them, followed by using harmony to remove the batch effect. However, the UMAP plot I generated did not successfully remove the batch effect, as several clusters were just from one study and did not overlap with the other studies. I am seeking advice on the best way to remove the batch effect for pan-cancer studies. I have read articles on pan-cancer research, such as the Pan-cancer single-cell landscape of tumor-infiltrating T cells, and noticed they also use harmony. I am wondering if I need to adjust my harmony code. Can you please offer some advice?

Here is my harmony code:

library(harmony) combine_datalist<-SCTransform(combine_datalist) %>%RunPCA() combine_datalist<-RunHarmony(combine_datalist, group.by.vars="study", assay.use="SCT", max.iter.harmony=40, max.iter.cluster = 40, kmeans_init_nstart=20, kmeans_init_iter_max=100)

harmony

1 answer

This doesn't answer the harmony question directly, but I've found with complex datasets often scVI is the only method (of the more popular ones) that can handle large batch effects and sample diversity for integration.

Seurat v5 adds scVI support via a reticulate wrapper function, but until a stable release I would recommend running it in Python directly or through reticulate yourself.

Thanks for the info. I just started learning bioinformatics a few months ago, and I mainly work with R instead of Python. It's really helpful for me to know about different approaches for integration and batch effect removal methods. I'm going to try this out.

What code are you trying to run and what problem are you encountering?

I am trying to run it on R, but I meet the error when I run

adata <- convertFormat(data, from="seurat", to="anndata", main_layer="counts", drop_single_values=FALSE).

And the error message said:

Error in compareVersion(as.character(obj@version), "3.0.0") : trying to get slot "version" from an object of a basic class ("function") with no slots.

I am clear what is the problem, and also I did not find other tutorial, this is why I ask please give me more suggestions.

interesting that I've never heard of scVI yet it is highly cited and the github is highly starred

The highly influential benchmark study came out 2 years after the scVI paper came out yet it didn't even mention this method... bizarre?

Log in to answer this question.