看Cross-tissue organization of the fibroblast lineage的时候发现作者使用了Slingshot这个r包来做拟时序分析,尝试使用了一下。
一、加载数据,转换格式
我使用的数据集:正常成纤维单细胞数据集(https://doi.org/10.1038/s41586-021-03549-5 ),seurat文件。
library(slingshot)
library(Seurat)
library(SingleCellExperiment)
library(RColorBrewer)
#加载单细胞数据集
load(file = "sc.RData")
#seurat转换为SingleCellExperiment
sc <- as.SingleCellExperiment(sc)
二、运行slingshot
sc <- slingshot(sc, clusterLabels = "ClustName", reducedDim = "UMAP")
sc
#class: SingleCellExperiment
#dim: 21087 5000
#metadata(0):
#assays(2): counts logcounts
#rownames(21087): Sox17 Mrpl15 ... 1700109K24Rik Gm10556
#rowData names(0):
#colnames(5000): AAGGTTCAGACAGACC-1_1_1 AAGTCTGAGGATGGTC-1_1_1 ...
# TTGGAACCACCACGTG.4_32 TTTATGCGTCTGATTG.4_32
#colData names(11): nCount_RNA nFeature_RNA ... slingPseudotime_3
# slingPseudotime_4
#reducedDimNames(3): PCA HARMONY UMAP
#mainExpName: RNA
#altExpNames(0):
summary(sc$slingPseudotime_1)
#Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# 0.155 7.934 12.553 13.726 19.180 27.999 1559
三、可视化
折线图:可指定起始和终点细胞簇(如果有先验知识,不指定的话就是无监督的)。
lin1 <- getLineages(sc,
clusterLabels = "ClustName",
#start.clus = 'Pi16',#可指定起始细胞簇
#end.clus=c("Comp","Col15a1","Ccl19"),#可指定终点细胞簇
reducedDim = "UMAP")
plot(reducedDims(sc)$UMAP,col = brewer.pal(10,'Paired')[sce$Cluster],pch=16,asp=1)
lines(SlingshotDataSet(lin1), lwd=2,col = 'black',type = 'lineages')
轨迹图:不指定起始和终点细胞簇(左)和同时指定起始和终点细胞簇(右)。
曲线图:我这里使用了同时指定起始和终点细胞簇的lin1,得到的结果和文章基本一致。
crv1 <- getCurves(lin1)
plot(reducedDims(sc)$UMAP,col = brewer.pal(10,'Paired')[sce$Cluster],pch=16,asp=1)
lines(SlingshotDataSet(crv1), lwd = 3, col = 'black')
参考文献:Slingshot: cell lineage and pseudotime inference for single-cell transcriptomics.BMC Genomics, 2018, 19, 477.
帮助文档:Slingshot: Trajectory Inference for Single-Cell Data (bioconductor.org)
网友评论