标签: ggtree

与ggtree ggjoy facet

是否可以将一个joyplot作为面板添加到包含ggtree的图中,如这些示例所示?这里有joyplots的例子.

我意识到我可以按照与树尖标签相同的顺序手动设置joyplot的物种标签,但我正在寻找一种自动解决方案.我想自动将joyplot行与树的提示相关联,类似于boxplot数据与tip标签的关联方式.

我认为Yuchuang Yu在上面链接的例子提供了合适的数据:

require(ggtree)
require(ggstance)

# generate tree
tr <- rtree(30)

# create simple ggtree object with tip labels
p <- ggtree(tr) + geom_tiplab(offset = 0.02)

# Generate categorical data for each "species"
d1 <- data.frame(id=tr$tip.label, location=sample(c("GZ", "HK", "CZ"), 30, replace=TRUE))

#Plot the categorical data as colored points on the tree tips
p1 <- p %<+% d1 + geom_tippoint(aes(color=location))

# Generate distribution of points for each species
d4 = data.frame(id=rep(tr$tip.label, each=20), 
            val=as.vector(sapply(1:30, function(i) 
                            rnorm(20, mean=i))) …
Run Code Online (Sandbox Code Playgroud)

r data-visualization ggplot2 ggtree ggridges

12
推荐指数
1
解决办法
2393
查看次数

如何在ggtree的系统发育树中的同一标签中应用斜体和普通字体

我想要斜体的 A,普通的 CBS。我认为 ggtext 可能有用,但我遇到了错误。这是一个例子:

tree<-read.tree(text="(A,(B,C));")
labs=c("*A*CBS","B","C")
tree$tip.label<-labs
ggtree(tree)+ geom_tiplab(align=T) + geom_richtext()

error: geom_rich_text requires the following missing aesthetics: label
Run Code Online (Sandbox Code Playgroud)

我也尝试过

ggtree(tree)+ aes(label=labs)+geom_tiplab(align=T) + geom_richtext()
error: Aesthetics must be either length 1 or the same as the data (5): label
Run Code Online (Sandbox Code Playgroud)

但我需要的富文本位于三个提示标签中,并非所有五个标签(提示和节点)中有人知道如何添加标签美观(作为提示标签)吗?

r ggplot2 ggtree ggtext

5
推荐指数
1
解决办法
915
查看次数

ggtree 绘图区域不够大

我正在尝试绘制一个带有引导标记节点和用户定义/彩色提示标签的圆形系统发育树。我得到了引导结果和标签,可以正常工作,但不知何故,我无法在图形设备中完全绘制绘图。总是有一些标签(从圆形系统树的中心向外辐射)丢失了自己的部分。唯一的方法是将尖端标签尺寸设置得非常小。

距离矩阵和 bootstrap 所基于的 DNAbin 文件由 82 个微生物菌株数据 (812aa) 组成。提示标签根据单独的属性文件进行着色。

dna_b<-read.dna("filename.txt", format="fasta")
dist.b<-dist.dna(dna_b)
tree_b<-nj(dist.b)
bp_b<-boot.phylo(tree_b, dna_b, B=1000, function(xx) nj(dist.dna<xx)))
tree_b2<-apeBoot(tree_b, bp_b)
phylo_b<-ggtree(tree_b2, layout='circular', size=0.02, branch.length = "none")+geom_text2(aes(label=bootstrap), size = 2)+geom_tiplab(aes(angle=angle))
#I changed the tiplab to original so using user defined attribute data was not required (the next line).
#phylo_b<-phylo_b %<+% isolate_attr +geom_tiplab(aes(color=tr_level,angle=angle),size=1)
phylo_b+theme(legend.position = "right", legend.text = element_text(size=3))+guides(colour = guide_legend(override.aes = list(size=3)))
Run Code Online (Sandbox Code Playgroud)

我尝试设置更大宽度和高度的新图形设备,但没有成功。调整边距也不起作用。通过将tiplab大小设置为小于0.05,我可以获得完整的图,但这确实不是最佳的。非常感谢这里的一些帮助。

会议信息:

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale: …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 bioconductor phylogeny ggtree

3
推荐指数
1
解决办法
8897
查看次数

如何在ggtree中按组为树的尖端着色?

如何根据样本所属的组简单地为树的尖端着色?

nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)

group_1 <- rep("1.1.1", 5)
group_2 <- rep("1.1.2", 3)
group_3 <- rep("1.2", 2)
group_4 <- rep("1.2.1", 2)
group_5 <- "1.2"

meta_data <- data.frame(ID = LETTERS[1:13], 
                        group = c(group_1, group_2, group_3, group_4, group_5))

Run Code Online (Sandbox Code Playgroud)

我该如何处理元数据才能使提示显示为彩色圆圈或正方形(或其他形状)并根据这些颜色创建图例?

我在 ggtree 文档中看到了类似的树,但是它们的代码非常复杂(例如,请参见https://guangchuangyu.github.io/ggtree-book/chapter-ggtree.html中的第 4.3.7.3 节)。

另外,我无法重现这些示例,因为它们依赖于没有明确说明可用的元数据:

treefile <- "RAxML_bestTree.Aln_All_H3.nwk"
tipseqfile <- "Aln_All_H3_filted.fas"
Run Code Online (Sandbox Code Playgroud)

例如。

必须有一种简单的方法来使用此元数据为提示着色。

r ggtree

1
推荐指数
1
解决办法
1007
查看次数