bedtools_genomecov: bedtools_genomecov

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/genomecov.R

Description

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.

Usage

1
2
3
4
5
6
7
8
9
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)

Arguments

cmd

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.

i

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.

g

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

d

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

dz

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

bg

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

bga

Like bg, except the zero coverage runs are retained.

split

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

strand

Calculate coverage of intervals from a specific strand.

5

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

3

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

max

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

scale

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

pc

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

fs

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

Details

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

bedtools_genomecov

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

R_bedtools_genomecov

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

do_bedtools_genomecov

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.

Value

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

default

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.

Author(s)

Michael Lawrence

References

http://bedtools.readthedocs.io/en/latest/content/tools/genomecov.html

See Also

intra-range-methods for genomecov.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## 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")

HelloRanges documentation built on Nov. 8, 2020, 7:05 p.m.