Export differentially methylated region (DMR) results to an Excel workbook, creating one worksheet per contrast.

writeDMRsToExcel(dataTable, path, FDRthres = 0.05)

Arguments

dataTable

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

path

character(1) File path of the Excel workbook to write (e.g., "dmr_results.xlsx").

FDRthres

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

Value

(Invisibly) returns the input object:

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

Details

One worksheet is created per contrast found in dataTable. If no contrast column is present, all rows are written to a single worksheet. If file I/O is restricted on the system (e.g., some HPC build environments), consider writing to tempfile(fileext = ".xlsx") in examples or tests.

Examples

data(exampleTumourNormal, package = "mesa")

# Minimal example: write results for a single contrast
exampleTumourNormal %>%
    calculateDMRs(variable = "type", contrasts = "LUAD_vs_NormalLung") %>%
    writeDMRsToExcel(path = file.path(tempdir(), "test.xlsx"))
#> 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

# With multiple contrasts and annotation
exampleTumourNormal %>%
    calculateDMRs(variable = "tumour", contrasts = "all") %>%
    annotateWindows(
        TxDb = "TxDb.Hsapiens.UCSC.hg38.knownGene",
        annoDb = "org.Hs.eg.db"
    ) %>%
    writeDMRsToExcel(path = file.path(tempdir(), "test.xlsx"))
#> 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