eliminating overlap of outer bar plots and inner heat maps

22 views
Skip to first unread message

Tiago Pereira

unread,
Feb 13, 2024, 9:46:29 AMFeb 13
to ggtree

Hi everyone

I have used the code for the circular tree with additional data annotation (Fig. 10.2, https://yulab-smu.top/treedata-book/chapter10.html) but I am having issues with the overlap of the inner heatmap rings and the outer bartplots. See figure attached.

I have played with the different parameters in the code (also attached), but so far I have not been successful to either (1) reduce the size of the inner heatmap rings (I have only two categories) or (2) move the barplots further out, so they do not overlap.

I am wondering if you can give me some guidance with this issue.

Thanks in advance!

`tree_nema_18S <- read.tree("data/wofa-asv-nematodes-rep-sequences.tree")
dat1_nema <- read.csv("exported_tables/combined/wofa_nematode_ludox_tippoint_attr.csv")
dat2_nema <- read.csv("exported_tables/combined/wofa_nematode_ludox_ringheatmap_attr.csv")
dat3_nema <- read.csv("exported_tables/combined/wofa_nematode_ludox_barplot_attr.csv")

dat2_nema$Group <- factor(dat2_nema$Group,
levels=c("Gp1", "Gp2"))

dat3_nema$Group <- factor(dat3_nema$Group,
levels=c("Gp1", "Gp2"))

p_nematoda <- ggtree(tree_nema_18S, layout="fan", size=0.15, open.angle=5)
p_nematoda

p_nematoda <- p_nematoda %<+% dat1_nema + geom_fruit(geom=geom_star,
mapping=aes(fill=Family, size=Size),
position="identity",starstroke=0.1)+
scale_fill_manual(values=c("#FFC125","#87CEFA","#7B68EE","#808080","#EE6A50",
"#9ACD32","#D15FEE","#FFC0CB","#800080","#8DEEEE",
"#006400","#800000","#f58231","#191970","#9a6324",
"#46f0f0","#1F78B4","#bcf60c","#e6beff","#4363d8",
"#008080","#e6194b","#f032e6","#aaffc3", "lightgreen",
"#ffe119","#75","#fffac8","#9a6324","#FB9A99",
"#33A02C","#fabebe","#6A3D9A", "gray", "lightblue", "darkblue", "mediumspringgreen"),
guide=guide_legend(keywidth = 0.5, keyheight = 0.5, order=1,
override.aes=list(starshape=15)),
na.translate=FALSE)+
scale_starshape_manual(values=c(15, 1, 3, 5, 7, 2, 10, 9),
guide=guide_legend(keywidth = 0.5, keyheight = 0.5, order=2),
na.translate=FALSE)+
scale_size_continuous(range = c(1, 2.5),
guide = guide_legend(keywidth = 0.5, keyheight = 0.5, order=3,
override.aes=list(starshape=15)))+
new_scale_fill()+
geom_fruit(data=dat2_nema, geom=geom_tile,
mapping=aes(y=ID, x=Group, alpha=Abundance, fill=Group),
color = "grey50", offset = 0.04, size = 0.02)+
scale_alpha_continuous(range=c(0, 1),
guide=guide_legend(keywidth = 0.3, keyheight = 0.3, order=5)) +
geom_fruit(data=dat3_nema, geom=geom_bar,
mapping=aes(y=ID, x=HigherAbundance, fill=Group),
pwidth=0.38, orientation="y", stat="identity")+
scale_fill_manual(values=c("#75", "#46f0f0"),
guide=guide_legend(keywidth = 0.3, keyheight = 0.3, order=4))+
geom_treescale(fontsize=1.2, linesize=0.3, x=0.1, y=0.0001) +
theme(legend.position=c(1.2, 0.5),
legend.background=element_rect(fill=NA),
legend.title=element_text(size=5),
legend.text=element_text(size=4),
legend.spacing.y = unit(0.02, "cm"))
p_nematoda


p_nematoda_ludox.pdf
Reply all
Reply to author
Forward
0 new messages