getRegionMeth: Get Region Methylation Data

View source: R/Examine_Region_Methylation.R

getRegionMethR Documentation

Get Region Methylation Data

Description

getRegionMeth() extracts methylation values at specified regions for all samples and then saves it as a .rds file.

Usage

getRegionMeth(
  regions,
  bs,
  type = c("raw", "smooth"),
  save = TRUE,
  file = "Region_Methylation.rds",
  verbose = TRUE
)

Arguments

regions

A data.frame of regions, typically after filtering with filterRegions(). Must have the columns chr, start, and end.

bs

A BSseq object, typically after filtering with filterCpGs().

type

A character(1) specifying the type of methylation values to extract. Accepted values are raw and smooth

save

A logical(1) indicating whether to save the matrix.

file

A character(1) giving the file name (.rds) for the saved matrix.

verbose

A logical(1) indicating whether messages should be printed.

Details

Methylation is summarized at the region level, and is estimated as the methylated reads divided by the total reads. Methylation values are obtained from a BSseq object and can be either raw or smoothed methylation.

Value

A numeric matrix, where each row is a region and each column is a sample.

See Also

  • getPCs() and adjustRegionMeth() to adjust methylation for the top principal components.

  • getDendro() and plotDendro() to generate and visualize dendrograms.

Examples

## Not run: 

# Get Methylation Data
meth <- getRegionMeth(regions, bs = bs, file = "Region_Methylation.rds")

# Adjust Methylation Data for Top PCs
mod <- model.matrix(~1, data = pData(bs))
PCs <- getPCs(meth, mod = mod, file = "Top_Principal_Components.rds")
methAdj <- adjustRegionMeth(meth, PCs = PCs,
                            file = "Adjusted_Region_Methylation.rds")

# Assess Sample Similarity
getDendro(methAdj, distance = "euclidean") %>%
        plotDendro(file = "Sample_Dendrogram.pdf", expandY = c(0.25,0.08))

## End(Not run)


cemordaunt/comethyl documentation built on Oct. 20, 2023, 5:47 p.m.