Category

Genomic Interval Manipulation


Usage

bedtools shift [OPTIONS] -i <BED/GFF/VCF> -g <GENOME> [-s or (-m and -p)]


Manual

This tool is part of the bedtools suite, and it's also known as shiftbed.

bedtools shift will move each feature in a feature file by a user-defined number of bases. While something like this could be done with

awk '{OFS="\t" print $1,$2+<shift>,$3+<shift>}'

bedtools shift will restrict the resizing to the size of the chromosome (i.e. no features before 0 or past the chromosome end). The result may not be identical to what bedClip will yield, as bedClip discards any records that are outside of the validate chromosomal ranges.

Input:    ======
-s 1:    -======-
-p 2:   --======
-m 1:     ======-

Required arguments

  • -i bed/gff/vcf: Input file in BED, GFF, or VCF format.
  • -g genome: Genome file. The file should tab delimited and structured as follows: <chromName> <chromSize>.  You can get this file for the genome release that you are working with by using fetchChromSizes.
  • One of the following arguments about the amount of basepairs for the shifting
    • -s int or float: Shift the BED/GFF/VCF entry by -s base pairs. If used with -pct, the value can be a float, e.g. 0.1.
    • -p int or float: Shift features on the + strand by -p base pairs. If used with -pct, the value can be a float, e.g. 0.1.
    • -m int or float: Shift features on the - strand by -m base pairs. If used with -pct, the value can be a float, e.g. 0.1.

Options

  • -pct: Define -s, -m, and -p as a fraction of the feature's length. E.g., if used on a 1000bp feature, -s 0.50 will shift the feature 500 bp "upstream". Default = false.
  • -header: Print the header from the input file prior to results.

Examples

Default behavior

By default, bedtools shift will shift features a fixed number of bases. This shift can either be applied to all features (-s), or seperately to features on the plus (-p) and minus (-m) strands. Shifts can either be positive or negative.

$ cat A.bed
chr1 5 100 +
chr1 800 980 -

$ cat my.genome
chr1 1000

$ bedtools shift -i A.bed -g my.genome -s 5
chr1 10 105 +
chr1 805 985 -

$ bedtools shift -i A.bed -g my.genome -p 2 -m -3
chr1 7 102 +
chr1 797 977 -

However, if the requested number of bases exceeds the boundaries of the chromosome, bedtools shift will “clip” the feature accordingly.

$ cat A.bed
chr1  5   100 +
chr1  800 980 +

$ cat my.genome
chr1  1000

$ bedtools shift -i A.bed -g my.genome -s 5000
chr1  999   1000 +
chr1  999   1000 +
Shifting features by a given fraction

bedtools shift will shift the feature by a user-specific fraction of the feature length. Hence, 0.5 will add half the length of the feature to the start and end coordinates.

For example:

$ cat A.bed
chr1 100 200 a1 1 +

$ bedtools shift -i A.bed -g my.genome -s 0.5 -pct
chr1 150  250 a1 1 +

File formats this tool works with
BEDGFFGTFVCF

Share your experience or ask a question