| aggregate_samples | R Documentation |
Aggregate samples according to an aggregate function like mean, median, etc. This can be used to merge replicates.
aggregate_samples(dataset, indexes, aggreg.fn = "mean", meta.to.remove = c())
dataset |
List representing the dataset from a metabolomics experiment. |
indexes |
Index vector with the samples that are going to be aggregated (e.g. c(1,1,2,2), this index vector will aggregate the first two samples and the last two samples). |
aggreg.fn |
Aggregation function (e.g. "mean", "median", etc). |
meta.to.remove |
Metadata variables to be removed. |
A dataset object in which samples have been aggregated according to 'indexes' and 'aggreg.fn', with updated 'data', 'metadata', and preserved dataset-level fields such as labels, type, and description.
data <- matrix(
c(1, 2, 10, 12,
3, 4, 14, 16),
nrow = 2,
dimnames = list(c("x1", "x2"), c("s1", "s2", "s3", "s4"))
)
metadata <- data.frame(
class = factor(c("A", "A", "B", "B")),
batch = c(1, 1, 2, 2),
row.names = c("s1", "s2", "s3", "s4")
)
dataset <- list(
data = data,
metadata = metadata,
labels = list(),
type = "example",
description = "toy dataset"
)
aggregate_samples(dataset, c(1, 1, 2, 2), "mean")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.