View source: R/name_balances.R
name.balance | R Documentation |
For a given ILR balance (coordinate) assigns a name to the balance based on a provided taxonomy table. This is useful for interpretation of the balances.
name.balance(
tr,
tax,
coord,
method = "voting",
thresh = 0.95,
return.votes = NULL
)
tr |
an object of class |
tax |
a matrix/data.frame of taxonomy, rownames should correspond to
|
coord |
the name of a balance/internal node on the tree (given as a string) |
method |
currently only |
thresh |
threshold for assignment of taxonomy to a given part of a
balance (must be greater than 0.5 if |
return.votes |
whether voting results by taxonomic level should be
shown for
|
A bit of terminology:
this is the same as the names of the balances which should be
the same as the names of the internal nodes of tr
this is the child node of coord
that is represented in
the numerator of the coord
balance.
this is the child node of coord
that is represented in
the denominator of the coord
balance
The method 'voting'
assigns the name of the each part of a balance
(e.g., numerator and denominator / each child of coord
) as follows:
First Subset tax
to contain only descendent tips of the given
child of coord
Second At the finest taxonomic (farthest right of tax
) see if
any one taxonomic label is present at or above thresh
. If yes output
that taxonomic label (at that taxonomic level) as the label for that child
of coord
. If no then move to coarser taxonomic level (leftward) and
repeat.
If return.votes=NULL
returns a string of the form
(ex. 'Genus_Bacteroides/Phylum_Firmicutes'). Otherwise returns
a list with the above string as 'name', see Arguments for show.votes
for other optional returned items.
Justin Silverman
philr
tr <- named_rtree(40)
tax <- data.frame(Kingdom=rep('A', 40),
Phylum=rep(c('B','C'), each=20),
Genus=c(sample(c('D','F'),20, replace=TRUE),
sample(c('G','H'), 20, replace=TRUE)))
rownames(tax) <- tr$tip.label
name.balance(tr, tax, 'n1')
name.balance(tr, tax, 'n34')
name.balance(tr,tax, 'n34', return.votes = c('up', 'down'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.