Methylation Extraction
Appendix (IV): Bismark Methylation Extractor
Section titled “Appendix (IV): Bismark Methylation Extractor”A brief description of the Bismark methylation extractor and a full list of options can also be viewed by typing bismark extract --help
USAGE: bismark extract [options] <filenames>
Section titled “USAGE: bismark extract [options] <filenames>”ARGUMENTS:
Section titled “ARGUMENTS:”<filenames>
A space-separated list of Bismark result files in BAM, SAM or CRAM format from which methylation information is extracted for every cytosine in the reads. Each file is processed on its own, with its own output files; two inputs that would write files of the same name (e.g. a/s.bam and b/s.cram) stop the run before anything is written.
OPTIONS:
Section titled “OPTIONS:”-
-s/--single-endInput file(s) are Bismark result file(s) generated from single-end read data. If neither
-snor-pis set the type of experiment will be determined automatically. -
-p/--paired-endInput file(s) are Bismark result file(s) generated from paired-end read data. If neither
-snor-pis set the type of experiment will be determined automatically. -
--cram_ref <path>Reference FastA file used to decode CRAM input. It must be the reference the CRAM was written against and needs a
.faiindex next to it (samtools faidx). Required when any input file is CRAM; ignored for BAM/SAM input. -
--allow_discordantAccept output from other bisulfite aligners carrying Bismark-format
XM/XR/XGtags. In paired-end mode, process discordant and cross-chromosome pairs independently and extract mapped reads whose mate is absent or unmapped; skip and count secondary and supplementary alignments. In single-end mode, only the secondary/supplementary filtering applies. Default: OFF.Paired input must be grouped by read name; use
-pfor paired input from a non-Bismark aligner. An orphan rate above 20% of templates produces a warning, including under--quiet, and does not by itself fail extraction. A template is one complete pair or one orphan. The warning does not establish incorrect ordering, and its absence does not validate grouping. Paired input declared coordinate-sorted is rejected. See input from a non-Bismark aligner for preparation and output details. -
--no_overlapFor paired-end reads it is theoretically possible that Read 1 and Read 2 overlap. This option avoids scoring overlapping methylation calls twice (only methylation calls of read 1 are used for in the process since read 1 has historically higher quality basecalls than read 2). Whilst this option removes a bias towards more methylation calls in the center of sequenced fragments it may de facto remove a sizeable proportion of the data. This option is on by default for paired-end data but can be disabled using
--include_overlap. Default: ON. -
--include_overlapFor paired-end data all methylation calls will be extracted irrespective of whether they overlap or not. Default: OFF.
-
--ignore <int>Ignore the first <int> bp from the 5’ end of Read 1 (or single-end alignment files) when processing the methylation call string. This can remove e.g. a restriction enzyme site at the start of each read or any other source of bias (such as PBAT-Seq data).
-
--ignore_r2 <int>Ignore the first <int> bp from the 5’ end of Read 2 of paired-end sequencing results only. Since the first couple of bases in Read 2 of BS-Seq experiments show a severe bias towards non-methylation as a result of end-repairing sonicated fragments with unmethylated cytosines (see M-bias plot), it is recommended that the first couple of bp of Read 2 are removed before starting downstream analysis. Please see the section on M-bias plots in the Bismark User Guide for more details.
-
--ignore_3prime <int>Ignore the last <int> bp from the 3’ end of Read 1 (or single-end alignment files) when processing the methylation call string. This can remove unwanted biases from the end of reads.
-
--ignore_3prime_r2 <int>Ignore the last <int> bp from the 3’ end of Read 2 of paired-end sequencing results only. This can remove unwanted biases from the end of reads.
-
--comprehensiveSpecifying this option will merge all four possible strand-specific methylation info into context-dependent output files. The default contexts are:
- CpG context
- CHG context
- CHH context
-
--merge_non_CpGThis will produce two output files (in
--comprehensive mode) or eight strand-specific output files (default) for Cs in- CpG context
- non-CpG context
-
--reportPrints out a short methylation summary as well as the parameters used to run this script. Default: ON.
-
--no_headerSuppresses the Bismark version header line in all output files for more convenient batch processing.
-
-o/--output_dir DIRAllows specification of a different output directory (absolute or relative path). If not specified explicitly, the output will be written to the current directory.
-
--samtools_pathAccepted for compatibility but ignored by the Rust suite, which does all BAM/SAM/CRAM I/O with pure-Rust
noodles— no Samtools installation is required. -
--gzipThe methylation extractor files (CpG_OT_…, CpG_OB_… etc) will be written out in a
GZIPcompressed form to save disk space. This option is also passed on to the genome-wide cytosine report.bedGraphandcoveragefiles are written out as.gzby default. -
--mbias_onlyThe methylation extractor will read the entire file but only output the M-bias table and plots as well as a report (optional) and then quit. Default: OFF.
-
--mbias_offThe methylation extractor will process the entire file as usual but doesn’t write out any M-bias report. Only recommended for users who deliberately want to keep an earlier version of the M-bias report. Default: OFF.
-
--multicore <int>Sets the number of cores to be used for the methylation extraction process. If system resources are plentiful this is a viable option to speed up the extraction process (we observed a near linear speed increase for up to 10 cores used). Please note that a typical process of extracting a BAM file and writing out
.gzoutput streams will use more than one core per value of--multicore <int>specified (the extractor itself plus a GZIP output stream — the Rust suite runs no Samtools stream), so a high--multicorevalue uses correspondingly more cores of system resources. This option has no bearing on thebismark bedgraphorbismark cov2cyt(genome-wide cytosine report) processes. -
--versionDisplays version information.
-
-h/--helpDisplays this help file and exits.
bedGraph specific options:
Section titled “bedGraph specific options:”-
--bedGraphAfter finishing the methylation extraction, the methylation output is written into a sorted
bedGraphfile that reports the position of a given cytosine and its methylation state (in %, see details below) using 0-based genomic start and 1-based end coordinates. The calls are aggregated and sorted in memory; no temporary files are written. By default, only cytosines in CpG context are sorted. The option--CX_contextmay be used to report all cytosines irrespective of sequence context (this will take MUCH longer!). ThebedGraphconversion step is performed by thebismark bedgraphsubcommand. -
--zero_basedWrite out an additional coverage file (ending in
.zero.cov) that uses 0-based genomic start and 1-based genomic end coordinates (zero-based, half-open), like used in thebedGraphfile, instead of using 1-based coordinates throughout. Default: OFF. -
--cutoff [threshold]
The minimum number of times any methylation state (methylated or unmethylated) has to be seen for a nucleotide before its methylation percentage is reported. Default: 1.
-
--remove_spacesReplaces white spaces in the sequence ID field with underscores to allow sorting.
-
--CX/--CX_contextThe sorted
bedGraphoutput file contains information on every single cytosine that was covered in the experiment irrespective of its sequence context. This applies to both forward and reverse strands. Please be aware that this option may generate large temporary and output files and may take a long time to sort (up to many hours). Default: OFF (i.e. Default = CpG context only). -
--buffer_size <string>Accepted for compatibility with Perl Bismark; ignored.
bismark bedgraphalways sorts in memory, so this option does not cap memory use. The value is still checked bybismark bedgraph: it must be a percentage (e.g.--buffer_size 50%) or a number ending inK,M,GorT(e.g.--buffer_size 20G), and an explicit--buffer_sizecannot be combined with--ample_memory. -
--scaffolds/--gazillionAccepted for compatibility with Perl Bismark; ignored. Perl Bismark used this to avoid the open-filehandle limit on genomes with very many scaffolds;
bismark bedgraphsorts in memory without per-chromosome files, so there is no such limit. Cannot be combined with--ample_memory. -
--ample_memoryAccepted for compatibility with Perl Bismark; ignored, since
bismark bedgraphalways sorts in memory. Cannot be combined with--scaffolds/--gazillionor an explicit--buffer_size.
Genome-wide cytosine methylation report specific options:
Section titled “Genome-wide cytosine methylation report specific options:”-
--cytosine_reportAfter the conversion to bedGraph has completed, the option
--cytosine_reportproduces a genome-wide methylation report for all cytosines in the genome. By default, the output uses 1-based chromosome coordinates (zero-based start coords are optional) and reports CpG context only (all cytosine context is optional). The output considers all Cs on both forward and reverse strands and reports their position, strand, trinucleotide content and methylation state (counts are 0 if not covered). The cytosine report conversion step is performed by thebismark cov2cytsubcommand. -
--CX/--CX_contextThe output file contains information on every single cytosine in the genome irrespective of its context. This applies to both forward and reverse strands. Please be aware that this will generate output files with > 1.1 billion lines for a mammalian genome such as human or mouse. Default: OFF (i.e. Default = CpG context only).
-
--zero_basedUses 0-based genomic coordinates instead of 1-based coordinates. Default: OFF.
-
--genome_folder <path>Enter the genome folder you wish to use to extract sequences from (full path only). Accepted formats are FastA files ending with
.faor.fasta. Specifying a genome folder path is mandatory. -
--split_by_chromosomeWrites the output into individual files for each chromosome instead of a single output file. Files are named to include the input filename as well as the chromosome number.
-
--ffs(bismark cov2cytonly)In addition to the standard output this option also extracts a four-, five- and six-nucleotide context for the cytosines in question. Hexamers follow the rule
xxCxxx. Too short sequences (e.g. at the edges of the chromosome) are left blank; sequences containing Ns are ignored.bismark extractdoes not accept this option; runbismark cov2cyt --ffson the coverage file instead.Example:U00096.3 90 + 0 0 CG CGT CGTG CGTGA GCCGTGU00096.3 91 - 1 0 CG CGG CGGC CGGCA CACGGC
OUTPUT
Section titled “OUTPUT”Extractor output
Section titled “Extractor output”The bismark extract output is in the form (tab delimited, 1-based coords):
<seq-ID> <methylation state*> <chromosome> <start position (= end position)> <methylation call>
Methylated cytosines receive a '+' orientation,Unmethylated cytosines receive a '-' orientation.Example output files (default mode only):
CHG_OB_simulated_1_bismark_bt2_pe.txt.gzCHG_OT_simulated_1_bismark_bt2_pe.txt.gzCHH_OB_simulated_1_bismark_bt2_pe.txt.gzCHH_OT_simulated_1_bismark_bt2_pe.txt.gzCpG_OB_simulated_1_bismark_bt2_pe.txt.gzCpG_OT_simulated_1_bismark_bt2_pe.txt.gzsimulated_1_bismark_bt2_pe.M-bias.txtsimulated_1_bismark_bt2_pe_splitting_report.txtbedGraph output
Section titled “bedGraph output”The bedGraph output (optional) looks like this (tab-delimited, 0-based start, 1-based end coords):
track type=bedGraph (header line)<chromosome> <start position> <end position> <methylation percentage>Example output files (default mode only):
simulated_1_bismark_bt2_pe.bedGraph.gzCoverage output
Section titled “Coverage output”The coverage output looks like this (tab-delimited; 1-based genomic coords):
<chromosome> <start position> <end position> <methylation percentage> <count methylated> <count unmethylated>Example output files (default mode only):
simulated_1_bismark_bt2_pe.bismark.cov.gzCytosine report
Section titled “Cytosine report”The genome-wide cytosine report (optional) is tab-delimited in the following format (1-based coords):
<chromosome> <position> <strand> <count methylated> <count unmethylated> <C-context> <trinucleotide context>Example output files (default mode only):
simulated_1_bismark_bt2_pe.CpG_report.txt.gzsimulated_1_bismark_bt2_pe.cytosine_context_summary.txt