Friday, February 14, 2014

How to correct negative coordinates from peaks bed file

If you have negative numbers as coordinates in your bed file with peak positions do the following to convert them to 0.

Use cat and pipe it to awk:

cat peaks.bed | awk '{OFS="\t"}{if($2<0){$2=0};print}' > corrected_peaks.bed

Or remove them:

cat peaks.bed | awk ‘($2>0)’ | filtered_peaks.bed

No comments:

Post a Comment