This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to reorder lines in afile based on a list of gene IDS?

I have two files;

File one:

ID  SCORE   PVALUE
A   1   0.1
B   2   0.2
C   3   0.3
D   4   0.4

FIle 2:

ID
C
B
A

Now I want to reorder my file 1, in the sequence as present in file 2.

THanks

reorder

And what have you tried to solve this?

Do you want a solution in Perl, Python or R?

why not trying googling using keywords "r dataframe reorder factor"?

In R, just set the column as factor with your levels for the dataframe.

For others, storing the levels in a hashmap with incremental numbers as values, then you can sort the rows using corresponding hashmap value.

Want save time? csvtk sort supports sorting by user defined levels.

0 answers

No answers yet.

Log in to answer this question.