CoMethSingleRegion: Wrapper function to find contiguous and comethyalted...

View source: R/CoMethSingleRegion.R

CoMethSingleRegionR Documentation

Wrapper function to find contiguous and comethyalted sub-regions within a pre-defined genomic region

Description

Wrapper function to find contiguous and comethyalted sub-regions within a pre-defined genomic region

Usage

CoMethSingleRegion(
  CpGs_char,
  dnam,
  betaToM = TRUE,
  rDropThresh_num = 0.4,
  method = c("pearson", "spearman"),
  minCpGs = 3,
  genome = c("hg19", "hg38"),
  arrayType = c("450k", "EPIC"),
  manifest_gr = NULL,
  returnAllCpGs = FALSE
)

Arguments

CpGs_char

vector of CpGs in the inputting pre-defined genomic region.

dnam

matrix (or data frame) of beta values, with row names = CpG ids, column names = sample ids. This should include the CpGs in CpGs_char, as well as additional CpGs.

betaToM

indicates if converting methylation beta values mvalues

rDropThresh_num

threshold for min correlation between a cpg with sum of the rest of the CpGs

method

method for computing correlation, can be "pearson" or "spearman"

minCpGs

minimum number of CpGs to be considered a "region". Only regions with more than minCpGs will be returned.

genome

Human genome of reference hg19 or hg38

arrayType

Type of array, can be "450k" or "EPIC"

manifest_gr

A GRanges object with the genome manifest (as returned by ExperimentHub or by ImportSesameData). This function by default ignores this argument in favour of the genome and arrayType arguments.

returnAllCpGs

When there is not a contiguous comethylated region in the inputing pre-defined region, returnAllCpGs = 1 indicates outputting all the CpGs in the input region, while returnAllCpGs = 0 indicates not returning any CpG.

Value

A list with two components:

  • Contiguous_Regions : a data frame with CpG (CpG ID), Chr (chromosome number), MAPINFO (genomic position), r_drop (correlation between the CpG with rest of the CpGs), keep (indicator for co-methylated CpG), keep_contiguous (index for contiguous comethylated subregion)

  • CpGs_subregions : lists of CpGs in each contiguous co-methylated subregion

Examples

   data(betasChr22_df)

   CpGsChr22_char <- c(
     "cg02953382", "cg12419862", "cg24565820", "cg04234412", "cg04824771",
     "cg09033563", "cg10150615", "cg18538332", "cg20007245", "cg23131131",
     "cg25703541"
   )
   CoMethSingleRegion(
     CpGs_char = CpGsChr22_char,
     dnam = betasChr22_df
   )

   data(betaMatrix_ex3)
   CpGsEx3_char <- c(
     "cg14221598", "cg02433884", "cg07372974", "cg13419809", "cg26856676",
     "cg25246745"
   )
   CoMethSingleRegion(
     CpGs_char = CpGsEx3_char,
     dnam = t(betaMatrix_ex3),
     returnAllCpGs = TRUE
   )


TransBioInfoLab/coMethDMR documentation built on Sept. 14, 2022, 7:09 p.m.