Convenience wrapper around getDataTable() to extract beta values (fraction methylated). Returns a window × sample (or group) table for downstream summaries/plots.

getBetaTable(
  qseaSet,
  useGroupMeans = FALSE,
  minEnrichment = 3,
  addMethodSuffix = FALSE,
  verbose = TRUE
)

Arguments

qseaSet

qseaSet. A qseaSet object containing methylation-enriched sequencing data. Default: none (must be supplied).

useGroupMeans

logical(1). If TRUE, average replicates by the group column in the sample table and return group means; if FALSE, return per-sample betas. Default: FALSE.

minEnrichment

integer(1). Minimum reads per window required for a non-NA beta (below this threshold, qsea sets beta to NA). Default: 3.

addMethodSuffix

logical(1). If TRUE, keep the method suffix in column names (e.g., Sample1_beta or Group_beta_means); if FALSE, return bare sample/group names. Default: FALSE.

verbose

logical(1). Print progress/messages. Default: TRUE.

Value

A tibble/data.frame with one row per genomic window and columns for each sample (or group), plus any window metadata included by getDataTable().

Examples

data(exampleTumourNormal, package = "mesa")

# Per-sample beta (first rows/columns), with a minimum read threshold
exampleTumourNormal %>%
  getBetaTable(minEnrichment = 3) %>%
  dplyr::select(1:6) %>%
  head()
#> Generating table of beta 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  NA        0.347 
#> 2 7        25005001 25005300       13.4    0.0565   0.0171
#> 3 7        25008601 25008900        5.57  NA        0.204 
#> 4 7        25011301 25011600        5.10  NA        0.382 
#> 5 7        25017601 25017900        8.38   0.122    0.0695
#> 6 7        25017901 25018200       17.9    0.0240   0.0660

# Group means instead of individual samples
exampleTumourNormal %>%
  getBetaTable(useGroupMeans = TRUE, minEnrichment = 3) %>%
  dplyr::select(1:6) %>%
  head()
#> Generating table of beta 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 NaN        0.347 
#> 2 7        25005001 25005300       13.4    0.0565   0.0171
#> 3 7        25008601 25008900        5.57 NaN        0.204 
#> 4 7        25011301 25011600        5.10 NaN        0.382 
#> 5 7        25017601 25017900        8.38   0.122    0.0695
#> 6 7        25017901 25018200       17.9    0.0240   0.0660

# Keep the method suffix in column names
exampleTumourNormal %>%
  getBetaTable(addMethodSuffix = TRUE) %>%
  names() %>%
  head()
#> Generating table of beta values for 819 regions across 10 samples.
#> [1] "seqnames"      "start"         "end"           "CpG_density"  
#> [5] "Colon1_N_beta" "Colon1_T_beta"

# Inspect how many NAs arise from the minEnrichment filter
exampleTumourNormal %>%
  getBetaTable(minEnrichment = 5) %>%
  dplyr::select(dplyr::where(is.numeric)) %>%
  is.na() %>%
  colSums() %>%
  head()
#> Generating table of beta values for 819 regions across 10 samples.
#>       start         end CpG_density    Colon1_N    Colon1_T    Colon2_N 
#>           0           0           0         376         179         351