I have a data file (
data.txt) with ~320 rows and ~1800 columns (1.9 MB), and I need to extract certain columns out (for all rows). The general layout of
data.txt is as follows:
ID Adipocyte - breast, donor2.CNhs11969.11327-117E4 .... HGNC:8888 0 .... HGNC:9999 123.92 .... HGNC:1000 9.31 ....
I have a list of the columns I need to extract (in a file
list.txt), but this list is made up of only the CNhsXXXXX identifier in the column term (i.e. for the above example, the list would only contain CNhs11969, not the whole term Adipocyte - breast, donor2.CNhs11969.11327-117E4).
I've used grep for a list of rows before, but have not for columns. I had a look around but could not find a way to grep multiple columns with multiple terms. I'm very new to unix (I'm a biologist, little experience in computing), so I'm unsure if grep can do this.
Any help would be appreciated.
EDIT: My sample output would be only ~850 of the ~1800 columns (only those containing the terms in my
list.txt file). Example: If my list contained only CNhs5006 and CNhs7021, I would only want columns containing those terms in the header. Example of the
ID XXXCNhs5006XXX XXXCNhs6025XXX XXXCNhs7021XXX XXXCNhs8095XXX HGNC:1111 1.23 1.53 9.21 0 HGNC:2222 1.95 73.92 0 123.29
Example of the desired output:
ID XXXCNhs5006XXX XXXCNhs7021 HGNC:1111 1.23 9.21 HGNC:2222 1.95 0
list.txt is just a simple list of terms (1 column, ~850 rows, each row containing 1 search term). Example: