monocle-release
monocle-release copied to clipboard
what is the "condition" in orderCells() function
Hi,
I am trying to construct single-cell trajectories using monocle, but I got an error message when I use the orderCells() function. the condition has length > 1 and only the first element will be used
any ideas what's going on? Appreciate your ideas.
Maybe it is caused by one if() statement in project2MST() function. The class of this projection matrix in this project2MST() function is c("matrix", "array").
projection <- rbind(projection, tmp) -> "matrix", "array"
if(class(projection) != 'matrix') -> error
projection <- as.matrix(projection)
possible solution: projection <- as.matrix(rbind(projection, tmp))
version: R Biobase eSet ExpressionSet CellDataSet "4.0.0" "2.48.0" "1.3.0" "1.0.0" "1.2.0"
I have the same problem, did you solve it? Error in if (class(projection) != "matrix") projection <- as.matrix(projection) :
the condition has length > 1
此外: Warning message:
In graph.dfs(dp_mst, root = root_cell, neimode = "all", unreachable = FALSE, :
Argument neimode' is deprecated; use
mode' instead
I have the same problem, too. Anyone could help? Many thanks. Bests.
@wangshisheng @ctrapnell @lizhaozhi i had the same issue, had anyone could help us? my R version was 4.2.0
Best
Had any advice for this issue ? @wangshisheng @ctrapnell @lizhaozhi Many thanks, Best
The same issue here. @ctrapnell
您好!已经收到邮件,祝好! 洪汉辉
I have the same problem, this is my solution. I download monocle from https://www.bioconductor.org/packages/3.15/bioc/src/contrib/Archive/monocle/ And change the code in function project2MST() in order_cell.R file.
from
if(class(projection) != 'matrix')
projection <- as.matrix(projection)
to
projection <- as.matrix(projection)
then install the package using install.packages("path to folder with the package", repos = NULL, type = "source")
hope this help
I have the same problem, this is my solution. I download monocle from https://www.bioconductor.org/packages/3.15/bioc/src/contrib/Archive/monocle/ And change the code in function project2MST() in order_cell.R file.
from
if(class(projection) != 'matrix') projection <- as.matrix(projection)
to
projection <- as.matrix(projection)
then install the package using
install.packages("path to folder with the package", repos = NULL, type = "source")
hope this help
Dear 44REAM, Thank you. After changing the function, did you make a new archived packaged with 'tar -czf monocle_2.24.0.tar.gz monocle 2' to replace the original one and installed? or you installed the package with the unarchived folder containing the modified 'order_cell.R' 'install.packages("R_package/monocle 2", repos = NULL, type = "source")'? I encountered the problem in installation....Could you show me more details about how you performed the installation? Many thanks! Guoliang
I have the same problem, too. Anyone could help? Thanks very much. Bests.
您好!已经收到邮件,祝好! 洪汉辉
您好,您的问题解决了吗,谢谢!
Dear Hanhui,
Yes, the problem was perfectly solved by following 44REAM's solution, however, with a bit of modification when performing the last step of installation.
I quote the following solution again as a big thanks for 44REAM as well:
- download monocle from https://www.bioconductor.org/packages/3.15/bioc/src/contrib/Archive/monocle/
- decompress the package 'monocle_2.24.0.tar.gz', and get a 'monocle' folder.
- open the folder 'monocle/R', change the code in function 'project2MST()' in the 'order_cell.R' file: change from
if(class(projection) != 'matrix')
projection <- as.matrix(projection)
to
projection <- as.matrix(projection)
- save the 'order_cell.R' file.
- copy the 'monocle' folder and paste to the location where I usually install my packages.
- In R studio, using the command to load the 'monocle' folder:
devtools::load_all("path to the location/monocle")
7.Done. and managed to run the 'orderCells(cds)'.
Thank you and best,
Guoliang
Dear Hanhui,
Yes, the problem was perfectly solved by following 44REAM's solution, however, with a bit of modification when performing the last step of installation.
I quote the following solution again as a big thanks for 44REAM as well:
- download monocle from https://www.bioconductor.org/packages/3.15/bioc/src/contrib/Archive/monocle/
- decompress the package 'monocle_2.24.0.tar.gz', and get a 'monocle' folder.
- open the folder 'monocle/R', change the code in function 'project2MST()' in the 'order_cell.R' file: change from
if(class(projection) != 'matrix') projection <- as.matrix(projection)
to
projection <- as.matrix(projection)
- save the 'order_cell.R' file.
- copy the 'monocle' folder and paste to the location where I usually install my packages.
- In R studio, using the command to load the 'monocle' folder:
devtools::load_all("path to the location/monocle")
7.Done. and managed to run the 'orderCells(cds)'.
Thank you and best,
Guoliang
Thanks very much!
Thank you @MwGuo11 & @44REAM for providing the edit to update the package.
I noticed that I could not rerun my monocle2 pipeline on the same data that I produced results from previously. It may be from updating my R to the latest version.
Now that I've utilized your update I can get past orderCells(). However, I cannot get retrieve BEAM() results.
`BEAM_res <- BEAM(monocle_cds, branch_point = 1, cores = 8)
Error in if (progenitor_method == "duplicate") { : the condition has length > 1`
I never returned this error before for BEAM(). Does anyone have any experience or input on this error?
Thank you @MwGuo11 & @44REAM for providing the edit to update the package.
I noticed that I could not rerun my monocle2 pipeline on the same data that I produced results from previously. It may be from updating my R to the latest version.
Now that I've utilized your update I can get past orderCells(). However, I cannot get retrieve BEAM() results.
`BEAM_res <- BEAM(monocle_cds, branch_point = 1, cores = 8)
Error in if (progenitor_method == "duplicate") { : the condition has length > 1`
I never returned this error before for BEAM(). Does anyone have any experience or input on this error?
I also have the same problem, I modified the code of / monocle/R /BEAM.R on the basis of 44REAM's solution.
from:
if (progenitor_method == "duplicate") { } else if (progenitor_method == "sequential_split") { }
to:
if ('duplicate' %in% progenitor_method){} else if('sequential_split' %in% progenitor_method){}
@weu74lin
Thank you for your advice on these edits. This change corrected the error.
@weu74lin great idea!
@weu74lin @44REAM Thanks very much!
Hi, I cannot get retrieve plot_genes_branched_heatmap() results.
plot_genes_branched_heatmap(mycds_sub_beam,
branch_point = 1,
num_clusters = 2,
show_rownames = T)
Error in if (isSparseMatrix(exprs(X))) { : the condition has length > 1 In addition: Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)'
Does anyone have any experience or input on this error?
@orange511 it happened to me once when i set the parameter 'cores = 1' in this function. if you change to 2 or else, it will pass; if this doesn't work, you should find another solution.
Hi, I cannot get retrieve plot_genes_branched_heatmap() results.
plot_genes_branched_heatmap(mycds_sub_beam, branch_point = 1, num_clusters = 2, show_rownames = T)
Error in if (isSparseMatrix(exprs(X))) { : the condition has length > 1 In addition: Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)'
Does anyone have any experience or input on this error?
I met the same problem.
I modified the code of / monocle/R /utils.R from: class(x) %in% c("dgCMatrix", "dgTMatrix") to: any(class(x) %in% c("dgCMatrix", "dgTMatrix"))
@zy-fang thank you! it works after i modified that. And it fix the same error when i use plot_genes_branched_pseudotime. however, i still got some warning:
plot_genes_branched_heatmap(cds[row.names(subset(BEAM_res, qval < 1e-4)),], branch_point = 1, num_clusters = 4,
cores = 4,use_gene_short_name = T, show_rownames = T)
Warning message:
In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)'
plot_genes_branched_pseudotime(cds[genes,], branch_point = 1, color_by = "State")
Warning messages:
1: In for (i in seq_len(differences)) r <- r[i1] - r[-length(r):-(length(r) - :
closing unused connection 6 (<-localhost:11964)
2: In for (i in seq_len(differences)) r <- r[i1] - r[-length(r):-(length(r) - :
closing unused connection 5 (<-localhost:11964)
3: In for (i in seq_len(differences)) r <- r[i1] - r[-length(r):-(length(r) - :
closing unused connection 4 (<-localhost:11964)
4: In for (i in seq_len(differences)) r <- r[i1] - r[-length(r):-(length(r) - :
closing unused connection 3 (<-localhost:11964)
5: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE :
'length(x) = 2 > 1' in coercion to 'logical(1)'
Did these warning happen to you and should i ignore it? thank you very much!
I think these warnings can be ignored.
In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)'.
This is because when cellData is a matrix, class(cellData) is going to be c("matrix", "array"). So the class(cellData) != "matrix" will be c(FALSE,TRUE). When do the “&&”at the end, only the first one (FALSE) is taken into account.
4: In for (i in seq_len(differences)) r <- r[i1] - r[-length(r):-(length(r) - : closing unused connection 3 (<-localhost:11964)
This warning is about multiple core parallelism.
@zy-fang Thank you for your advice and these details which help me a lot.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.
sc_cds <- newCellDataSet(
- as.matrix(ct),
- phenoData = pd,
- featureData =fd,
- expressionFamily = negbinomial.size(),
- lowerDetectionLimit=1) Warning message: In class(cellData) != "matrix" && isSparseMatrix(cellData) == FALSE : 'length(x) = 2 > 1' in coercion to 'logical(1)' I also meet this warnings when using the newCellDataSet function. Furthermore, when I run the following codes cds <- estimateSizeFactors(cds) Error in if (isSparseMatrix(counts)) { : the condition has length > 1
cds <- estimateDispersions(cds) Error in .local(object, ...) : NAs found in size factors. Have you called 'estimateSizeFactors'? These error have made the analysis discontinued in the following steps. Thank you for anyone who can solve these problems.