This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to sort chromosome name in bed file

Hello Friends!

I have one stupid question. I have a bed file

chr1 955541 955763 AGRN.chr1.955552.955753
chr1 957569 957852 AGRN.chr1.957580.95784

in my bed file my chromosome name are not sorted I want output in

chr1 chr2 ..... chr22 chrX chrY chrM

Can anyone help me out

Thanks!

bed

can you tell me how should i sort using sortbed i mean commands

i used bedtool/sort -chrThenSizeA -i my.bed > new.bed

it not working

Please see the answer below and provide feedback.

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. Upvote|Bookmark|Accept

1 answer

sortBed -i inputfile >outfile

By default it sorts by chromosome and then by start position in ascending order. It has many other options, kindly go through the manual

@Prasad - It would be better if you change it answer from comment and format the code, so that OP can accept the answer and the question will not remain as unanswered, and also helpful for future googlers.

@Venu - Sure i will keep that in mind. @genomax - thanks for the format

Log in to answer this question.