取得某个GO term的基因列表
library(org.Hs.eg.db)
AnnotationDbi::select(org.Hs.eg.db, keys = "GO:0006915", columns = "SYMBOL", keytype = "GO")
Velocyto画图show.velocity.on.embedding.cor报错:OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
show.velocity.on.embedding.cor(embVelocyto_clusters,rvel.cd.Velocyto_clusters,n=200,scale="log",
cex=0.8,arrow.scale=6,show.grid.flow=T,n.cores = 1,
min.grid.cell.mass=1.0,grid.n=60,arrow.lwd=0.7,
do.par=T,cell.border.alpha = 0.1, main="Cell Velocity")
Seurat的FeaturePlot正确读取reduction坐标
#Seurat FeaturePlot, 选择reduction后,会通过reduction的key
#比如umap的key是“UMAP_”,使用
#FetchData.Seurat(object = object, vars = c(dims, "ident", features))读取坐标信息
#这里features应该是key加上1或者2:paste0(key,c(1,2))
#但是如果对应reduction@cell.embedding的colnames不是上述的features的话,就找不到对应的坐标,就会报错
#error: The following requested variables were not found: key1, key2
#同时,如果你有两个reduction,key相同,cell.embeding的colnames相同,那么总有一个reduction的坐标是没办法访问的,会被覆盖。直到你修改key以及对应的cell.embeding的colnames为止
因此,要想特定reduction的坐标被featureplot正确读取,需要确定key和cell.embeding的colnames准确对应
colnames(seurat.obj@reduction$reduction1@cell.embeding)<- paste0(seurat.obj@reduction$reduction1@key,c(1,2)
#同时保证key是独一无二的
关于Seurat的reduction object
尽管Seurat的reduction object包含很多子元素,但是构建一个DimReduc对象的必要充分的条件仅仅是cell.embeddings这一矩阵(行为样本列为变量)
如果我们有一个自己定义的低维矩阵:matrix,那么我们可以依次构建一个名为test的DimReduc对象:
其中key为“key_”
因此对应的cell.embeddings的colnames应为
paste0('key',1:ncol(matrix))
当然你无需手动改变matrix的colnames,因为我们将使用函数CreateDimReducObject构建一个DimReduc对象,该函数会自动改变cell.embeddings的colnames
obj[['test']] <- CreateDimReducObject(embeddings = matrix,key = 'key_')
这个名为test的DimReduc可供FindNeighbors、FindCluster、RunUMAP:
obj <- obj %>% RunUMAP(reduction = 'test',dims = 1:10) %>%
FindNeighbors(reduction = 'test',dims = 1:10) %>%
FindClusters(resolution = 0.6)