I have a big matrix in which the first row contains the variable_name and the first column contains the name of the objects (variables and objects are the same, it's comparison all vs all). Moreover, I have 2 different text files. The first (file1.txt
) contains the object of interest (I should use this file to select the row of interest-based on the name object reported in the first column of the matrix) while the second file (list.txt
)contains a shorter list of objects and I should use this list to select the relative columns of the matrix that starting with the name of the objects reported in the list. the aim is to use these two txt files to extract the relative scores in the matrix.
e.g. matrix.txt: ( Columns are separated by a tab)
Object 3mup_A_001_____ 3oz1_A_001_____ 456r_V_002_____ 23er_B_001_____ 87t5_C_001_____
23er_B_001_____ 0.5 0.3 0.87 1 0.9
456r_V_002_____ 0.2 0.7 0.65 0.63 0.2
87t5_C_001_____ 0.35 0.5 0.254 0.12 1
dret_A_009_____ 0.99 0.88 0.7 0.89 0.214
3mup_A_001_____ 0.12 0.15 0.87 0.17 0.87
file1.txt:
87t5_C_001_____
list.txt:
3mup_A_001_____
456r_V_002_____
I should use the file1.txt
(87t5_C_001____) to select the object of interest in the first column (select the 4th row of the matrix) and obtained the score associated at the column (variable) that starting with the name of the objects including in the file list.txt
.
output.txt
Object 3mup_A_001_____ 456r_V_002_____
87t5_C_001_____ 0.35 0.254
As an alternative, if it's simpler, the output could have also in another format, for example reporting the score near the object in the list:
3mup_A_001_____ 0.35
456r_V_002_____ 0.254
I hope that it's clear and that someone could help me because I don't know how I can do this operation.
Thanks.