Skip to content

Commit

Permalink
capping vrf to 0.999 (#575)
Browse files Browse the repository at this point in the history
Co-authored-by: Stromberg, Michael <mstromberg@illumina.com>
  • Loading branch information
2 people authored and GitHub Enterprise committed Dec 11, 2020
1 parent 78cc3c3 commit 19868c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions MitoHeteroplasmy/MitoHeteroplasmyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void Add(int position, string altAllele, double[] vrfs, int[] alleleDepth

if (!_alleleToDistribution.TryGetValue(positionAndAltAlleleIntForm, out (double[] Vrfs, double[] Percentiles) data)) return null;

if (vrf > 0.999) vrf = 0.999;
return PercentileUtilities.GetPercentile(vrf, data.Vrfs, data.Percentiles);
}

Expand Down
17 changes: 17 additions & 0 deletions UnitTests/MitoHeteroplasmy/MitoHeteroplasmyProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,22 @@ public void GetVrfPercentiles_100()
Assert.True(percentilesSample[0].HasValue);
Assert.Equal(100, percentilesSample[0].Value, 2);
}

[Fact]
public void CapVrf()
{
var provider = new MitoHeteroplasmyProvider();
provider.Add(750, "G", new[] { 0.0,0.001,0.002,0.991,0.994,0.995,0.996,0.997,0.998,0.999 }, new[] { 24,4,2,3,2,1,1,4,3,2460});

var chrom = ChromosomeUtilities.ChrM;
var position = 750;
var altAlleles = new[] { "G" };

var percentilesSample = provider.GetVrfPercentiles(chrom, position, altAlleles, new[] { 1.0 });

Assert.Single(percentilesSample);
Assert.True(percentilesSample[0].HasValue);
Assert.Equal(1.76, percentilesSample[0].Value, 2);
}
}
}

0 comments on commit 19868c3

Please sign in to comment.