Hello priyankaraina10 ,
Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.

Thank you!
• 1 views
•
link
I have a correlation matrix of 22000 genes and for some analysis, I need to split each row of the matrix into a new file. Which means I need to create 22000 individual files.
I don't want to use the split command (because I want to get the output file as the gene_name.txt)
Input file (for 6 genes)
IGHD2-15 IGHD3-22 IGHD3-16 IGHD3-10 IGHD3OR15-3B IGHD3-9
IGHD2-15 1 0.696084 0.799736 0.818788 0.03798 0.762752
IGHD3-22 0.696084 1 0.691419 0.67505 0.036993 0.658945
IGHD3-16 0.799736 0.691419 1 0.810656 0.030124 0.759392
IGHD3-10 0.818788 0.67505 0.810656 1 0.026141 0.786954
IGHD3OR15-3B 0.03798 0.036993 0.030124 0.026141 1 0.02706
awk '{print >> $1".txt"}' matrix.txt
That will print each line into a file whose name is the 1st field of that line plus a (completely optional) .txt extension. If you don't want the gene name in the file, use:
awk '{n=$1; $1="";print >> n".txt"}' matrix.txt
And, if your first line is a header, use:
awk 'NR>1{n=$1; $1="";print >> n".txt"}' matrix.txt
Hello priyankaraina10 ,
Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.

Thank you!
Log in to answer this question.
The pasted table format is not correct. it is a matrix