hello, i have a hash table and i want transform this into an output which i could use in a R script. i use Text::table but i cant find a solution to have a good column separator (tab or pipe) this my code :
my %hash_sample_cds_genotype; my %hash_sample_cds_RT; my %hash_sample_cds_R1; my %hash_sample_cds_R2; #String des fichiers inputs foreach my $fichier (@fichiers) { my $sample_name; #alimentation du hash de resultat avec cette echatillon open(RESULTAT,"<$fichier") or die ("Cannot open $fichier\n"); while (defined(my $_ = <RESULTAT>)) { $sample_name = $fichier; my @attribut_name = split(m/out_/,$sample_name); $sample_name = $attribut_name[1]; my @resutat_infos = split(m/\t/,$_); next if ($_ =~ m/^CDS/); chomp($_); my $cds = $resutat_infos[0]; my $genotype = $resutat_infos[1]."/".$resutat_infos[2]; my $reads_p1 =$resutat_infos[3]; my $reads_p2 =$resutat_infos[4]; my $reads_totaux =$resutat_infos[6]; $hash_sample_cds_genotype{$sample_name}{$cds} = $genotype ; $hash_sample_cds_RT{$sample_name}{$cds} = $reads_p1 ; $hash_sample_cds_R1{$sample_name}{$cds} = $reads_p2 ; $hash_sample_cds_R2{$sample_name}{$cds} = $reads_totaux ; } close(RESULTAT); } #alimentation des fichier de resultats GENOTYPE my @cols1 = sort keys (%hash_sample_cds_genotype ); my @rows1 = sort keys % { { map { my $x = $_; map { $_ => undef } keys $hash_sample_cds_genotype{$x} } @cols1 } }; my $out1 = Text::Table->new(' ', @cols1); for my $r1 (@rows1) { $out1->add($r1, map $hash_sample_cds_genotype{$_}{$r1} // 'NA', @c +ols1); } print OUTPUT1 $out1;
Any idea ?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |