首页 > 解决方案 > 为R中的集成Seurat对象创建层次聚类树状图?

问题描述

有谁知道如何为集成的 Seurat 对象创建树状图。我可以为非集成对象执行此操作,但是当我尝试时:

immune.combined <- BuildClusterTree(object = immune.combined, slot = "data")

我看到了错误:

Error in hclust(d = data.dist) : NA/NaN/Inf in foreign function call (arg 10)

标签: rhierarchical-clusteringdendrogramseurat

解决方案


如果您遵循正常的 Seurat 工作流程,在某些时候您会将默认检测更改为“RNA”。查看 BuildClusterTree 的源代码,它使用了所选分析中变化最大的特征(您所选分析下的大型 Seurat 对象中的 var.features)。对于集成工作流程,您只计算了“集成”分析的这些值,而不是 RNA 分析。因此,您需要对综合分析进行分析。这将意味着这样的事情:

sampleIntegrated <- BuildClusterTree(sampleIntegrated,assay="integrated")

由于某种原因不起作用,并且产生了相同的错误。但是,如果您首先将默认检测明确设置为集成,则它可以工作:

DefaultAssay(sampleIntegrated) <- "integrated"
sampleIntegrated <- BuildClusterTree(sampleIntegrated,assay="integrated")

然后,您可以使用您选择的可视化方法。例如,使用 Seurat 的 ggtree 包和工具:

library(ggtree)
myPhyTree <- Tool(object=sampleIntegrated, slot = "BuildClusterTree")
ggtree(myPhyTree)+geom_tiplab()+theme_tree()+xlim(NA,400)

推荐阅读