This is a test version of Biostars. For the public version, visit https://www.biostars.org.
sort the homo sapiens genes by chromosome with Unix command lines

Hi,

I want to sort homo sapiens gene by chromosome. I tried with sort -t _ -k 3 -g genes.txt > genes_by_chr.txt, while the result is not what I want. In my genes.txt file, the chromosome column includes numbers like 1, 2, 3 ... and characters like CHR_HG1_PATCH, CHR_HG26_PATCH, and GL000009.2. What is the easiest way to sort my genes by chromosome, if I only use Unix commands?

Thank you in advance!

gene sort

How about sort -kz,z genes.txt > genes_by_chr.txt, where z is the column of interest. In case you have positional information for your genes, you may add -kx,xn, where x is the column of the genomic coordinate and "n" indicates to sort numerically.

Paste add some example data, in additon to data description. Data description is good, but it is more helpful if you can post some example data.

try sort -V -k1 if chromsomes are in first column.

0 answers

No answers yet.

Log in to answer this question.