monocle做擬時(shí)序分析首先要構(gòu)建CDS需要3個(gè)矩陣:expr.matrix、pd技俐、fd,其次將Seurat中的對(duì)象轉(zhuǎn)換為monocle識(shí)別的對(duì)象。然后選擇想要做擬時(shí)序依據(jù)的基因就可以了,如果已知開(kāi)始和結(jié)束的細(xì)胞祈噪,將過(guò)程開(kāi)始時(shí)收集的細(xì)胞與結(jié)束時(shí)收集的細(xì)胞簡(jiǎn)單地進(jìn)行比較,并找到差異表達(dá)的基因尚辑,做擬時(shí)序依據(jù)的基因辑鲤,根據(jù)時(shí)間點(diǎn)的差異分析選擇基因通常非常有效,但是如果我們沒(méi)有時(shí)間序列數(shù)據(jù)杠茬,可以選擇離散度和表達(dá)量高的基因月褥。
library(monocle)
packageVersion("monocle")
#monocle構(gòu)建CDS需要3個(gè)矩陣:expr.matrix、pd瓢喉、fd
# 將Seurat中的對(duì)象轉(zhuǎn)換為monocle識(shí)別的對(duì)象
#cds <- importCDS(GetAssayData(seurat.object))
#選擇做擬時(shí)序的亞群
Mono_tj<-subset(seurat.object, idents = c(1,2,4,6,7))
Mono_matrix<-as(as.matrix(GetAssayData(Mono_tj,slot = "counts")), 'sparseMatrix')
#構(gòu)建featuredata宁赤,一般featuredata需要兩個(gè)col,一個(gè)是gene_id,一個(gè)是gene_short_name,row對(duì)應(yīng)counts的rownames
feature_ann<-data.frame(gene_id=rownames(Mono_matrix),gene_short_name=rownames(Mono_matrix))
rownames(feature_ann)<-rownames(Mono_matrix)
#
Mono_fd<-new("AnnotatedDataFrame", data = feature_ann)
#
#Seurat object中的@meta.data一般會(huì)存放表型相關(guān)的信息如cluster栓票、sample的來(lái)源决左、group等,所以選擇將metadata轉(zhuǎn)換為phenodata
sample_ann<-Mono_tj@meta.data
#rownames(sample_ann)<-colnames(Mono_matrix)
Mono_pd<-new("AnnotatedDataFrame", data =sample_ann)
#build new cell data set
Mono.cds<-newCellDataSet(Mono_matrix,phenoData =Mono_pd,featureData =Mono_fd,expressionFamily=negbinomial.size())
#查看phenodata走贪、featuredata
head(pData(Mono.cds))
head(fData(Mono.cds))
#預(yù)處理
Mono.cds <- estimateSizeFactors(Mono.cds)
Mono.cds <- estimateDispersions(Mono.cds)
#篩選基因,這里可以根據(jù)自己的需要篩選特定的基因
disp_table <- dispersionTable(Mono.cds)
unsup_clustering_genes <- subset(disp_table, mean_expression >= 0.1)
Mono.cds <- setOrderingFilter(Mono.cds, unsup_clustering_genes$gene_id)
#用DDRtree 進(jìn)行降維分析
Mono.cds <- reduceDimension(
Mono.cds,
max_components = 2,
method = 'DDRTree')
#計(jì)算psudotime值
Mono.cds <- orderCells(Mono.cds)
head(pData(Mono.cds))
plot_cell_trajectory(Mono.cds,cell_size = 1)
plot_cell_trajectory(Mono.cds, color_by = "Pseudotime")
plot_cell_trajectory(Mono.cds, color_by = "seurat_clusters",cell_size = 1)
歡迎關(guān)注~
參考:http://cole-trapnell-lab.github.io/monocle-release/docs/
https://cole-trapnell-lab.github.io/monocle-release/Paul_dataset_analysis_final.html
作者:生信編程日常
鏈接:http://www.reibang.com/p/9cb936749242