Build a per-window table for one or more normalisation methods, returning values per sample or group means.
getDataTable(x, ...)
# S4 method for class 'ANY'
getDataTable(
x,
normMethod = "nrpm",
useGroupMeans = FALSE,
minEnrichment = 3,
addMethodSuffix = FALSE,
verbose = TRUE
)
# S4 method for class 'mesaDimRed'
getDataTable(x, ...)qseaSet or mesaDimRed.
A qseaSet object containing methylation-enriched sequencing data, or a
mesaDimRed object.
Default: none (must be supplied).
Passed to methods. Not used by the mesaDimRed method.
character().
One or more of "counts", "nrpm", "beta".
Default: "nrpm".
logical(1).
If TRUE, average replicates by the group column and return group means;
if FALSE, return per-sample values.
Default: FALSE.
integer(1).
Minimum reads per window required for a non-NA beta (applies only when
normMethod includes "beta").
Default: 3.
logical(1).
Keep a method suffix in column names (e.g., Sample1_nrpm,
Group_beta_means). If multiple methods are requested, suffixes are kept
regardless to avoid collisions.
Default: FALSE.
logical(1).
Print progress/messages.
Default: TRUE.
A tibble/data.frame with one row per genomic window and one column per
sample (or group), plus window metadata columns. For a mesaDimRed,
a data.frame with windows in rows and samples in columns, or an empty
data.frame if the data was not stored.
The result is a window × sample (or group) table. Window coordinates and
any available region metadata (e.g., seqnames, start, end, densities)
are kept alongside the requested measures. Column naming: when a single
method is requested and addMethodSuffix = FALSE, columns are bare sample /
group names; otherwise a _{method} (and for group means _{method}_means)
suffix is appended.
For "beta", windows with reads < minEnrichment are set to NA before
aggregation. Use removeNormMethodSuffix() afterwards if you want to strip
method tags in wide tables.
If x is a mesaDimRed object (returned by getDimRed(),
getPCA() or getUMAP()), the input data used to compute the results is
returned, provided it was stored when the dimensionality reduction was
performed by setting returnDataTable = TRUE. The other arguments are
ignored.
data(exampleTumourNormal, package = "mesa")
# Default: NRPM per window (first few columns)
exampleTumourNormal %>%
getDataTable() %>%
dplyr::select(1:6) %>%
head()
#> Generating table of nrpm values for 819 regions across 10 samples.
#> # A tibble: 6 × 6
#> seqnames start end CpG_density Colon1_N Colon1_T
#> <fct> <int> <int> <dbl> <dbl> <dbl>
#> 1 7 25002001 25002300 5.51 0 0.131
#> 2 7 25005001 25005300 13.4 0.263 0
#> 3 7 25008601 25008900 5.57 0 0
#> 4 7 25011301 25011600 5.10 0 0.131
#> 5 7 25017601 25017900 8.38 0 0
#> 6 7 25017901 25018200 17.9 0 0.523
# Multiple methods together (suffixes retained automatically)
exampleTumourNormal %>%
getDataTable(normMethod = c("nrpm","beta"), minEnrichment = 3) %>%
dplyr::select(1:8) %>%
head()
#> Generating table of nrpm values for 819 regions across 10 samples.Generating table of beta values for 819 regions across 10 samples.
#> # A tibble: 6 × 8
#> seqnames start end CpG_density Colon1_N_nrpm Colon1_T_nrpm Colon2_N_nrpm
#> <fct> <int> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 7 25002001 2.50e7 5.51 0 0.131 0.246
#> 2 7 25005001 2.50e7 13.4 0.263 0 0
#> 3 7 25008601 2.50e7 5.57 0 0 0
#> 4 7 25011301 2.50e7 5.10 0 0.131 0
#> 5 7 25017601 2.50e7 8.38 0 0 4.42
#> 6 7 25017901 2.50e7 17.9 0 0.523 2.70
#> # ℹ 1 more variable: Colon2_T_nrpm <dbl>
# Group means instead of individual samples
exampleTumourNormal %>%
getDataTable(useGroupMeans = TRUE, normMethod = "nrpm") %>%
dplyr::select(1:6) %>%
head()
#> Generating table of nrpm values for 819 regions across 10 sample groups.
#> # A tibble: 6 × 6
#> seqnames start end CpG_density Colon1_N Colon1_T
#> <fct> <int> <int> <dbl> <dbl> <dbl>
#> 1 7 25002001 25002300 5.51 0 0.131
#> 2 7 25005001 25005300 13.4 0.263 0
#> 3 7 25008601 25008900 5.57 0 0
#> 4 7 25011301 25011600 5.10 0 0.131
#> 5 7 25017601 25017900 8.38 0 0
#> 6 7 25017901 25018200 17.9 0 0.523
# Keep (or later remove) the method suffix
exampleTumourNormal %>%
getDataTable(normMethod = "nrpm", addMethodSuffix = TRUE) %>%
names() %>%
head()
#> Generating table of nrpm values for 819 regions across 10 samples.
#> [1] "seqnames" "start" "end" "CpG_density"
#> [5] "Colon1_N_nrpm" "Colon1_T_nrpm"
# The data a PCA was computed from, when kept with returnDataTable = TRUE
exampleTumourNormal %>%
getPCA(topVarNum = 100, returnDataTable = TRUE, verbose = FALSE) %>%
getDataTable() %>%
dplyr::select(1:4) %>%
head()
#> Generating table of beta values for 819 regions across 10 samples.
#> # A tibble: 6 × 4
#> seqnames start end CpG_density
#> <fct> <int> <int> <dbl>
#> 1 7 25005001 25005300 13.4
#> 2 7 25017601 25017900 8.38
#> 3 7 25017901 25018200 17.9
#> 4 7 25018201 25018500 16.5
#> 5 7 25018501 25018800 17.5
#> 6 7 25018801 25019100 15.3