cole-trapnell-lab / monocle-release

274 stars 116 forks source link

Error:Error in vcount(x) : REAL() can only be applied to a 'numeric', not a 'NULL' #475

Open CJSCI666 opened 2 years ago

CJSCI666 commented 2 years ago

Hi I'm using moncle2 for analysis recently, but I found a very strange error, one of which is that when I access the view(cds), there is a problem, the other is _cds.1 <- cds[fData(cds) $num_cellsexpressed >= 10, ] After screening the cds file, we search for highly variable genes by performing _disptable <- dispersionTable(cds.1), the number of highly expressed genes in the _disptable file is greater than the number of genes in the cds.1 file, I am not sure Where is the problem, so come to help, thank you very much.

library(monocle) library(SeuratData) library(Seurat) sce <- pbmc3k.final
table(Idents(sce)) sce$celltype = Idents(sce) sce= sce[,sce$celltype %in% c('CD14+ Mono','FCGR3A+ Mono')] table(Idents(sce)) sample_ann <- sce@meta.data
head(sample_ann) sample_ann[,1] = rownames(sample_ann) gene_ann <- data.frame( gene_short_name = rownames(sce@assays$RNA) , row.names = rownames(sce@assays$RNA) ) head(gene_ann) pd <- new("AnnotatedDataFrame",data=sample_ann) fd <- new("AnnotatedDataFrame",data=gene_ann) data <- as(as.matrix(sce@assays$RNA@counts), 'sparseMatrix') class(data) data[1:4,1:4] cds <- newCellDataSet(data, phenoData = pd, featureData =fd, expressionFamily = negbinomial.size()) view(cds)

Error in vcount(x) : REAL() can only be applied to a 'numeric', not a 'NULL'_

cds <- estimateSizeFactors(cds) cds <- estimateDispersions(cds) sce cds fData(cds)[1:1,1:1] pData(cds)[1:4,1:4] cds <- detectGenes(cds, min_expr = 1) fData(cds)[1:2,1:2] cds <- cds[fData(cds)$num_cells_expressed >= 10, ] cds length(row.names(fData(cds))) [1] 1803 disp_table <- dispersionTable(cds) length(row.names(disp_table)) [1] 11450 unsup_clustering_genes <- subset(disp_table, mean_expression >= 0.1) length(unsup_clustering_genes$gene_id) [1] 2342

my problem:

  1. view(cds)

    Error in vcount(x) : REAL() can only be applied to a 'numeric', not a 'NULL'_

  2. Why the number of genes doesn't make sense

length(row.names(fData(cds)))

[1] 1803

disp_table <- dispersionTable(cds)

length(row.names(disp_table))

[1] 11450

unsup_clustering_genes <- subset(disp_table, mean_expression >= 0.1)

length(unsup_clustering_genes$gene_id)

[1] 2342

CJSCI666 commented 2 years ago

monocle2 can not directly open cds ,but if you use m3 you can open it

Matthew1309 commented 1 year ago

I'm having the same issue. I used to be able to View(cds) or str(cds) but now I cannot! My error message is

> View(cds)
Error in vcount(x) : 
  REAL() can only be applied to a 'numeric', not a 'NULL'
> str(cds)
Formal class 'CellDataSet' [package "monocle"] with 19 slots
  ..@ reducedDimS          : num[0 , 0 ] 
  ..@ reducedDimW          : num[0 , 0 ] 
  ..@ reducedDimA          : num[0 , 0 ] 
  ..@ reducedDimK          : num[0 , 0 ] 
  ..@ minSpanningTree      :Error in vcount(x) : 
  REAL() can only be applied to a 'numeric', not a 'NULL'

Edit: I looked at the minSpanningTree and see the following message

This graph was created by an old(er) igraph version.
  Call upgrade_graph() on it to use with the current igraph version
  For now we convert it on the fly...
Error in is_directed(object) : 
  REAL() can only be applied to a 'numeric', not a 'NULL'

Did this get resolved?

lisahnglai commented 1 year ago

I met the same error, did it get resolved? I can view it in R 4.2.0, but i did not view it in R 4.1.3. if i use R 4.2.0, i met the another error in this step: cds <- orderCells(cds)

lisahnglai commented 1 year ago

I solve this problem,the whole process can be successfully completed by running with R 4.1.3.

Jianghf666 commented 1 year ago

Hello, lisahnglai How did you solve the above problem, just the R version problem? Can you provide more details? I would appreciate it very much

XiaoMi93 commented 3 months ago

Reloading the monocle package works for me

handesome commented 1 week ago

same question,I‘d never met this error last week, but when I run the same code,the error happen today.anyone solve it?