根据视频学习单细胞测序拟时序分析中出现的报错应该怎么解决
library(monocle)
data <- as(as.matrix(scRNA@assays$RNA@counts), 'sparseMatrix')
pd <- new('AnnotatedDataFrame', data = scRNA@meta.data)
fData <- data.frame(gene_short_name = row.names(data), row.names = row.names(data))
fd <- new('AnnotatedDataFrame', data = fData)
mycds <- newCellDataSet(data,
phenoData = pd,
featureData = fd,
expressionFamily = negbinomial.size())
save(mycds, file = "c:/Users/LWD/Desktop/scRNAseq/mycds_raw.Rdata")
rm(list = ls())
load("../../tmp/mycds_raw.Rdata")
#library("monocle")
mycds <- estimateSizeFactors(mycds)
mycds <- estimateDispersions(mycds, cores=4, relative_expr = TRUE) #!
load("../../tmp/markergene.Rdata")
markers.gene <- all.markers$gene
mycds <- setOrderingFilter(mycds, markers.gene)
mycds <- reduceDimension(mycds, max_components = 2, method = 'DDRTree') #!
mycds <- orderCells(mycds)
#save(mycds,file = "../../tmp/mycds_reduced.Rdata")
load("../../tmp/mycds_reduced.Rdata")
p1 <- plot_cell_trajectory(mycds, color_by = "seurat_clusters")
ggsave("../../out/3.4trajectory_1.pdf", plot = p1)
p2 <- plot_cell_trajectory(mycds, color_by = "State")
ggsave("../../out/3.4trajectory_2.pdf", plot = p2)
data <- as(as.matrix(scRNA@assays$RNA@counts), 'sparseMatrix')
pd <- new('AnnotatedDataFrame', data = scRNA@meta.data)
fData <- data.frame(gene_short_name = row.names(data), row.names = row.names(data))
fd <- new('AnnotatedDataFrame', data = fData)
mycds <- newCellDataSet(data,
phenoData = pd,
featureData = fd,
expressionFamily = negbinomial.size())
save(mycds, file = "c:/Users/LWD/Desktop/scRNAseq/mycds_raw.Rdata")
mycds <- estimateSizeFactors(mycds)
mycds <- estimateDispersions(mycds, cores=4, relative_expr = TRUE)
Removing 95 outliers
Warning messages:
1:group_by_()
was deprecated in dplyr 0.7.0.
Please usegroup_by()
instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Calllifecycle::last_lifecycle_warnings()
to see where this warning was generated.
2:select_()
was deprecated in dplyr 0.7.0.
Please useselect()
instead.
This warning is displayed once every 8 hours.
Calllifecycle::last_lifecycle_warnings()
to see where this warning was generated.
markers.gene <- all.markers$gene
mycds <- setOrderingFilter(mycds, markers.gene)
mycds <- reduceDimension(mycds, max_components = 2, method = 'DDRTree')
p1 <- plot_cell_trajectory(mycds, color_by = "seurat_clusters")
mycds <- orderCells(mycds)
Error in if (class(projection) != "matrix") projection <- as.matrix(projection) :
the condition has length > 1
In addition: Warning message:
In graph.dfs(dp_mst, root = root_cell, neimode = "all", unreachable = FALSE, :
Argumentneimode' is deprecated; use
mode' instead
感觉无从下手
能解决报错并成功出图
您收到该错误是因为您只能评估 if (...) 中的单个 T/F。但是,data[1, ] < ... 是一个矢量化评估,它返回一个长度为 n 的 T/F 向量(即,对于上述情况,为 1000)。不过,我认为您的第二个函数 (est_L) 与该图像中显示的等式不匹配。