Question: Shrink elements of a bedtools file
0
gravatar for olga.botvinnik
3.8 years ago by
United States
olga.botvinnik80 wrote:

Is there a way to shrink elements in a bed file? `bedtools {slop,flank}` are all about increasing, but I can't find a function in bedtools that will shrink a region. In particular, I'm interested in taking intron files and strand-specifically removing 400bp from one end.

Thanks!

bedtools • 1.2k views
ADD COMMENTlink modified 3.8 years ago by Alex Reynolds28k • written 3.8 years ago by olga.botvinnik80
3
gravatar for Pierre Lindenbaum
3.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum119k wrote:
 awk -vX=400 '{OFS="\t";S=$2+X; E=$3-X; if(S<=E) {$2=S;$3=E;print;}}' input.bed
ADD COMMENTlink written 3.8 years ago by Pierre Lindenbaum119k
0
gravatar for Alex Reynolds
3.8 years ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k wrote:

This can easily be done per edge and per strand with awk and BEDOPS bedops --range.

To shrink forward-stranded introns from the "left" edge:

$ awk '$6=="+"' introns.bed | bedops --everything --range 400:0 - > left_shrunken_forward_introns.bed

To shrink forward-stranded elements from the "right" edge:

$ awk '$6=="+"' introns.bed | bedops --everything --range 0:-400 - > right_shrunken_forward_introns.bed

To shrink reverse-stranded introns from the "left" edge:

$ awk '$6=="-"' introns.bed | bedops --everything --range 400:0 - > left_shrunken_reverse_introns.bed

And, finally, from the "right" edge:

$ awk '$6=="-"' introns.bed | bedops --everything --range 0:-400 - > right_shrunken_reverse_introns.bed
ADD COMMENTlink modified 3.8 years ago • written 3.8 years ago by Alex Reynolds28k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2116 users visited in the last hour