Dear all,
I just need a little help to merge my all features counts into one matrix. I have counted features using htseq-counts and now want to merge into one file like....
ID c1 c2 c3..............t1 t2 t2.......etc
The problem is that i have 36 sample and corresponding counts so i am lazy to write ...
paste *.txt | cut -d -f1,2,4,6,8...............................72 (because each file contain two column i.e ID and counts )
and moreover, apart from laziness, one problem also happened here that while pasting its not in sequence like :
paste 1.txt 2.txt 3.txt............
Help me please...
Finally got a solution to this problem
#!/bin/bash
FILES=$(ls -t -v *.txt | tr '\n' ' ');
awk 'NF > 1{ a[$1] = a[$1]"\t"$2} END {for( i in a ) print i a[i]}' $FILES > merged.tmp
This woks like you asked.
Thank you man for your kind reply but i have already done, i am sorry for the delay. Was just needed to change the file name like 1.txt -> 01.txt, 2.txt -> 02.txt....................... etc and after i used your suggested awk code and worked fine.
By the way thanks a million.