tanggle
Workflows
Standard Workflow
Visualize unrooted, undirected split networks (such as consensus networks or neighbor-nets) from Nexus files.
library(tanggle)
library(phangorn)
library(ggtree)
fdir <- system.file("extdata/trees", package = "phangorn")
Nnet <- phangorn::read.nexus.networx(file.path(fdir,"woodmouse.nxs"))
p <- ggsplitnet(Nnet) + geom_tiplab2()
p <- p + xlim(-0.019, .003) + ylim(-.01, .012)
Input: A Nexus file containing split network data, read as a networx object; Output: A ggplot object representing the unrooted split network with tip labels.
Explicit Networks
Visualize explicit, rooted phylogenetic networks with reticulations from extended Newick format.
library(tanggle)
library(ape)
z <- read.evonet(text = "((1,((2,(3,(4)Y#H1)g)e,(((Y#H1,5)h,6)f)X#H2)c)a, ((X#H2,7)d,8)b)r;")
p <- ggevonet(z, layout = "slanted") + geom_tiplab() + geom_nodelab()
Input: An extended Newick format string; Output: A ggplot object representing a rooted phylogenetic network with reticulations.
When to Use
- Visualizing unrooted, undirected split networks (consensus networks or neighbor-nets) using
ggsplitnet.
- Visualizing explicit, rooted phylogenetic networks with reticulations using
ggevonet.
- Customizing phylogenetic network plots with
ggplot2 layers such as geom_tiplab2 and geom_nodepoint.
When NOT to Use
- For standard, non-reticulated phylogenetic trees, use
ggtree directly as it is optimized for simple tree structures.
- For plotting networks without a phylogenetic context (e.g., protein-protein interaction networks), use
ggraph or igraph.
Data Requirements
- Split networks must be represented as a
networx object, typically read via phangorn::read.nexus.networx.
- Explicit networks must be represented as an
evonet object, typically read via ape::read.evonet.
Key Parameters
- layout ("rectangular"): Layout style for explicit networks in
ggevonet (can be "rectangular" or "slanted").
- col ("blue"): Color parameter inside
geom_tiplab2 or geom_nodepoint to customize labels and nodes.
- font (4): Font style parameter in
geom_tiplab2.
- hjust (-0.15): Horizontal adjustment for tip labels in
geom_tiplab2.
Best Practices
- Adjust plot limits using
xlim and ylim to ensure long tip labels are fully visible and readable.
- Use
geom_tiplab2 for split networks to properly align labels along the network perimeter.
- Minimize reticulation line crossings in complex explicit networks using
minimize_overlap.
Common Pitfalls
- Truncated tip labels: Labels extending beyond the default plot margins. Fix by adding
xlim and ylim limits to the ggplot object.
- Overlapping reticulation lines: Hard-to-read explicit networks. Fix by applying
minimize_overlap to the network object before plotting.
Alternatives
ape: For basic plotting of evonet objects without ggplot2 syntax.
phangorn: For basic plotting of networx split networks without ggplot2 integration.
Citations
- Yu, Guangchuang, David Smith, Huachen Zhu, Yi Guan, and Tommy Tsan-Yuk Lam. 2017. "Ggtree: An R Package for Visualization and Annotation of Phylogenetic Trees with Their Covariates and Other Associated Data." Methods in Ecology and Evolution 8 (1): 28–36.
- Cardona, Gabriel, Francesc Rosselló, and Gabriel Valiente. 2008. "Extended Newick: It Is Time for a Standard Representation of Phylogenetic Networks." BMC Bioinformatics 9 (1): 532.
References
1---2name: tanggle3description: tanggle4---56# tanggle78## Workflows910### Standard Workflow1112Visualize unrooted, undirected split networks (such as consensus networks or neighbor-nets) from Nexus files.1314```r15library(tanggle)16library(phangorn)17library(ggtree)1819fdir <- system.file("extdata/trees", package = "phangorn")20Nnet <- phangorn::read.nexus.networx(file.path(fdir,"woodmouse.nxs"))2122p <- ggsplitnet(Nnet) + geom_tiplab2()23p <- p + xlim(-0.019, .003) + ylim(-.01, .012)24```25*Input: A Nexus file containing split network data, read as a networx object; Output: A ggplot object representing the unrooted split network with tip labels.*2627### Explicit Networks2829Visualize explicit, rooted phylogenetic networks with reticulations from extended Newick format.3031```r32library(tanggle)33library(ape)3435z <- read.evonet(text = "((1,((2,(3,(4)Y#H1)g)e,(((Y#H1,5)h,6)f)X#H2)c)a, ((X#H2,7)d,8)b)r;")36p <- ggevonet(z, layout = "slanted") + geom_tiplab() + geom_nodelab()37```38*Input: An extended Newick format string; Output: A ggplot object representing a rooted phylogenetic network with reticulations.*3940## When to Use41- Visualizing unrooted, undirected split networks (consensus networks or neighbor-nets) using `ggsplitnet`.42- Visualizing explicit, rooted phylogenetic networks with reticulations using `ggevonet`.43- Customizing phylogenetic network plots with `ggplot2` layers such as `geom_tiplab2` and `geom_nodepoint`.4445## When NOT to Use46- For standard, non-reticulated phylogenetic trees, use `ggtree` directly as it is optimized for simple tree structures.47- For plotting networks without a phylogenetic context (e.g., protein-protein interaction networks), use `ggraph` or `igraph`.4849## Data Requirements50- Split networks must be represented as a `networx` object, typically read via `phangorn::read.nexus.networx`.51- Explicit networks must be represented as an `evonet` object, typically read via `ape::read.evonet`.5253## Key Parameters54- **layout** ("rectangular"): Layout style for explicit networks in `ggevonet` (can be `"rectangular"` or `"slanted"`).55- **col** ("blue"): Color parameter inside `geom_tiplab2` or `geom_nodepoint` to customize labels and nodes.56- **font** (4): Font style parameter in `geom_tiplab2`.57- **hjust** (-0.15): Horizontal adjustment for tip labels in `geom_tiplab2`.5859## Best Practices60- Adjust plot limits using `xlim` and `ylim` to ensure long tip labels are fully visible and readable.61- Use `geom_tiplab2` for split networks to properly align labels along the network perimeter.62- Minimize reticulation line crossings in complex explicit networks using `minimize_overlap`.6364## Common Pitfalls65- Truncated tip labels: Labels extending beyond the default plot margins. Fix by adding `xlim` and `ylim` limits to the ggplot object.66- Overlapping reticulation lines: Hard-to-read explicit networks. Fix by applying `minimize_overlap` to the network object before plotting.6768## Alternatives69- `ape`: For basic plotting of `evonet` objects without `ggplot2` syntax.70- `phangorn`: For basic plotting of `networx` split networks without `ggplot2` integration.7172## Citations73- Yu, Guangchuang, David Smith, Huachen Zhu, Yi Guan, and Tommy Tsan-Yuk Lam. 2017. "Ggtree: An R Package for Visualization and Annotation of Phylogenetic Trees with Their Covariates and Other Associated Data." Methods in Ecology and Evolution 8 (1): 28–36.74- Cardona, Gabriel, Francesc Rosselló, and Gabriel Valiente. 2008. "Extended Newick: It Is Time for a Standard Representation of Phylogenetic Networks." BMC Bioinformatics 9 (1): 532.7576## References77- Homepage: bioconductor.org/packages/tanggle78- Vignette: https://bioconductor.org/packages/release/bioc/vignettes/tanggle/inst/doc/tanggle.html