getCpGs: Read Bismark CpG reports

View source: R/Get_and_Filter_CpGs.R

getCpGsR Documentation

Read Bismark CpG reports

Description

getCpGs() reads individual sample Bismark CpG reports into a single BSseq object and then saves it as a .rds file.

Usage

getCpGs(
  colData,
  path = getwd(),
  pattern = "*CpG_report.txt.gz",
  sameLoci = TRUE,
  chroms = c(paste("chr", 1:22, sep = ""), "chrX", "chrY", "chrM"),
  BPPARAM = BiocParallel::MulticoreParam(10),
  save = TRUE,
  file = "Unfiltered_BSseq.rds",
  verbose = TRUE
)

Arguments

colData

A data.frame whose row names specify CpG reports to load into the BSseq object and whose columns are sample traits with numeric values.

path

A character giving the path(s) to the CpG reports.

pattern

A regular expression used to filter for CpG reports.

sameLoci

A logical(1) indicating whether CpG reports contain the same set of methylation loci. This is the case if the files are genome wide cytosine reports aligned to the same reference genome. The default sameLoci = TRUE speeds up getCpGs() by only having to parse each CpG report once.

chroms

A character giving the chromosomes to include in the BSseq object.

BPPARAM

A BiocParallel::BiocParallelParam instance providing the parallel back-end to use during evaluation.

save

A logical(1) indicating whether to save the BSseq object.

file

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

verbose

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

Details

This BSseq object still needs to be filtered for coverage at individual CpGs. More information on these arguments is given in the documentation for bsseq::read.bismark().

Value

A BSseq object.

See Also

  • getCpGtotals() and plotCpGtotals() for help with deciding coverage cutoffs.

  • filterCpGs() to filter the BSseq object.

  • bsseq::read.bismark() for more details on the arguments and the underlying functions.

Examples

## Not run: 

# Read Bismark CpG Reports
colData <- read.xlsx("sample_info.xlsx", rowNames = TRUE)
bs <- getCpGs(colData, file = "Unfiltered_BSseq.rds")

# Examine CpG Totals at Different Cutoffs
CpGtotals <- getCpGtotals(bs, file = "CpG_Totals.txt")
plotCpGtotals(CpGtotals, file = "CpG_Totals.pdf")

# Filter BSseq Object
bs <- filterCpGs(bs, cov = 2, perSample = 0.75, file = "Filtered_BSseq.rds")

## End(Not run)


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