Read the contents of mesaDimRed, mesaPCA and
mesaUMAP objects, as returned by getPCA() and getUMAP().
# S4 method for class 'mesaDimRed'
getSampleTable(object)
# S4 method for class 'mesaDimRed'
getSampleNames(object)
getResults(object, ...)
# S4 method for class 'mesaDimRed'
getResults(object)
# S4 method for class 'mesaDimRed'
getParameters(object)
getCoordinates(object, ...)
# S4 method for class 'mesaPCA'
getCoordinates(object)
# S4 method for class 'mesaUMAP'
getCoordinates(object)
# S4 method for class 'mesaPCA'
getSampleNames(object)
# S4 method for class 'mesaUMAP'
getSampleNames(object)
# S4 method for class 'mesaDimRed'
getCoordinates(object)
getPrcomp(object, ...)
# S4 method for class 'mesaPCA'
getPrcomp(object)
# S4 method for class 'mesaDimRed'
getPrcomp(object)
# S4 method for class 'mesaDimRed'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)A mesaDimRed object, or a mesaPCA or mesaUMAP object where stated.
Not used.
A mesaDimRed object.
Not used.
getResults(): a named list of mesaPCA or mesaUMAP
objects, one per result (e.g. per topVarNum value); empty when there
are no results.
getSampleTable(): the sample annotations, a data.frame with the
sample IDs in its sample_name column.
getSampleNames(): the sample IDs the results cover, or character()
when there are no results; also works on a mesaPCA or
mesaUMAP, giving its sample IDs. With useGroupMeans = TRUE they are sample
group names.
getParameters(): the list of parameters used to compute the results,
including method ("PCA" or "UMAP").
getDataTable(): if returnDataTable = TRUE, the input data used to
compute the results, as a data.frame with windows in rows and samples
in columns; otherwise, an empty data.frame.
getCoordinates(): for a mesaPCA, its principal component
scores (prcomp$x); for a mesaUMAP, its UMAP coordinates. Each
is a data.frame with one row per sample and sample IDs as row names.
For a mesaDimRed, a named list of these, one per result.
getPrcomp(): the stats::prcomp() fit of a mesaPCA. For a
mesaDimRed of PCA results, a named list of these, one per
result; an error for UMAP results.
getWindowNames(): the window IDs a result was computed over. For a
mesaDimRed, a named list of these, one per result.
as.data.frame(): one data.frame with a row per result and sample:
resName (the result's name, as in getResults()), sample_name, the
coordinate columns (PC1, PC2, ... or UMAP1, UMAP2), then the
sampleTable columns. With useGroupMeans = TRUE the ID column is
group and no sample annotations are added.
data(exampleTumourNormal, package = "mesa")
pca <- getPCA(exampleTumourNormal, topVarNum = c(100, 500),
verbose = FALSE)
#> Generating table of beta values for 819 regions across 10 samples.
names(getResults(pca))
#> [1] "pca1" "pca2"
head(getSampleTable(pca))
#> sample_name group patient type tumour tissue age gender
#> Colon1_N Colon1_N Colon1_N Colon1 NormalColon Normal Colon 80 F
#> Colon1_T Colon1_T Colon1_T Colon1 CRC Tumour Colon 80 F
#> Colon2_N Colon2_N Colon2_N Colon2 NormalColon Normal Colon 67 F
#> Colon2_T Colon2_T Colon2_T Colon2 CRC Tumour Colon 67 F
#> Lung1_N Lung1_N Lung1_N Lung1 NormalLung Normal Lung 64 F
#> Lung1_T Lung1_T Lung1_T Lung1 LUAD Tumour Lung 64 F
#> stage
#> Colon1_N <NA>
#> Colon1_T III
#> Colon2_N <NA>
#> Colon2_T IV
#> Lung1_N <NA>
#> Lung1_T IIA
getSampleNames(pca)
#> [1] "Colon1_N" "Colon1_T" "Colon2_N" "Colon2_T" "Lung1_N" "Lung1_T"
#> [7] "Lung2_N" "Lung2_T" "Lung3_N" "Lung3_T"
getParameters(pca)$method
#> [1] "PCA"
first <- getResults(pca)[[1]]
head(getCoordinates(first))
#> PC1 PC2 PC3 PC4 PC5
#> Colon1_N -1.5548660 1.44750438 0.94467418 0.97768551 0.15374220
#> Colon1_T -2.6914778 0.34334463 -1.58832065 0.06878159 -0.11682077
#> Colon2_N 0.3780406 0.43242959 -0.08074868 -0.06182247 -1.39952095
#> Colon2_T -0.9233616 0.44363244 1.51991730 -1.35115706 0.20034742
#> Lung1_N 1.5101990 0.01393992 -0.28749699 0.38421605 -0.09776136
#> Lung1_T 0.7346282 -0.22198374 -0.72104166 -1.41025272 -0.02523040
summary(getPrcomp(first))$importance[, 1:3]
#> PC1 PC2 PC3
#> Standard deviation 1.446439 1.168279 0.880966
#> Proportion of Variance 0.337400 0.220110 0.125160
#> Cumulative Proportion 0.337400 0.557510 0.682670
# Coordinates of every result at once
lapply(getCoordinates(pca), dim)
#> $pca1
#> [1] 10 5
#>
#> $pca2
#> [1] 10 5
#>
# Everything in one table, e.g. for a custom plot
head(as.data.frame(pca)[, 1:6])
#> resName sample_name PC1 PC2 PC3 PC4
#> 1 pca1 Colon1_N -1.5548660 1.44750438 0.94467418 0.97768551
#> 2 pca1 Colon1_T -2.6914778 0.34334463 -1.58832065 0.06878159
#> 3 pca1 Colon2_N 0.3780406 0.43242959 -0.08074868 -0.06182247
#> 4 pca1 Colon2_T -0.9233616 0.44363244 1.51991730 -1.35115706
#> 5 pca1 Lung1_N 1.5101990 0.01393992 -0.28749699 0.38421605
#> 6 pca1 Lung1_T 0.7346282 -0.22198374 -0.72104166 -1.41025272