Open NikicaJEa opened 9 months ago
I am curious about this as well
Hi,
Thanks for pointing this out! We are actively looking into a fix. As you mentioned, I would avoid using the relative
parameter for now.
As a quick fix, you can get around this by saving the normalized layer on-disk again. It seems that, as you mentioned, the issue specifically happens when the data layer is a transformation of the current BPCells on-disk matrix. If you save the normalized data layer directly from the sparse matrix, it will ensure it is saved.
This example works normally for me:
library(Seurat)
library(BPCells)
library(SeuratData)
pbmc3k[["RNA"]]$counts <- write_matrix_dir(pbmc3k[["RNA"]]$counts, dir = "/brahms/mollag/practice/pbmc_counts_new_issue/")
pbmc3k <- NormalizeData(pbmc3k)
pbmc3k[["RNA"]]$data <- write_matrix_dir(pbmc3k[["RNA"]]$data, dir = "/brahms/mollag/practice/pbmc_data_new_issue/")
identical(as(pbmc3k[["RNA"]]$counts, "dgCMatrix"), as(pbmc3k[["RNA"]]$data, "dgCMatrix"))
# should return FALSE and does
SaveSeuratRds(
object = pbmc3k,
file = "my/path/obj.Rds")
cells_loaded <- LoadSeuratRds("my/path/obj.Rds")
identical(as(cells_loaded[["RNA"]]$counts, "dgCMatrix"), as(cells_loaded[["RNA"]]$data, "dgCMatrix"))
# also returns FALSE as expected
That sounds great. Thanks for looking into it!
Any progress with this bug? At least fixing the bug with relative parameter, because relative=TRUE doesn't work and is of high importance to the people that want to share seurat objects with someone.
Hi @NikicaJEa, Apologies that we have not yet gotten a chance to look into this deeply as we prepare for the Seurat 5.0.2 release. In the meantime, does the workaround I shared work for you to be able to share the objects with other poeple?
Hi. The example you kindly shared works nicely with saving the count and normalized count on-disk matrices but does not help if I want to share a seurat object with someone externally. From the example that you shared if I do cells_loaded <- LoadSeuratRds("my/path/obj.Rds")
then in order to access the disk-on matrix I will need access to dir = "/brahms/mollag/practice/pbmc_counts_new_issue/"
. To my understanding, anyone who doesn't have access to this exact folder path won't be able load the seurat object i.e. the on-disk matrices. I guess this is where the relative
parameter would come really in handy. Would you agree?
any update?
Guys, please just make the the SaveSeuratRds()
function work with relative = TRUE
. Without this feature the function is not as nearly useful as it could be. Thanks.
The work around I have used for this scenario is to modify the directory path of the BPCells matrix itself before creating the Seurat object.
library(Seurat)
library(BPCells)
counts_mat <- open_matrix_dir(dir = "./data/cartridge1_1/")
counts_mat@dir <- "relative/path/here"
cells <- CreateSeuratObject(counts_mat)
Hi. I am experiencing multiple issues with SaveSeuratRds. When using SaveSeuratRds everything looks fine, the function is not complaining. But when I load the same saved object with LoadSeuratRds I get
Warning message: Cannot find any of the layer files specified
Here is the code example:
Another related issue to SaveSeuratRds: If I do SaveSeuratRds with
move =TRUE, relative = FALSE
, then it kind of works - the LoadSeuratRds loaded object has the counts and data layers present BUT the data layer is identical to counts layer. When I inspect the counts and data layers they have the same Queued Operations (although they shouldnt).Somehow the layer Queued Operations were not transferred correctly during SaveSeuratRds.Would be great if someone could have look into this. Many thanks!