% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make_meth_rse.R
\name{makeMethRSEFromBedgraphs}
\alias{makeMethRSEFromBedgraphs}
\title{Create a HDF5-backed RangedSummarizedExperiment for methylation values in bedGraphs}
\usage{
makeMethRSEFromBedgraphs(
  bedgraphs,
  seqnames_column = 1,
  start_column = 2,
  end_column = 3,
  value_column = 4,
  zero_based = TRUE,
  normalization_factor = NULL,
  decimal_places = NA,
  meth_sites,
  sample_metadata = NULL,
  hdf5_dir,
  dataset_name = "beta",
  overwrite = FALSE,
  chunkdim = NULL,
  temporary_dir = NULL,
  BPPARAM = BiocParallel::bpparam(),
  ...
)
}
\arguments{
\item{bedgraphs}{A vector of paths to bedGraph files. Automatically detects if bedGraphs contain a header if every field in the first line is a character.}

\item{seqnames_column}{The column number in bedgraphs which corresponds to the sequence names. Default is 1st column.}

\item{start_column}{The column number in bedgraphs which corresponds to the start positions. Default is 2nd column.}

\item{end_column}{The column number in bedgraphs which corresponds to the end positions. Default is 3rd column.}

\item{value_column}{The column number in bedgraphs which corresponds to the methylation values. Default is 4th column.}

\item{zero_based}{TRUE or FALSE indicating if files are zero-based. Default value is TRUE.}

\item{normalization_factor}{An optional numerical value to divide methylation values by to convert them to fractions e.g. 100 if they are percentages.
Default is not to leave values as they are in the input files.}

\item{decimal_places}{Optional integer indicating the number of decimal places to round beta values to. Default is not to round.}

\item{meth_sites}{A GRanges object with the locations of the methylation sites of interest. Any methylation sites in bedGraphs that are not in meth_sites are ignored.}

\item{sample_metadata}{Sample metadata to be used as colData for the RangedSummarizedExperiment.}

\item{hdf5_dir}{Directory to save HDF5 file. Is created if it doesn't exist. HDF5 file is called assays.h5.}

\item{dataset_name}{Name to give data set in HDF5 file. Default is "beta".}

\item{overwrite}{TRUE or FALSE indicating whether to allow overwriting if dataset_name already exists in assays.h5. Default is FALSE.}

\item{chunkdim}{The dimensions of the chunks for the HDF5 file. Should be a vector of length 2 giving the number of rows and then the number of columns in each chunk.
Uses HDF5Array::getHDF5DumpChunkDim(length(meth_sites), length(bedgraphs))) by default.}

\item{temporary_dir}{Name to give temporary directory created to store intermediate files. A directory with this name cannot already exist.
Default is to create a name using tempfile("temporary_meth_chunks_").
Will be deleted after completion.}

\item{BPPARAM}{A BiocParallelParam object for parallel processing. Defaults to \code{BiocParallel::bpparam()}.}

\item{...}{Additional arguments to be passed to HDF5Array::HDF5RealizationSink() for controlling the physical properties of the created HDF5 file,
such as compression level. Uses the defaults for any properties that are not specified.}
}
\value{
A RangedSummarizedExperiment with methylation values for all methylation sites in meth_sites. methylation sites will be in the same order as sort(meth_sites).
}
\description{
Create a HDF5-backed RangedSummarizedExperiment for methylation values in bedGraphs
}
\examples{

# Load CpGs within first million base pairs of chromosome 1 as a GRanges object
data("hg38_cpgs_subset", package = "methodical")

# Get paths to bedGraphs
bedgraphs <- list.files(path = system.file('extdata', package = 'methodical'), 
  pattern = ".bg.gz", full.names = TRUE)

# Create sample metadata
sample_metadata <- data.frame(
  tcga_project = gsub("_.*", "", gsub("TCGA_", "", basename(bedgraphs))),
  sample_type = ifelse(grepl("N", basename(bedgraphs)), "Normal", "Tumour"),
  row.names = tools::file_path_sans_ext(basename(bedgraphs))
)

# Create a HDF5-backed RangedSummarizedExperiment from bedGraphs
meth_rse <- makeMethRSEFromBedgraphs(bedgraphs = bedgraphs, 
  meth_sites = hg38_cpgs_subset, sample_metadata = sample_metadata, 
  hdf5_dir = paste0(tempdir(), "/bedgraph_hdf5_1"))
  
}
