UMAP图分不开怎么办?

作者: 周运来就是我 | 来源:发表于2021-02-02 22:19 被阅读0次

    在这里,与国际同行一起学习数据分析。

    在单细胞数据分析过程中,往往需要看不同的参数下的数据表现,也往往需要循环某个列表(基因集或者分组),这时候向量化测试效率就比较高了。

    向量(vector)是R编程里最底层也是最核心的结构,并且从广泛意义上的数据类型而言,R中的矩阵和数组甚至是列表都是向量。提升代码效率的有效途径便是向量化(vectorize),即将运算符或者函数作用在向量的每一个元素上的一种理念。

    多个聚类的resolution参数:

    library(Seurat)
    library(SeuratData,lib.loc = 'F:\\EE\\software\\R\\R-4.0.2\\library')
    library(pbmc3k.SeuratData,lib.loc = 'F:\\EE\\software\\R\\R-4.0.2\\library')   
    library(clustree,lib.loc = 'F:\\EE\\software\\R\\R-4.0.2\\library')    
    .libPaths()
    library(tidyverse)
    library(cowplot)
    pbmc3k.final <- FindClusters(pbmc3k.final,dims=1:20,resolution = seq(from=0,by=.2,length=10))
    clustree(pbmc3k.final)
    

    分群可视化,其实是map函数的应用。

    Idents(pbmc3k.final) <- "seurat_annotations"
    p=list()
    p<- map(c(levels(Idents(pbmc3k.final))),function(x){DimPlot(pbmc3k.final, cells.highlight = CellsByIdentities(object = pbmc3k.final, idents = x))})
    plot_grid(plotlist = p)
    

    下面来看另一个例子:调节UMAP结构。那么我们就看看可视化有什么参数可以调节:

    • 3D
    • 调RunUMAP的参数
    • 换可视化方法

    今天我们来看看n.neighbors和epochs,negative.sample.rate 这几个函数的影响:

    map(c(2,seq(from=5,by=50,length=10)) , function(x) { pbmc3k.final %>%  RunUMAP(n.neighbors = x,n.epochs=200,dims = 1:20) %>% DimPlot()}) %>% cowplot::plot_grid(plotlist = .)
    
    
    c(2,seq(from=5,by=50,length=10) )
     [1]   2   5  55 105 155 205 255 305 355 405 455
    map(c(2,seq(from=5,by=50,length=10)) , function(x) { pbmc3k.final %>%  RunUMAP(n.neighbors = 50,n.epochs=x,dims = 1:20) %>% DimPlot()}) %>% cowplot::plot_grid(plotlist = .)
    
    
    map(c(2,seq(from=1,by=5,length=10)) , function(x) { pbmc3k.final %>%  RunUMAP(n.neighbors = 50,n.epochs=500,negative.sample.rate = x,dims = 1:20) %>% DimPlot()}) %>% cowplot::plot_grid(plotlist = .)
    
    

    好了,节目的最后,放一张大佬的小道消息:


    相关文章

      网友评论

        本文标题:UMAP图分不开怎么办?

        本文链接:https://www.haomeiwen.com/subject/szsutltx.html