使用 ggtree 为系统发育树的提示着色

时间:2021-06-06 07:20:20

标签: r ggtree

我的编码经验非常有限,所以请耐心等待!

我有一个 newick 树和一个 .txt 文件,其中包含分配给不同克隆编号的不同单元格编号,如下所示:

List

我已经按照 PHE: Bioinformatics 页面中的步骤操作,我得到的只是所有提示上的一种颜色,似乎没有按克隆编号对单元格进行分类。

这是结果图的图像:

Output

library("ggplot2")
library("ggtree")
nwk <- ("/Users/Nisu/Downloads/True.nwk")
tree <- read.tree(nwk)
p <- ggtree(tree,right = TRUE)
tip_metadata <- read.table("/Users/Nisu/Downloads/TallG5clone_50_9_True_cloneAnno.txt", sep="\t",col.names = c("Clone", "Cell"),header=TRUE,check.names=FALSE, stringsAsFactor=F)
p <- p %<+% tip_metadata + geom_tippoint(aes(color= "Clone"), size=3)
plot(p)

1 个答案:

答案 0 :(得分:0)

这很可能是因为您在 "Clone" 中添加了引号。不应引用数据中的变量。因此它应该是geom_tippoint(aes(color= Clone)
下面是一个示例:添加不带引号的 aes colour = class

library(ggplot2)

ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

enter image description here

现在加引号:

ggplot(mpg, aes(displ, hwy, colour = "class")) + 
  geom_point()

enter image description here

相关问题