我想使用类似于下面代码的代码,该代码适用于 Monocle 包中的肺数据集:
options(stringsAsFactors = FALSE)
library("monocle")
lung <- load_lung()
diff_test_res <- differentialGeneTest(
lung,
fullModelFormulaStr = "~genotype"
)
ordering_genes <- diff_test_res[diff_test_res$qval < 0.01, "gene_id"]
lung <- setOrderingFilter(lung, ordering_genes)
plot_ordering_genes(lung)
lung <- reduceDimension(
lung,
max_components = 2,
method = 'DDRTree'
)
lung <- orderCells(lung)
p = plot_genes_in_pseudotime(lung)
df = p$data
df
我想为我自己的数据集运行以下命令,但最后一行花费的时间太长。diff_test_res 行也需要大约 5 分钟,但这对于与我的大小相当的肺数据集来说是即时的:
#Create CellDataSet object
cds <- newCellDataSet(expr_matrix.s4, phenoData = pd, featureData = fd, expressionFamily=negbinomial.size())
cds <- estimateSizeFactors(cds)
cds <- estimateDispersions(cds)
cds <- detectGenes(cds, min_expr = 0.1)
expressed_genes <- row.names(subset(fData(cds), num_cells_expressed >= 10))
#Cluster
disp_table <- dispersionTable(cds)
unsup_clustering_genes <- subset(disp_table, mean_expression >= 0.1)
cds <- setOrderingFilter(cds, unsup_clustering_genes$gene_id)
cds <- reduceDimension(cds, max_components = 2, num_dim = 6,
reduction_method = 'tSNE', verbose = T)
cds <- clusterCells(cds, num_clusters = 4)
#Plot differentially expressed genes in pseudotime
cds_myo <- estimateDispersions(cds)
diff_test_res <- differentialGeneTest(cds_myo[expressed_genes,],fullModelFormulaStr = '~Cluster', cores = 10)
ordering_genes <- row.names (subset(diff_test_res, qval < 0.01))
cds_myo <- setOrderingFilter(cds_myo, ordering_genes)
plot_ordering_genes(cds_myo)
cds_myo <- reduceDimension(
cds_myo,
max_components = 2,
method = 'DDRTree'
)
cds_myo <- orderCells(cds_myo)
p = plot_genes_in_pseudotime(cds_myo)
有熟悉 Monocle 的人知道我如何加快速度吗?
非常感谢。