Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/name_balances.R
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.
1 2 | 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
1 2 3 4 5 6 7 8 9 | 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'))
|
Registered S3 method overwritten by 'treeio':
method from
root.phylo ape
[1] "Kingdom_A/Phylum_C"
[1] "Phylum_C/Genus_H"
$name
[1] "Phylum_C/Genus_H"
$up.votes
$up.votes$Genus
votes
G H
2 3
$up.votes$Phylum
votes
C
5
$up.votes$Kingdom
votes
A
5
$down.votes
$down.votes$Genus
votes
H
2
$down.votes$Phylum
votes
C
2
$down.votes$Kingdom
votes
A
2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.