Aggregates one or more dimensionality reduction results (e.g., PCA/UMAP) computed on a common set of samples.
mesaDimRed(res, sampleTable, params, dataTable = data.frame())
# S4 method for class 'mesaDimRed'
show(object)list
Dimensionality reduction result objects. Default: none. res must
be supplied.
data.frame
Sample annotations, with the sample IDs in a sample_name column.
Default: none.
list
Parameters used to compute res. Default: none.
data.frame
Optional numeric matrix/data used for the dimensionality reduction.
Default: data.frame().
mesaDimRed
A mesaDimRed object:
stores dimensionality reduction results in res,
carries sample metadata in sampleTable,
and persists parameters/data in params / dataTable.
A valid object has res empty, or:
res is a named list with unique names;
its elements are all mesaPCA or all
mesaUMAP objects, matching params$method if set;
every element covers the same sample IDs, in the same order, with no duplicates;
each sample ID is a value of sampleTable$sample_name (of
sampleTable$group when params$useGroupMeans is TRUE);
each sample ID is a column of dataTable, when it has columns.
reslist
Individual dimensionality reduction result objects (e.g.,
mesaPCA, mesaUMAP).
The sample IDs of the results are the row names of each element of
res (prcomp$x for mesaPCA,
points for mesaUMAP). With
useGroupMeans = TRUE they are sample group names.
sampleTabledata.frame
Sample annotations; the sample_name column holds the sample IDs
(the row names mirror it, as in a qseaSet).
paramslist
Parameters used to generate results in res.
dataTabledata.frame
Optional matrix/data used to compute the dimensionality reduction (for
reproducibility).
Read the slots with these functions rather than @:
getResults(): the list of results (res);
getSampleTable() and getSampleNames(): the sample annotations and the
sample IDs the results cover;
getParameters(): the parameters (params);
getDataTable(): the data used to compute the results (dataTable);
getCoordinates() and getWindowNames(): per-result coordinates and
window IDs, as named lists;
as.data.frame(): the coordinates of every result in one long table, with the sample annotations.
set.seed(1)
x <- matrix(rnorm(20), nrow = 5, ncol = 4,
dimnames = list(paste0("S", 1:5), paste0("W", 1:4)))
st <- data.frame(sample_name = rownames(x),
group = rep(c("A", "B"), c(3, 2)), row.names = rownames(x))
mp <- mesaPCA(prcomp = stats::prcomp(x), windows = colnames(x))
md <- mesaDimRed(res = list(pca1 = mp), sampleTable = st,
params = list(method = "PCA"))
md
#> Object containing 1 dimensionality reduction objects for 5 samples
getSampleNames(md)
#> [1] "S1" "S2" "S3" "S4" "S5"