seurat-object
seurat-object copied to clipboard
SaveSeuratRds(): Is there a way to alter directory address of 'on-disk' matrices in Seurat object
Hello,
I have been running an analysis in Seurat 5 that is partially run on a local machine and a remote server, and I've been trying to work out how to change the address of where the BP cell generated count matrices are located. After moving Seurat objects generated remotely to my local machine, I encounter errors when trying to run certain functions as the root directory for the count data is set to the remote directory, rather than the local directory. See here for more details.
The SaveSeuratRds()
function looks as if it may be able to change this directory address, but there does not appear to be functionality to just change it without moving the on-disk layers from their original location. I've tried running SaveSeuratRds()
with move = F
, but when you reload the object the layers are missing:
> seurat_object
An object of class Seurat
53590 features across 144380 samples within 2 assays
Active assay: RNA (26795 features, 2000 variable features)
0 layers present:
1 other assay present: sketch
6 dimensional reductions calculated: pca, umap, harmony, umap.harmony, harmony.full, umap.full
When running SaveSeuratRds()
with move = T
, obviously the original path is not found (this also occurs when setting relative = T
or relative = F
).
SaveSeuratRds(seurat_object, paste0(R_dir, '02seurat_', region, '_test.rds'))
Error:
! Can't find path:
...
I've also tried digging around the Seurat Object, but I can't put my finger where this address is stored. The best I could do was find a list of 28 identical items containing the following, but I'm not convinced this is worth changing as it looks like a log:
Matrix_list
seurat_object@assays$RNA@layers$counts@matrix@matrix@matrix_list[[1]]
26795 x 5706 IterableMatrix object with class RenameDims
Row names: TTR, LINC01821 ... PARVG
Col names: 10X356_4:GGTGAAGCAGGTGACA, 10X356_4:TGGATGTCACGACAAG ... 10X356_4:AGTGATCAGGCCCAAA
Data type: double
Storage order: column major
Queued Operations:
1. Load compressed matrix from directory /scratch/results/01R_objects/CBL_BP
2. Select rows: 1, 5 ... 59357 and cols: 1, 2 ... 28010
3. Reset dimnames
4. Reset dimnames
5. Reset dimnames
6. Reset dimnames
7. Reset dimnames
8. Reset dimnames
9. Reset dimnames
10. Reset dimnames
11. Reset dimnames
So a couple of questions then:
- Is there a way to alter the address of the root directory within Seurat, wither using
SaveSeuratRds()
or otherwise? - If not, could this functionality be added to
SaveSeuratRds()
to handle local / remote analyses?
Many thanks.