Entering edit mode
16 months ago
Marco Pannone
▴
810
Hello!
I have a list of genes and I want to extract their genomic coordinates. I do so in UCSC Table Browser, but in the output .txt file I obtain the genes have been mixed up in their order.
For downstream plotting reasons, I want to get the genes in the output file in the same exact order as I provided in the input list, but I cannot find a way to do so.
Any help would be very appreciated.
Thanks!
You could sort your result file using your input order:
https://unix.stackexchange.com/questions/274625/sorting-one-file-line-by-line-based-on-another-file
https://unix.stackexchange.com/questions/610303/how-to-sort-a-first-file-csv-based-on-the-second-file-keys
There are other solutions you can find as well.
I was aware of solutions like those ones (even much easier to do it in R as well). I was just wondering if there was a way to do so already in the Table Browser, without needing to do it myself afterwards. But thanks anyway for the answer!
Are you using the web interface or MySQL queries? The web interface may be returning the answers in random order. There is no option to keep the queries in the same order in GUI that I see. MariaDB (MySql) queries may give you more control.
Yes just using the web interface. I could notice I get the output in random order. I wished there was an option to keep the same order as the input, but I will fix it myself in R.
I am having a hard time finding a solution to the problem since the output file has many more rows than the input list (since one gene can produce multiple transcripts with slightly different starting and ending coordinates). Do you know how I can fix that? Thanks again!
Solution here will sort rows that contain multiple keys: https://unix.stackexchange.com/questions/274625/sorting-one-file-line-by-line-based-on-another-file
Be sure to change the last line to something like
mv -f "$TMP_FILE" "some_other_file_name"
to prevent overwriting original file.Original file:
will be sorted to
Can't help with a
R
solution. Perhaps someone else will.