在原有的UMAP上标注RNA velocity

2020-04-24 15:53:36 浏览数 (1)

1.读入RNA velocity的loom文件,并提取spliced文件和unspliced文件
代码语言:javascript复制
ldat <- ReadVelocity(file = test.loom")
emat <- ldat$spliced
nmat <- ldat$unspliced
2.提取原有的用seurat做的UMAP的图。
代码语言:javascript复制
emb <- seurat.object@reductions$umap@cell.embeddings
# Estimate the cell-cell distances 
cell.dist <- as.dist(1-armaCor(t(seurat.object@reductions$umap@cell.embeddings)))
3.将RNA velocity的细胞的名字改成原有的seurat用到的细胞名字
代码语言:javascript复制
colnames(emat) <- paste(substring(colnames(emat),6,21),"_1",sep="")
colnames(nmat) <- paste(substring(colnames(nmat),6,21),"_1",sep="")
4.对velocity进行计算
代码语言:javascript复制
# I'm not sure what this parameter does to be honest. 0.02 default
# perform gamma fit on a top/bottom quantiles of expression magnitudes
fit.quantile <- 0.02
# Main velocity estimation
rvel.cd <- gene.relative.velocity.estimates(emat,nmat,deltaT=2,
                                            kCells=10,
                                            cell.dist=cell.dist,
                                            fit.quantile=fit.quantile,
                                            n.cores=24)
5.提取原seurat对象的UMAP图的细胞颜色
代码语言:javascript复制
# This section gets the colors out of the seurat tSNE object so that my seurat and velocyto plots use the same color scheme.
gg <- UMAPPlot(seurat.object)
ggplot_build(gg)$data
colors <- as.list(ggplot_build(gg)$data[[1]]$colour)
names(colors) <- rownames(emb)
6.将velocity画在原有的seurat的UMAP上
代码语言:javascript复制
 p1 <- show.velocity.on.embedding.cor(emb,rvel.cd,n=30,scale='sqrt',
                                      cell.colors=ac(colors,alpha=0.5),
                                      cex=0.8,arrow.scale=2,show.grid.flow=T,
                                      min.grid.cell.mass=1.0,grid.n=50,arrow.lwd=1,
                                      do.par=F,cell.border.alpha = 0.1,
                                      n.cores=24,main="Day1 Cell Velocity")

参考: https://github.com/velocyto-team/velocyto.R/issues/16

0 人点赞