Created
July 10, 2020 21:40
-
-
Save arnavm/8556b53adf386e47efb880e4ef218f32 to your computer and use it in GitHub Desktop.
One-liner to rescale BED features to a constant-width intervals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nifty one-liner for rescaling BED features (new size designated by s) | |
# Solution from https://www.biostars.org/p/241744/#241748 | |
alias rescaleBed="awk -F '\t' '{X=s; mid=(int(\$2)+int(\$3))/2;printf(\"%s\t%d\t%d\n\",\$1,(mid-X<0?0:mid-X),mid+X);}'" | |
# Example usage to get centered, 200 bp intervals: rescaleBed s=100 test.bed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment