monocle-release icon indicating copy to clipboard operation
monocle-release copied to clipboard

reload cds cause error.

Open shanshenbing opened this issue 6 months ago • 1 comments

I run following code to get pseudotime of cells.

#Store data in a cell_data_set object
exprDa <- GetAssayData(object = srobj,slot = 'counts', assay = 'RNA')
metaDa <- [email protected]
gene_annotation <-data.frame(gene_short_name =rownames(exprDa))
rownames(gene_annotation)<-rownames(exprDa)

cds <- new_cell_data_set(exprDa,
                         cell_metadata = metaDa,
                         gene_metadata = gene_annotation)

## Step 1: Normalize and pre-process the data
cds <- preprocess_cds(cds, num_dim = 100)
#check var
#Remove batch effects
## Step 2: Remove batch effects with cell alignment
#check for batch
plot_cells(cds, color_cells_by=batchCol, label_cell_groups=FALSE)
cds <- align_cds(cds, alignment_group = batchCol)

#Cluster your cells
## Step 3: Reduce the dimensions using UMAP
cds <- reduce_dimension(cds)
#check for batch again.
plot_cells(cds, color_cells_by=batchCol, label_cell_groups=FALSE)
## Step 4: Cluster the cells
cds <- cluster_cells(cds)
#check for clusters
plot_cells(cds)
#subset cds
#opitonal
cds <- choose_cells(cds)
# recluster the cells
cds <- cluster_cells(cds)
#check for clusters
plot_cells(cds)


#Order cells in pseudotime along a trajectory
## Step 5: Learn a graph
cds <- learn_graph(cds)
## Step 6: Order cells
cds <- order_cells(cds)

#save  data
qs::qsave(x = cds,nthreads = 10,
          file = paste0(dataDir, '/', projid, '.', ppart, '.cds.qs'))

Everything is ok, but when I save the R img or save cds object and reload cds obj, error will be thrown.

cds

class: cell_data_set dim: 31109 6385 metadata(2): cds_version citations assays(1): counts rownames(31109): AL627309.5 LINC01409 ... GPR50 AC010086.3 rowData names(1): gene_short_name colnames(6385): LM01_AAACGGGTCCTTCAAT-1 LM01_AACCATGCAGGGTACA-1 ... BM16_TGACCCTAGTCTAGCT-1 BM16_TGATCAGCACTAGGCC-1 colData names(45): orig.ident nCount_RNA ... Size_Factor pseudotime Error in validObject(result) : invalid class “cell_data_set” object: slots in class definition but not in object: "preprocess_aux" Error during wrapup: no slot of name "preprocess_aux" for this object of class "cell_data_set" Error: no more error handlers available (recursive errors?); invoking 'abort' restart

shanshenbing avatar Dec 27 '23 12:12 shanshenbing

Finally, I found the reason. I used monocle3(version 1.2.9) when generating CDS obj. But I used monocle3 (version 1.0.0) to load CDS. Different monocle3 version caused the error.

shanshenbing avatar Dec 28 '23 05:12 shanshenbing