ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Composite plots to circular layout

Open LuffyLuffy opened this issue 5 years ago • 4 comments
trafficstars

Dear Prof Yu, I see a wonderful example of the ggtree data in the 7.5 sector. https://yulab-smu.github.io/treedata-book/chapter7.html#gheatmap-ggnewscale

library(ggplot2) library(ggtree)

set.seed(2019-10-31) tr <- rtree(10)

d1 <- data.frame( label = c(tr$tip.label[sample(5, 5)], "A"), value = sample(1:6, 6))

d2 <- data.frame( label = rep(tr$tip.label, 5), category = rep(LETTERS[1:5], each=10), value = rnorm(50, 0, 3))

g <- ggtree(tr) + geom_tiplab(align=TRUE)

p1 <- ggplot(d1, aes(label, value)) + geom_col(aes(fill=label)) + coord_flip() + theme_tree2() + theme(legend.position='none')

p2 <- ggplot(d2, aes(x=category, y=label)) + geom_tile(aes(fill=value)) + scale_fill_viridis_c() + theme_tree2()

library(aplot) p2 %>% insert_left(g) %>% insert_right(p1, width=.5)

I wonder if it is possible to create a circular layout of this data

image

so that ggtree can really reporduce a figure like bellow. image

LuffyLuffy avatar May 21 '20 10:05 LuffyLuffy

Yes, You can reporduce the figure using ggtreeExtra

xiangpin avatar Jun 15 '20 05:06 xiangpin

Yes, You can reporduce the figure using ggtreeExtra

Awesome! I try the code in ggtreeExtra, the starshape seem not to work.

Error in starGrob(x = coords$x, y = coords$y, gp = gpar(fill = alpha(coords$fill, : the starshape should be one of 1 to 12 ! Warning message: Removed 229 rows containing missing values (geom_star).

LuffyLuffy avatar Jun 15 '20 08:06 LuffyLuffy

The version of ggstar in README is development. You can update the vesion of ggstar from github, or you can use scale_starshape_manual to set 1~12 values.

xiangpin avatar Jun 15 '20 09:06 xiangpin

The version of ggstar in README is development. You can update the vesion of ggstar from github, or you can use scale_starshape_manual to set 1~12 values.

Great! Problem solved out! The ggstar is also great! The pch is limit in to several groups. You guys are asesome!

LuffyLuffy avatar Jun 15 '20 09:06 LuffyLuffy