Export differentially methylated region (DMR) results to a set of BED files, with one file generated per contrast.

writeDMRsToBed(dataTable, folder, FDRthres = 0.05)

Arguments

dataTable

data.frame DMR results, typically returned by calculateDMRs(). If a GRanges, it will be coerced to a data frame internally.

folder

character(1) Directory in which to write BED files. Must exist and be writable.

FDRthres

numeric(1) False discovery rate threshold used to filter DMRs before writing. Default: 0.05.

Value

(Invisibly) returns the input object:

  • writeDMRsToBed(): returns dataTable (invisibly), enabling use in a pipeline.

Examples

data(exampleTumourNormal, package = "mesa")

# Export DMRs for a single contrast to BED files in a temp directory
exampleTumourNormal %>%
    calculateDMRs(
        variable = "type",
        contrasts = "LUAD_vs_NormalLung"
    ) %>%
    writeDMRsToBed(folder = tempdir())
#> Generating table of nrpm values for 819 regions across 5 samples.
#> Fitting initial GLM on 255 windows, without using parallelisation.
#> Performing contrast LUAD_vs_NormalLung
#> Contrasts Complete
#> selecting regions from contrast LUAD_vs_NormalLung
#> selected 46/255 windows
#> adding test results from LUAD_vs_NormalLung

# Export DMRs with explicit annotation (requires TxDb/annotation packages)
exampleTumourNormal %>%
    calculateDMRs(variable = "tumour", contrasts = "all") %>%
    annotateWindows(
        TxDb = "TxDb.Hsapiens.UCSC.hg38.knownGene",
        annoDb = "org.Hs.eg.db"
    ) %>%
    writeDMRsToBed(folder = tempdir(), FDRthres = 0.1)
#> Calculating 1 possible contrasts on the tumour column.
#> Generating table of nrpm values for 819 regions across 10 samples.
#> Fitting initial GLM on 309 windows, without using parallelisation.
#> Performing contrast Normal_vs_Tumour
#> Contrasts Complete
#> selecting regions from contrast Normal_vs_Tumour
#> selected 23/309 windows
#> adding test results from Normal_vs_Tumour
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> 'select()' returned 1:1 mapping between keys and columns