pf.tree: ggtree-based plotting of phylofactor bins or factors

View source: R/pf.tree.R

pf.treeR Documentation

ggtree-based plotting of phylofactor bins or factors

Description

ggtree-based plotting of phylofactor bins or factors

Usage

pf.tree(pf, tree = NULL, method = "factors", factors = NULL,
  ignore.tips = TRUE, groups = NULL, colors = NULL,
  GroupList = NULL, bg.color = NA, bg.alpha = 0.1, alphas = NULL,
  layout = "circular", rootnode = FALSE, top.layer = F,
  top.alpha = 0.1, color.fcn = viridis::viridis, ...)

Arguments

pf

phylofactor class object

tree

An alternative tree on which to plot the phylogenetic factors pf$tree.

method

either "factors" or "bins", based on whether to use factors ( factors along with groups) or resultant bins (pf$bins) from phylofactorization.

factors

vector of factor numbers to be plotted

groups

vector of groups (1 or 2) to be plotted for each factor. Default is 1

colors

colors for each factors x groups pair, or each member of GroupList

GroupList

optional list of groups for plotting

bg.color

background color

bg.alpha

background alpha

alphas

vector, of length = nrow(factor.map) or length(GroupList) or, if default settings, of length pf$nfactors. Controls alphas for highlights of each clade. Warning: the current output legend gives you the colors layered onto each clade. Layering transparent colors on top of one-another will produce a different color not in the legend..

layout

See ggtree. Default is "circular"

rootnode

Logical. If true, will fill in the root node. Default controls root only with bg.color

top.layer

Logical. If true, will superimpose hilights on top of tree. If false, tree will layer on top of hilights.

top.alpha

Numeric. Alpha value for top.layer

color.fcn

Color function for plotting. Default is viridis.

...

optional arguments for ggtree

Examples

library(phylofactor)
data(FTmicrobiome)
pf <- FTmicrobiome$PF
big.tree <- FTmicrobiome$tree
tax <- FTmicrobiome$taxonomy
gg <- pf.tree(pf,factors=1:3,layout='circular')
gg$ggplot
gg$legend

## We can also focus on a universal tree
# pf.tree(pf,big.tree,factors=1:3)

## and a sub-tree
bacteroidetes <- tax$OTU_ID[grepl('p__Bacteroidetes',tax$taxonomy)] %>%
 intersect(pf$tree$tip.label)
bacteroidetes.tree <- drop.tip(big.tree,setdiff(big.tree$tip.label,bacteroidetes))
pf.tree(pf,bacteroidetes.tree,factors=setdiff(1:pf$nfactors,41))
## factor 41 contains a large, paraphyletic group that encompases all of the 
## bacteroidetes - this will color our entire tree purple.

reptalex/phylofactor documentation built on Feb. 28, 2024, 3:19 p.m.