Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge runs forever without error if x is inside a named vector #108

Open
edridgedsouza opened this issue Jun 22, 2023 · 0 comments
Open

Comments

@edridgedsouza
Copy link

Had a part of my script that looked like this:

all_objs <- c()
for (i in seq_along(dirs)) {
    samplename <- basename(dirs[i])
    obj <- Load10X_Spatial(data.dir=dirs[i], 
                            filename='filtered_feature_bc_matrix.h5')
    all_objs[[samplename]] <- obj
}

obj_combined <- merge(all_objs[1], y = all_objs[-1], 
                      add.cell.ids = names(all_objs), 
                      project = "Spatial Seq")

This was taking upwards of several hours, even when I restricted my all_objs to contain only two objects. After some tinkering, I found that the offending part was inside the merge() operation: the argument x here is technically a Seurat object inside a vector, rather than the object itself. Changing x to all_objs[[1]], without making any changes to y, seemed to do the trick and the samples merged in a few seconds.

Ultimately, this is on me for not reading the docs more closely to realize that x should literally be the object itself, and not the object contained inside a named vector (which isn't the case for y). However, I can imagine that at least a few other people may accidentally make such a mistake and not realize anything is wrong for a while; my htop showed 100% CPU usage so I assumed the function was running normally and was simply a lot more computationally intensive than I thought.

No idea why this bug occurs, since merge.Assay in assay.R simply performs c(x, y) under the hood anyways. If not fixable, would it be possible to add a warning message?

Relevant package versions: SeuratObject_4.1.3 Seurat_4.3.0 spacexr_2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant