Skip to content

Commit a8b5aec

Browse files
warrenlrlcoombe
andauthored
Update ntRootAncestryPredictor.pl (#23)
* Update ntRootAncestryPredictor.pl added conditional to capture ND cases * Update ND to Unknown, put N/A in stat columns when ancestry ambiguous --------- Co-authored-by: lcoombe <lauren.e.coombe@gmail.com>
1 parent e0df5f6 commit a8b5aec

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

ntRootAncestryPredictor.pl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
my $verbose = 0;
3030
my $tile_resolution = 0;
3131
my $fai = "";
32+
my $ambiguous_category = "Unknown";
3233

3334
getopts('f:t:v:r:i:');
3435

@@ -159,6 +160,9 @@ sub usage_page {
159160
if($metric>$winmax){
160161
$winmax = $metric;
161162
$winpop = $pp;
163+
}elsif($metric==$winmax){ ###do not assign tiles to a population if ambiguous
164+
$winmax = $metric;
165+
$winpop = $ambiguous_category;
162166
}
163167
}
164168
$top->{$winpop} += $dw;
@@ -217,12 +221,20 @@ sub usage_page {
217221
$rank++;
218222
my $k = $population . "_AF";
219223
my $percent = $top->{$population}/$total *100;
220-
printf OUT "$population\t%.2f%%\t%.4f\t$xr\t$s->{$k}{'ct'}", ($percent, $s->{$k}{'prob'});
224+
if ($population eq $ambiguous_category) {
225+
printf OUT "$population\t%.2f%%\tN/A\t$xr\tN/A", $percent;
226+
} else {
227+
printf OUT "$population\t%.2f%%\t%.4f\t$xr\t$s->{$k}{'ct'}", ($percent, $s->{$k}{'prob'});
228+
}
221229
if ($verbose) {
222-
my $p = $s->{$k}{'sum'}/$xr;
223-
my $c=$s->{$k}{'sum'}/$s->{$k}{'ct'};
224-
my $nzr=$s->{$k}{'ct'}/$xr;
225-
printf OUT "\t%.2f\t%.4f\t%.4f\t%.4f\t%.2f\n", ($s->{$k}{'sum'}, $p, $c, $nzr, $s->{$k}{'fract'});
230+
if ($population eq $ambiguous_category) {
231+
printf OUT "\tN/A\tN/A\tN/A\tN/A\tN/A\n";
232+
} else {
233+
my $p = $s->{$k}{'sum'}/$xr;
234+
my $c=$s->{$k}{'sum'}/$s->{$k}{'ct'};
235+
my $nzr=$s->{$k}{'ct'}/$xr;
236+
printf OUT "\t%.2f\t%.4f\t%.4f\t%.4f\t%.2f\n", ($s->{$k}{'sum'}, $p, $c, $nzr, $s->{$k}{'fract'});
237+
}
226238
} else {
227239
printf OUT "\n";
228240
}

0 commit comments

Comments
 (0)