selNode | R Documentation |
Select branches in a tree meeting the specified criteria in terms of number of leaves and the count proportion. Note that only internal branch nodes are considered - no individual leaves will be returned.
selNode(
pr = NULL,
obj = NULL,
assay = 1,
data = NULL,
tree = NULL,
minTip = 0,
maxTip = Inf,
minPr = 0,
maxPr = 1,
skip = NULL,
all = FALSE
)
pr |
A named numeric vector to provide proportions of entities. If
this is provided, |
obj |
A |
assay |
The index or name of the assay of |
data |
Either a count table with entities in rows and samples in
columns, or a list with |
tree |
A |
minTip |
the minimum number of leaves in the selected branch. |
maxTip |
The maximum number of leaves in the selected branch. |
minPr |
The minimum count proportion of the selected branch in a sample. A value between 0 and 1. |
maxPr |
The maximum count proportion of the selected branch in a sample. A value between 0 and 1. |
skip |
A character vector of node labels. These nodes can not be descendants or the ancestors of the selected branch. |
all |
A logical scalar. If |
A data.frame
with node information for the selected
internal node(s).
Ruizhu Huang, Charlotte Soneson
suppressPackageStartupMessages({
library(TreeSummarizedExperiment)
})
## Generate example data
set.seed(1)
data(tinyTree)
toyTable <- matrix(rnbinom(40, size = 1, mu = 10), nrow = 10)
colnames(toyTable) <- paste(rep(LETTERS[seq_len(2)], each = 2),
rep(seq_len(2), 2), sep = "_")
rownames(toyTable) <- tinyTree$tip.label
## Estimate entity proportions from count matrix under a Dirichlet
## Multinomial framework, and use this as the input for selNode
dat <- parEstimate(obj = toyTable)
selNode(tree = tinyTree, data = dat, all = TRUE)
selNode(tree = tinyTree, data = dat,
minTip = 4, maxTip = 9, minPr = 0, maxPr = 0.8, all = TRUE)
## Alternatively, directly provide the proportions vector
selNode(tree = tinyTree, pr = dat$pi, all = TRUE)
## Return only branch with lowest proportion among valid ones
selNode(tree = tinyTree, pr = dat$pi, all = FALSE)
## Start instead from a TreeSummarizedExperiment object
lse <- TreeSummarizedExperiment(rowTree = tinyTree,
assays = list(counts = toyTable))
selNode(obj = lse, assay = "counts", all = TRUE)
## Don't allow node 1 to be included
selNode(obj = lse, assay = "counts", skip = 1, all = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.