From 2576eaecdeb589fe4bcc06cf99fb2171a8352cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Thu, 10 Dec 2015 09:41:42 +0000 Subject: [PATCH] pairwise_dnds: fix too low values of dn/ds due to zero values (issue #24) When the sequences were the same, both dN and dS would be zero and dn/ds ratio would be 99. The 99 value would shift the mean dn/ds value which would become too high. --- scripts/pairwise_dnds.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/pairwise_dnds.pl b/scripts/pairwise_dnds.pl index 92ba7e4..15c0951 100755 --- a/scripts/pairwise_dnds.pl +++ b/scripts/pairwise_dnds.pl @@ -115,8 +115,16 @@ sub get_dNdS_stats { for my $j (($i +1) .. ($n_seqs -1)) { - push @{$stats->{'dN'}}, $MLmatrix->[$i]->[$j]->{'dN'}; - push @{$stats->{'dS'}}, $MLmatrix->[$i]->[$j]->{'dS'}; + my $dn = $MLmatrix->[$i]->[$j]->{'dN'}; + my $ds = $MLmatrix->[$i]->[$j]->{'dS'}; + + ## Some sequences are exactly the same and will have a dN and + ## dS of zero, which then takes a dn/ds of 99. This is all + ## non-sense so we just skip those cases. See issue #23 + next if $dn == 0 && $ds == 0; + + push @{$stats->{'dN'}}, $dn; + push @{$stats->{'dS'}}, $ds; push @{$stats->{'omega'}}, $MLmatrix->[$i]->[$j]->{'omega'}; # say join("\t", $otus[$i]->display_id, # $otus[$j]->display_id,