Export bigWig files with per-window scores for each sample (or group means).
writeBigWigs(
qseaSet,
folderName,
normMethod = "nrpm",
useGroupMeans = FALSE,
naVal = -1
)qseaSet.
A qseaSet object containing methylation-enriched sequencing data.
Default: none (must be supplied).
character(1).
Output directory where .bw files will be written (created if missing).
Default: none (must be supplied).
character(1).
Normalisation/measure to export. Common choices: "nrpm" or "beta".
Default: "nrpm".
logical(1).
If TRUE, export group-mean tracks instead of per-sample tracks.
Default: FALSE.
numeric(1).
Value used to replace NA scores prior to export (useful for beta).
Default: 0.
(Invisibly) NULL. Files are written to folderName.
For each sample (or group), the function pairs the per-window scores from
qseaSet with the corresponding window genomic coordinates and writes a
bigWig via rtracklayer. When exporting beta, windows failing the minimum
read threshold used to compute beta may be NA; these are replaced by
naVal before writing.
File naming. Output files are typically named using the sample (or group)
name and the method, e.g. "<sample>_<method>.bw" or
"<group>_<method>_means.bw" when useGroupMeans = TRUE.
Seqinfo. bigWig export requires chromosome lengths; ensure the window
GRanges in qseaSet carries valid seqinfo (this is the case for the
example data on GRCh38).
data(exampleTumourNormal, package = "mesa")
# Per-sample NRPM bigWigs
td <- tempfile()
dir.create(td)
exampleTumourNormal %>%
writeBigWigs(folderName = td, normMethod = "nrpm", useGroupMeans = FALSE)
#> Generating table of nrpm values for 819 regions across 10 samples.
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Colon1_N_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Colon1_T_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Colon2_N_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Colon2_T_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Lung1_N_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Lung1_T_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Lung2_N_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Lung2_T_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Lung3_N_nrpm.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file51732344a45/Lung3_T_nrpm.bw
list.files(td, pattern = "\\\\.bw$")
#> character(0)
# Group-mean beta bigWigs (replace NA beta with 0)
td2 <- tempfile()
dir.create(td2)
exampleTumourNormal %>%
writeBigWigs(
folderName = td2,
normMethod = "beta",
useGroupMeans = TRUE,
naVal = 0
)
#> Generating table of beta values for 819 regions across 10 sample groups.
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Colon1_N_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Colon1_T_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Colon2_N_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Colon2_T_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Lung1_N_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Lung1_T_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Lung2_N_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Lung2_T_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Lung3_N_beta.bw
#> Writing bigWig track to /tmp/RtmpP8NbUt/file517788f8746/Lung3_T_beta.bw
list.files(td, pattern = "\\\\.bw$")
#> character(0)