geom_range(): How can I remove some segments from plot

165 views
Skip to first unread message

Marco

unread,
Mar 14, 2019, 10:58:09 AM3/14/19
to ggtree
Given this example from here.


The code plots a tree with ranges on nodes and tips. It is clear to me that the data for plotting the ranges is stored in beast@data. However, I would like to remove some segments on the plot (e.g. tip ranges), It seemed straightforward to me that I could just apply a filter on this tibble and then plot this again. E.g.

beast@data <- beast@data %>% filter(node != "1") # to remove segment on node 1

When I then run:

ggtree(beast, aes(color=rate))  +
    geom_range(range='length_0.95_HPD', color='red', alpha=.6, size=2) +
    geom_nodelab(aes(x=branch, label=round(posterior, 2)), vjust=-.5, size=3) +
    scale_color_continuous(low="darkgreen", high="red") +
    theme(legend.position=c(.1, .8))

I get the error: 

Error in is.finite(x) : default method not implemented for type 'list'

I have two questions:

1) Why can I not manipulate the beast@data tibble without producing an error? Did I miss some dependencies?
2) How can I in the example above only plot the ranges on nodes, but not at the tips?

Any help would be highly appreciated.

Many Thanks,
Marco

lichenhao.sg

unread,
Mar 14, 2019, 12:53:42 PM3/14/19
to ggtree
Something like this?

library(treeio)
beast@data[isTip(beast, beast@data$node),]$length_0.95_HPD <- NA


Yu, Guangchuang

unread,
Apr 27, 2019, 4:08:42 AM4/27/19
to Marco, ggtree
your code should work in next release (bioconductor 3.9).

--
1. G Yu*, TTY Lam, H Zhu, Y Guan*. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution, 2018, 35(2):3041-3043. doi: 10.1093/molbev/msy194
2. G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
3. Book: https://yulab-smu.github.io/treedata-book/
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree...@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
Visit this group at https://groups.google.com/group/bioc-ggtree.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/59b09b31-3e52-448a-89be-5cffb05a7ad9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
--~--~---------~--~----~------------~-------~--~----~
Guangchuang Yu PhD
Professor
School of Basic Medical Sciences
Southern Medical University
Guangzhou, China
-~----------~----~----~----~------~----~------~--~---
Reply all
Reply to author
Forward
0 new messages