Writes per-site methylation beta values for a single sample from a
commaData object to a 9-column BED file (BED9 format),
suitable for visualisation in IGV, UCSC Genome Browser, or other genome
browsers that support the itemRGB field.
Usage
writeBED(
object,
file,
sample,
mod_type = NULL,
rgb_scale = TRUE,
track_name = sample,
track_description = "methylation beta values"
)Arguments
- object
A
commaDataobject.- file
Character string. Path to the output BED file. The file will be created or overwritten.
- sample
Character string. Name of the sample to export. Must match a column name in
methylation(object).- mod_type
Character string or
NULL. If provided, only sites of the specified modification type are written (e.g.,"6mA"). IfNULL(default), all sites are written.- rgb_scale
Logical. If
TRUE(default), anitemRGBcolumn is added based on the methylation score using a blue-to-red gradient (low = blue, high = red). IfFALSE,itemRGBis set to"0,0,0"for all sites.- track_name
Character string. Name shown in the genome browser track header. Defaults to
sample.- track_description
Character string. Description shown in the track header. Defaults to
"methylation beta values".
Details
The BED score field (column 5) contains the beta value multiplied by 1000
and rounded to the nearest integer (range 0–1000), which is the standard
convention for methylation BED files. The itemRGB colour gradient
transitions as follows: score ≤ 200 = blue (0,0,255), score ≤ 400 =
blue-purple (83,0,172), score ≤ 600 = purple (167,0,85), score ≤ 800 =
red-purple (222,0,28), score ≤ 1000 = red (250,0,0).
Sites with NA methylation (below the coverage threshold) are
excluded from the output.