Skip to content

geom_tiplab angle off when collapsing clades in circular layout #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sarahfrail opened this issue Mar 12, 2025 · 0 comments
Open

geom_tiplab angle off when collapsing clades in circular layout #647

sarahfrail opened this issue Mar 12, 2025 · 0 comments

Comments

@sarahfrail
Copy link

sarahfrail commented Mar 12, 2025

Hello,

I am running into an issue where, when geom_tiplab is used in conjunction with scaleClade, the tip labels are rendering at the angle they would be if they were in their original positions. This causes them to progressively get further away from the desired angle. Further, the geom_point2 disappears after scaling. See p (before scaling) and p2 (after scaling) below.

My code

p <- ggtree(speciestree, layout='circular') %<+% tipdatasimple + xlim_tree(-1) +
  geom_tiplab(aes(label=species, color=kingdom),  angle="auto", size=2, align=TRUE, linesize=0.1) +
  geom_tree(aes(color=kingdom)) +
  scale_color_manual(values = subgroup_colors) +
  ggnewscale::new_scale_fill() +
  scale_fill_carto_c(name = "Orthologue count", palette = "DarkMint", limits=c(0,10), breaks=c(0,2,4,6,8,10)) +
  geom_point2(aes(subset = in_orthocounts, x = max(x) -0.05, fill=count), shape=21, size=2, stroke=NA) + 
  geom_text2(aes(subset = in_orthocounts, x = max(x) -0.05, label = count), size = 1.2, color = "grey20")

p2 <- scaleClade(p, 421, 0.1) %>%
  scaleClade(574, 0.1) %>%
  scaleClade(485, 0.1) %>%
  collapse(421, 'max', fill="tan") %>%
  collapse(574, 'max', fill="grey") %>%
  collapse(485, 'max', fill="#108454")

p
Image

p2

Image

Scaling before adding labels and data does not change this outcome. Any help on this much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant