bedtools_genomecov: bedtools_genomecov

View source: R/genomecov.R

bedtools_genomecovR Documentation



Compute coverage over the genome. By default, this computes a per-chromosome histogram of the coverage, but options allow for per-position coverage to be returned in different ways.


bedtools_genomecov(cmd = "--help")
R_bedtools_genomecov(i, g = NA_character_, d = FALSE, dz = FALSE,
                     bg = FALSE, bga = FALSE, split = FALSE,
                     strand = c("any", "+", "-"), `5` = FALSE, `3` = FALSE,
                     max = NULL, scale = 1, pc = FALSE, fs = NULL)
do_bedtools_genomecov(i, g = NA_character_, d = FALSE, dz = FALSE,
                      bg = FALSE, bga = FALSE, split = FALSE,
                      strand = c("any", "+", "-"), `5` = FALSE, `3` = FALSE,
                      max = NULL, scale = 1, pc = FALSE, fs = NULL)



String of bedtools command line arguments, as they would be entered at the shell. There are a few incompatibilities between the docopt parser and the bedtools style. See argument parsing.


Path to a BAM/BED/GFF/VCF/etc file, a BED stream, a file object, or a ranged data structure, such as a GRanges. Use "stdin" for input from another process (presumably while running via Rscript). For streaming from a subprocess, prefix the command string with “<”, e.g., "<grep foo file.bed". Any streamed data is assumed to be in BED format.


Genome file, identifier or Seqinfo object that defines the order and size of the sequences.


Report the depth at each genome position. This causes a GPos object to be returned.


Same as d, except the zero coverage positions are dropped.


Like d, except returns a GRanges object, which is useful for operating on runs of coverage. Zero coverage runs are dropped.


Like bg, except the zero coverage runs are retained.


Treat split BAM (i.e., having an ‘N’ CIGAR operation) or BED12 entries as compound ranges with gaps, i.e., as GRangesList objects.


Calculate coverage of intervals from a specific strand.


Calculate coverage of 5' positions (instead of entire interval).


Calculate coverage of 3' positions (instead of entire interval).


Combine all positions with a depth >= max into a single bin in the histogram.


Scale the coverage by a constant factor. Each coverage value is multiplied by this factor before being reported. Useful for normalizing coverage by, e.g., reads per million (RPM).


Calculates coverage of intervals from left point of a pair reads to the right point. Works for BAM files only.


Forces to use the given fragment size instead of read length.


As with all commands, there are three interfaces to the genomecov command:


Parses the bedtools command line and compiles it to the equivalent R code.


Accepts R arguments corresponding to the command line arguments and compiles the equivalent R code.


Evaluates the result of R_bedtools_genomecov. Recommended only for demonstration and testing. It is best to integrate the compiled code into an R script, after studying it.

We typically compute the coverage with coverage. Computing the histogram requires more work.


A language object containing the compiled R code, evaluating to an object that depends on the mode:


A DataFrame that is a per-chromosome histogram of the coverage that includes the whole genome margin. Includes columns “seqnames” (the chromosome name, or “genome”), “coverage” (the coverage value), “count” (the count of positions covered at that value), “len” (the length of the chromosome/genome), “fraction” (the fraction of bases covered at the value).

d, dz

A GPos object with per-position coverage values.

bg, bga

A GRanges object with coverage runs.


Michael Lawrence


See Also

intra-range-methods for genomecov.


## Not run: 
setwd(system.file("unitTests", "data", "genomecov", package="HelloRanges"))

## End(Not run)
## get coverage runs as a GRanges
bedtools_genomecov("-i y.bed -bg -g test.genome")
## get coverage depth as a GPos, dropping zero values, ignore junctions
bedtools_genomecov("-i three_blocks.bam -dz -split")
## custom fragment size
bedtools_genomecov("-i chip.bam -bg -fs 100")

lawremi/HelloRanges documentation built on April 20, 2022, 5:40 p.m.