samuel-marsh / scCustomize

R package with collection of functions created and/or curated to aid in the visualization and analysis of single-cell data using R.
https://samuel-marsh.github.io/scCustomize/
GNU General Public License v3.0
185 stars 19 forks source link

Error Merge #187

Open eblchen opened 1 month ago

eblchen commented 1 month ago

Cannot merge Seurat object list get the following error:

entry.seurat <- Merge_Seurat_List(entry.list)
Error in names(model.list) <- all.levels : 
  attempt to set an attribute on NULL

Any pointers would be appreciated :)

samuel-marsh commented 1 month ago

Can you post the output of traceback() after receiving the error?

Best, Sam

eblchen commented 1 month ago

Sure, thanks for helping with this!

> entry.seurat <- Merge_Seurat_List(entry.list)
Error in names(model.list) <- all.levels : 
  attempt to set an attribute on NULL
> traceback()
8: merge.SCTAssay(x = objects[[idx.x]][[assay]], y = lapply(X = objects[idx.y], 
       FUN = "[[", assay), labels = projects, add.cell.ids = NULL, 
       collapse = collapse, merge.data = merge.data)
7: merge(x = objects[[idx.x]][[assay]], y = lapply(X = objects[idx.y], 
       FUN = "[[", assay), labels = projects, add.cell.ids = NULL, 
       collapse = collapse, merge.data = merge.data)
6: merge.Seurat(x = x, y = y, merge.data = merge.data, project = project)
5: merge(x = x, y = y, merge.data = merge.data, project = project)
4: fn(out, elt, ...)
3: reduce_impl(.x, .f, ..., .init = .init, .dir = .dir)
2: reduce(list_seurat, function(x, y) {
       merge(x = x, y = y, merge.data = merge.data, project = project)
   })
1: Merge_Seurat_List(entry.list)
> 
samuel-marsh commented 1 month ago

ok thanks.

What happens if you run:

merged <- merge(entry.list[[1]], entry.list[[2:length(x = entry.list)]])

Best, Sam

samuel-marsh commented 1 month ago

Hi,

Just following up on my message from last week.

Best, Sam

eblchen commented 1 month ago

Hi Sam, Sorry it's taken a while to reply have been away! This was the result:

> merged <- merge(entry.list[[1]], entry.list[[2:length(x = entry.list)]])
Error in (function (cond)  : 
  error in evaluating the argument 'y' in selecting a method for function 'merge': subscript out of bounds
samuel-marsh commented 1 month ago

no worries! Sorry this was my bad on previous code. Try running this (removed bracket):

merged <- merge(entry.list[[1]], entry.list[2:length(x = entry.list)])

Best, Sam

samuel-marsh commented 1 month ago

Hi @eblchen,

No worries if you haven't had time but just following up on my previous post.

Best, Sam

eblchen commented 1 month ago

Hi Sam, Sorry only just got back from travelling!

> merged <- merge(entry.list[[1]], entry.list[2:length(x = entry.list)])
Error in names(model.list) <- all.levels : 
  attempt to set an attribute on NULL

This was the error. Thanks for your help with this!

samuel-marsh commented 2 weeks ago

Hi @eblchen,

So sorry I've been in and out as well. So this tells me that the issue is coming from Seurat objects and not scCustomize. How many objects are in your list?

Best, Sam