static List<GenomicBin> RemoveBinsWithExtremeGC(List<GenomicBin> bins, int threshold, NexteraManifest manifest = null)
{
// Will hold outlier-removed bins.
List<GenomicBin> stripped = new List<GenomicBin>();
// used to count the number of bins with each possible GC content (0-100)
int[] counts = new int[EnrichmentUtilities.numberOfGCbins];
double totalCount = 0;
foreach (GenomicBin bin in manifest == null ? bins : EnrichmentUtilities.GetOnTargetBins(bins, manifest))
{
// We only count autosomal bins because these are the ones we computed normalization factor upon.
if (!GenomeMetadata.SequenceMetadata.IsAutosome(bin.Chromosome))
continue;
counts[bin.GC]++;
totalCount++;
}
int averageCountPerGC = Math.Max(minNumberOfBinsPerGCForWeightedMedian, (int)(totalCount / counts.Length));
threshold = Math.Min(threshold, averageCountPerGC);
foreach (GenomicBin bin in bins)
{
// Remove outlier (not a lot of bins with the same GC content)
if (counts[bin.GC] < threshold)
continue;
stripped.Add(bin);
}
return stripped;
}