I have this file (a sparse matrix):PC.354 OTU1 6PC.354 OTU2 1PC.356 OTU0 4PC.356 OTU2 7PC.356 OTU3 3I want an output like this (dense matrix -classic .biom table):OTU_ID PC.354  PC.355  PC.356OTU0   0   0   4OTU1   6   0   0OTU2   1   0   7OTU3   0   0   3How can I do this with awk/perl/sed? I found a similar question about R package (xtabs/tidyr), but I'm not used to it.
Organizing three dimensional data with awk/sed/perl
text processing;awk;sed;perl;bioinformatics
In perl:#!/usr/bin/perlmy (%hotu, %hpc)=();while(<>){  my($pc,$otu,$v)=split;  $hpc{$pc}=1;  ($hotu{$otu} or $hotu{$otu}={})->{$pc}+=$v;}#headersmy @apc = sort keys %hpc;print join (\t, 'OTU_ID', @apc) . \n;#valuesforeach my $otu (sort keys %hotu) {  print join (\t, $otu, map {$_=0 unless defined; $_} @{$hotu{$otu}}{@apc}) . \n;}