CanvasClean.CanvasClean.RemoveBinsWithExtremeGC C# (CSharp) Method

RemoveBinsWithExtremeGC() static private method

Remove bins with extreme GC content.
static private RemoveBinsWithExtremeGC ( List bins, int threshold, NexteraManifest manifest = null ) : List
bins List Genomic bins in from which we filter out GC content outliers.
threshold int Minimum number of bins with the same GC content required to keep a bin.
manifest NexteraManifest
return List
        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;
        }