This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Sorting file by column, with missing values

I'm trying to sort a file by max values in column 8 (Raw), here is a sample of the data:

glimmer screen shoot

I tried to tackle this dataset with the following sort script:

sort -t$'\t' -k8,8  -nr glm_ref.detail2 > glm_ref_detail_sort

however, the output file keeps sorting on the first column? I removed the header info to simplify the process but for some reason it wants to sort on the ID column (column 1) which has many missing values. Any ideas?

Ideally the file will be sorted by Raw, starting with the max positive number and ending with the largest negative number.

glimmer sort awk

You'd need to head -2 <file> && tail -n +3 <file> | sort ... to sort properly. That header is super unwieldy.

Are you sure the file is tab-separated? You can check with cat -vet file.txt and see if columns are separated by the ^I marker. Also, you probably want -k8,8nr to sort column 8 numerically largest to smallest rather than alphanumerically.

0 answers

No answers yet.

Log in to answer this question.