groupFeatures-similar-abundance | R Documentation |
Group features based on similar abundances (i.e. feature values) across
samples. Parameter subset
allows to define a sub set of samples on which
the similarity calculation should be performed. It might for example be
better to exclude QC samples from the analysis because feature values are
supposed to be constant in these samples.
The function first calculates a nxn similarity matrix with n being the
number of features and subsequently groups features for which the similarity
is higher than the user provided threshold. Parameter simFun
allows
to specify the function to calculate the pairwise similarities on the feature
values (eventually transformed by the function specified with parameter
transform
). simFun
defaults to a function that uses cor
to calculate
similarities between rows in object
but any function that calculates
similarities between rows and that returns a (symmetric) numeric similarity
matrix can be used.
If object
is a SummarizedExperiment()
: if a column "feature_group"
is
found in SummarizedExperiment::colData()
feature groups defined in that
column are further sub-grouped with this method. See groupFeatures()
for
the general concept of this feature grouping.
Parameter groupFun
allows to specify the function to group the features
based on the similarity function. It defaults to groupSimilarityMatrix
. See
groupSimilarityMatrix()
for details.
Additional settings for the groupFun
and simFun
functions can be passed
to the parameter object with the ...
in the AbundanceSimilarityParam
constructor function. Other additional parameters specific for the type
of object
can be passed via ...
in the groupFeatures
call.
AbundanceSimilarityParam(
threshold = 0.9,
simFun = corRows,
groupFun = groupSimilarityMatrix,
subset = integer(),
transform = identity,
...
)
## S4 method for signature 'matrix,AbundanceSimilarityParam'
groupFeatures(object, param, ...)
## S4 method for signature 'SummarizedExperiment,AbundanceSimilarityParam'
groupFeatures(object, param, i = 1L, ...)
threshold |
|
simFun |
|
groupFun |
|
subset |
|
transform |
|
... |
for |
object |
object containing the feature abundances on which features should be grouped. |
param |
|
i |
for |
for object being a SummarizedExperiment
: a SummarizedExperiment
with the grouping results added to a column "feature_group"
in the
object's rowData
. For object being a matrix
: an integer
of length
equal to the number of rows with the group identifiers.
Johannes Rainer
groupFeatures()
for the general concept of feature grouping.
featureGroups()
for the function to extract defined feature
groups from a SummarizedExperiment
.
Other feature grouping methods:
groupFeatures-similar-rtime
## Define a simple numeric matrix on which we want to group the rows
x <- rbind(
c(12, 34, 231, 234, 9, 5, 7),
c(900, 900, 800, 10, 12, 9, 4),
c(25, 70, 400, 409, 15, 8, 4),
c(12, 13, 14, 15, 16, 17, 18),
c(14, 36, 240, 239, 12, 7, 8),
c(100, 103, 80, 2, 3, 1, 1)
)
## Group rows based on similarity calculated with Pearson's correlation
## on the actual data values (without transforming them).
res <- groupFeatures(x, AbundanceSimilarityParam())
res
## Use Spearman's rho to correlate rows of the log2 transformed x matrix
res <- groupFeatures(x, AbundanceSimilarityParam(method = "spearman",
transform = log2))
res
## Perform the grouping on a SummarizedExperiment
library(SummarizedExperiment)
data(se)
## Group features based on log2 transformed feature values in the first
## assay of the SummarizedExperiment
res <- groupFeatures(se, param = AbundanceSimilarityParam(threshold = 0.7,
transform = log2))
featureGroups(res)
## Perform feature grouping only on a subset of rows/features:
featureGroups(res) <- NA_character_
featureGroups(res)[40:80] <- "FG"
res <- groupFeatures(res, AbundanceSimilarityParam(transform = log2))
featureGroups(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.