monocle-release
monocle-release copied to clipboard
estimateDispersion: object 'fit' not found
Hello all,
I am trying to run the following lines
cds <- newCellDataSet(as(as.matrix(tpm_mat), "sparseMatrix"),phenoData = pd,featureData =fd, lowerDetectionLimit = 0.5, expressionFamily = negbinomial.size()) cds <- estimateSizeFactors(cds) cds <- estimateDispersions(cds)#having problems
but I keep getting the error message
"Error in glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = c(1e-06, : object 'fit' not found"
Any ideas what I could be doing wrong? Thank you so much for your help!
I am not aware of this error. you can post a link to your data for me to take a look if you want. thanks
Hi, I'm facing the same issue. Attaching my data file. Please let me know if you need any other information from me! Thanks! Controldata.txt
I'm also having the same problem. Just posting here to follow the thread :) Do let me know if I can help in some way!
same issue. The cds come from seurat and anndata.
Idents(scRNA) <- 'orig.ident'
subnew <- subset(scRNA,idents=c('day5'))
Idents(subnew) <- 'integrated_snn_res.0.8'
subnew <- subset(subnew,idents=c(3,8,10,12))
sample_ann <- [email protected]
sample_ann$celltype=subnew$leiden
gene_ann <- data.frame(
gene_short_name = rownames(subnew@assays$RNA) ,
row.names = rownames(subnew@assays$RNA)
)
pd <- new("AnnotatedDataFrame",
data=sample_ann)
fd <- new("AnnotatedDataFrame",
data=gene_ann)
ct=as.data.frame(GetAssayData(subnew,slot = 'counts',assay = 'RNA'))
cds <- newCellDataSet(
as.matrix(ct),
phenoData = pd,
featureData =fd,
expressionFamily = negbinomial.size(),
lowerDetectionLimit=1)
cds <- detectGenes(cds, min_expr = 1)
cds <- cds[fData(sc_cds)$num_cells_expressed > 10, ]
cds <- estimateSizeFactors(cds)
cds <- estimateDispersions(cds)
> cds <- estimateSizeFactors(cds)
Warning message:
In if (isSparseMatrix(counts)) { :
the condition has length > 1 and only the first element will be used
> cds <- estimateDispersions(cds)
Error in glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = c(1e-06, :
object 'fit' not found
In addition: Warning messages:
1: In if (isSparseMatrix(exprs(cds))) { :
the condition has length > 1 and only the first element will be used
2: In glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = c(1e-06, :
no observations informative at iteration 1
3: glm.fit: algorithm did not converge
I'm also having the same problem with truittll
i also having the same problem with truittll
cds <- estimateSizeFactors(cds) Warning message: In if (isSparseMatrix(counts)) { : the condition has length > 1 and only the first element will be used
cds <- estimateDispersions(cds) Removing 69 outliers Warning message: In if (isSparseMatrix(exprs(cds))) { : the condition has length > 1 and only the first element will be used
I also have the same problem:
cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts) >= 1) { : the condition has length > 1
Then I did the following steps and finally sovled it.
step1: download the sorce code package from https://www.bioconductor.org/packages/3.15/bioc/src/contrib/Archive/monocle/
step2: decompress the compressed package
step3: type ".libPaths()" in R console to check where the library are
.libPaths() [1] "D:/Program Files/R/R-4.2.2/library"
step4: goto this director and find a directory of the same name "monocle"
step5: replace this directory with the one you just decompressed
step6: reload the sorce code package (maybe you need to install "devtools" first) devtools::load_all("D:/Program Files/R/R-4.2.2/library/monocle")
step7: re-run "estimateSizeFactor(cds)"; it will return the error message and also "Return with Debug" button
step8: click "Return with Debug" button. It will show you at which line in which R script, the error comes from. Or, to be simple, you need to edit utils.R and expr_models.R
step9: edit utils.R at line 35: chnage "isSparseMatrix(cellData)" into "isSparseMatrix(cellData)[1]" at line 192: change "isSparseMatrix(exprs(X))" into "isSparseMatrix(exprs(X))[1]" at line 438: change "isSparseMatrix(counts)" into "isSparseMatrix(counts)[1]" all in all, it is because the return of isSparseMatrix() shoulde return one logical value-TRUE/FALSE but now it return two logical values and both them are FALSE !!!remember to save the changes
step10: edit expr_modles.R at line 454: change "isSparseMatrix(exprs(cds))" into "isSparseMatrix(exprs(cds))[1]" !!!remember to save the change
step11: reload monocle devtools::load_all("D:/Program Files/R/R-4.2.2/library/monocle")
Now, the problem is sovled
cds <- estimateSizeFactors(cds) cds <- estimateDispersions(cds) Removing 159 outliers