Skip to content

Commit 19868c3

Browse files
rajatshuvroStromberg, Michael
authored and
GitHub Enterprise
committed
capping vrf to 0.999 (#575)
Co-authored-by: Stromberg, Michael <[email protected]>
1 parent 78cc3c3 commit 19868c3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

MitoHeteroplasmy/MitoHeteroplasmyProvider.cs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void Add(int position, string altAllele, double[] vrfs, int[] alleleDepth
5252

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

55+
if (vrf > 0.999) vrf = 0.999;
5556
return PercentileUtilities.GetPercentile(vrf, data.Vrfs, data.Percentiles);
5657
}
5758

UnitTests/MitoHeteroplasmy/MitoHeteroplasmyProviderTests.cs

+17
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,22 @@ public void GetVrfPercentiles_100()
9696
Assert.True(percentilesSample[0].HasValue);
9797
Assert.Equal(100, percentilesSample[0].Value, 2);
9898
}
99+
100+
[Fact]
101+
public void CapVrf()
102+
{
103+
var provider = new MitoHeteroplasmyProvider();
104+
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});
105+
106+
var chrom = ChromosomeUtilities.ChrM;
107+
var position = 750;
108+
var altAlleles = new[] { "G" };
109+
110+
var percentilesSample = provider.GetVrfPercentiles(chrom, position, altAlleles, new[] { 1.0 });
111+
112+
Assert.Single(percentilesSample);
113+
Assert.True(percentilesSample[0].HasValue);
114+
Assert.Equal(1.76, percentilesSample[0].Value, 2);
115+
}
99116
}
100117
}

0 commit comments

Comments
 (0)