splitOn | R Documentation |
TreeSummarizedExperiment
column-wise or row-wise based on grouping variableSplit TreeSummarizedExperiment
column-wise or row-wise based on grouping variable
splitOn(x, ...)
## S4 method for signature 'SummarizedExperiment'
splitOn(x, f = NULL, ...)
## S4 method for signature 'SingleCellExperiment'
splitOn(x, f = NULL, ...)
## S4 method for signature 'TreeSummarizedExperiment'
splitOn(x, f = NULL, update_rowTree = FALSE, ...)
unsplitOn(x, ...)
## S4 method for signature 'list'
unsplitOn(x, update_rowTree = FALSE, ...)
## S4 method for signature 'SimpleList'
unsplitOn(x, update_rowTree = FALSE, ...)
## S4 method for signature 'SingleCellExperiment'
unsplitOn(x, altExpNames = names(altExps(x)), keep_reducedDims = FALSE, ...)
x |
A
|
... |
Arguments passed to
|
f |
A single character value for selecting the grouping variable
from |
update_rowTree |
|
altExpNames |
a |
keep_reducedDims |
|
splitOn
split data based on grouping variable. Splitting can be done
column-wise or row-wise. The returned value is a list of
SummarizedExperiment
objects; each element containing members of each
group.
For splitOn
: SummarizedExperiment
objects in a SimpleList
.
For unsplitOn
: x
, with rowData
and assay
data replaced by the unsplit data. colData
of x is kept as well
and any existing rowTree
is dropped as well, since existing
rowLinks
are not valid anymore.
Leo Lahti and Tuomas Borman. Contact: microbiome.github.io
splitByRanks
unsplitByRanks
mergeRows
,
sumCountsAcrossFeatures
,
agglomerateByRank
,
altExps
,
splitAltExps
data(GlobalPatterns)
tse <- GlobalPatterns
# Split data based on SampleType.
se_list <- splitOn(tse, f = "SampleType")
# List of SE objects is returned.
se_list
# Create arbitrary groups
rowData(tse)$group <- sample(1:3, nrow(tse), replace = TRUE)
colData(tse)$group <- sample(1:3, ncol(tse), replace = TRUE)
# Split based on rows
# Each element is named based on their group name. If you don't want to name
# elements, use use_name = FALSE. Since "group" can be found from rowdata and colData
# you must use MARGIN.
se_list <- splitOn(tse, f = "group", use_names = FALSE, MARGIN = 1)
# When column names are shared between elements, you can store the list to altExps
altExps(tse) <- se_list
altExps(tse)
# If you want to split on columns and update rowTree, you can do
se_list <- splitOn(tse, f = colData(tse)$group, update_rowTree = TRUE)
# If you want to combine groups back together, you can use unsplitBy
unsplitOn(se_list)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.