Skip to content
bismark-rust-v3.5.1

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>”
  • <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.

  • -s/--single-end

    Input file(s) are Bismark result file(s) generated from single-end read data. If neither -s nor -p is set the type of experiment will be determined automatically.

  • -p/--paired-end

    Input file(s) are Bismark result file(s) generated from paired-end read data. If neither -s nor -p is 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 .fai index next to it (samtools faidx). Required when any input file is CRAM; ignored for BAM/SAM input.

  • --allow_discordant

    Accept output from other bisulfite aligners carrying Bismark-format XM/XR/XG tags. 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 -p for 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_overlap

    For 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_overlap

    For 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.

  • --comprehensive

    Specifying 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_CpG

    This will produce two output files (in --comprehensive mode) or eight strand-specific output files (default) for Cs in

    • CpG context
    • non-CpG context
  • --report

    Prints out a short methylation summary as well as the parameters used to run this script. Default: ON.

  • --no_header

    Suppresses the Bismark version header line in all output files for more convenient batch processing.

  • -o/--output_dir DIR

    Allows specification of a different output directory (absolute or relative path). If not specified explicitly, the output will be written to the current directory.

  • --samtools_path

    Accepted 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.

  • --gzip

    The methylation extractor files (CpG_OT_…, CpG_OB_… etc) will be written out in a GZIP compressed form to save disk space. This option is also passed on to the genome-wide cytosine report. bedGraph and coverage files are written out as .gz by default.

  • --mbias_only

    The 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_off

    The 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 .gz output 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 --multicore value uses correspondingly more cores of system resources. This option has no bearing on the bismark bedgraph or bismark cov2cyt (genome-wide cytosine report) processes.

  • --version

    Displays version information.

  • -h/--help

    Displays this help file and exits.

  • --bedGraph

    After finishing the methylation extraction, the methylation output is written into a sorted bedGraph file 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_context may be used to report all cytosines irrespective of sequence context (this will take MUCH longer!). The bedGraph conversion step is performed by the bismark bedgraph subcommand.

  • --zero_based

    Write 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 the bedGraph file, 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_spaces

    Replaces white spaces in the sequence ID field with underscores to allow sorting.

  • --CX/--CX_context

    The sorted bedGraph output 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 bedgraph always sorts in memory, so this option does not cap memory use. The value is still checked by bismark bedgraph: it must be a percentage (e.g. --buffer_size 50%) or a number ending in K, M, G or T (e.g. --buffer_size 20G), and an explicit --buffer_size cannot be combined with --ample_memory.

  • --scaffolds/--gazillion

    Accepted for compatibility with Perl Bismark; ignored. Perl Bismark used this to avoid the open-filehandle limit on genomes with very many scaffolds; bismark bedgraph sorts in memory without per-chromosome files, so there is no such limit. Cannot be combined with --ample_memory.

  • --ample_memory

    Accepted for compatibility with Perl Bismark; ignored, since bismark bedgraph always sorts in memory. Cannot be combined with --scaffolds/--gazillion or an explicit --buffer_size.

Genome-wide cytosine methylation report specific options:
Section titled “Genome-wide cytosine methylation report specific options:”
  • --cytosine_report

    After the conversion to bedGraph has completed, the option --cytosine_report produces 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 the bismark cov2cyt subcommand.

  • --CX/--CX_context

    The 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_based

    Uses 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 .fa or .fasta. Specifying a genome folder path is mandatory.

  • --split_by_chromosome

    Writes 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 cov2cyt only)

    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 extract does not accept this option; run bismark cov2cyt --ffs on the coverage file instead.

    Example:
    U00096.3 90 + 0 0 CG CGT CGTG CGTGA GCCGTG
    U00096.3 91 - 1 0 CG CGG CGGC CGGCA CACGGC

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.gz
CHG_OT_simulated_1_bismark_bt2_pe.txt.gz
CHH_OB_simulated_1_bismark_bt2_pe.txt.gz
CHH_OT_simulated_1_bismark_bt2_pe.txt.gz
CpG_OB_simulated_1_bismark_bt2_pe.txt.gz
CpG_OT_simulated_1_bismark_bt2_pe.txt.gz
simulated_1_bismark_bt2_pe.M-bias.txt
simulated_1_bismark_bt2_pe_splitting_report.txt

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.gz

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.gz

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.gz
simulated_1_bismark_bt2_pe.cytosine_context_summary.txt