Skip to contents

Create a new BetaHandler object that manages methylation beta values from various input formats (files, matrices, tabix, BSseq objects) with memory-efficient access patterns.

Usage

getBetaHandler(
  beta,
  array = c("450K", "27K", "EPIC", "EPICv2"),
  genome = c("hg38", "hg19", "hs1", "mm10", "mm39"),
  beta_row_names_file = NULL,
  sorted_locs = NULL,
  chrom_col = "#chrom",
  start_col = "start",
  output_prefix = NULL,
  njobs = getOption("CMEnt.njobs", .defaultNJobs())
)

Arguments

beta

Path to beta values file, or a tabix, or a beta matrix, or a BSseq object

array

Array platform type, ignored if sorted_locs or a BSseq object have been provided

genome

Reference genome version, eg. hg38 or hs1. Only human and mouse genomes are supported. Ignored if sorted_locs or a BSseq object have been provided.

beta_row_names_file

Path to row names file

sorted_locs

Data frame with genomic locations containing 'chr' and 'start' and 'end' columns, sorted by genomic position. If NULL, will be retrieved automatically using genome and array information, or extracted from BSseq object.

chrom_col

Chromosome column name in tabix file

start_col

Start position column name in tabix file

output_prefix

Prefix used for saving derived beta artifacts.

njobs

Number of parallel jobs to use when reading beta file or tabix file. Default is number of available cores minus one, up to a maximum of 8.

Value

A new BetaHandler object

Examples

loadExampleInputData("beta")
beta_matrix <- beta

beta_handler <- getBetaHandler(
    beta = beta_matrix,
    array = "450K",
    genome = "hg38"
)

beta_locs <- beta_handler$getBetaLocs()
head(beta_locs)

beta_values <- beta_handler$getBeta()
head(beta_values[, 1:5])