mojaveazure / seurat-disk

Interfaces for HDF5-based Single Cell File Formats
https://mojaveazure.github.io/seurat-disk
GNU General Public License v3.0
156 stars 50 forks source link

Error: Attempting to add a different number of cells and/or features #151

Open sarahbonnin opened 1 year ago

sarahbonnin commented 1 year ago

Hi,

I am running into the following error:

Error: Attempting to add a different number of cells and/or features

when trying to read in a .h5seurat file.

I am creating it from h5ad, and reading it back the following way:

Convert(inh5ad, dest = "h5seurat", assay="RNA", overwrite = TRUE)

data <- LoadH5Seurat(inh5seurat, assays="RNA", meta.data=FALSE, misc=FALSE)

I get a couple of warning messages, with the above mentioned error. Details:

Validating h5Seurat file

Warning message:
“Feature names cannot have underscores ('_'), replacing with dashes ('-')”
Initializing RNA with data

Warning message:
“Non-unique features (rownames) present in the input matrix, making unique”
Adding counts for RNA

Error: Attempting to add a different number of cells and/or features
Traceback:

1. LoadH5Seurat(inh5seurat, assays = "RNA", meta.data = FALSE, misc = FALSE)
2. LoadH5Seurat.character(inh5seurat, assays = "RNA", meta.data = FALSE, 
 .     misc = FALSE)
3. LoadH5Seurat(file = hfile, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
4. LoadH5Seurat.h5Seurat(file = hfile, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
5. as.Seurat(x = file, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
6. as.Seurat.h5Seurat(x = file, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
7. AssembleAssay(assay = assay, file = x, slots = assays[[assay]], 
 .     verbose = verbose)
8. SetAssayData(object = obj, slot = slot, new.data = dat)
9. SetAssayData.Assay(object = obj, slot = slot, new.data = dat)
10. stop("Attempting to add a different number of cells and/or features", 
  .     call. = FALSE)

Any idea how to fix this?

Note that my h5ad file does not have duplicated .var or .obs indices, I checked before running the convertion to h5seurat.

Thank you!

GerardoZA commented 1 month ago

Keeping an eye on this issue!