CanvasClean.CanvasClean.RemoveBigBins C# (CSharp) Method

RemoveBigBins() static private method

Removes bins that are genomically large. Typically centromeres and other nasty regions.
static private RemoveBigBins ( List bins ) : List
bins List Genomic bins.
return List
        static List<GenomicBin> RemoveBigBins(List<GenomicBin> bins)
        {
            List<int> sizes = new List<int>(bins.Count);

            foreach (GenomicBin bin in bins)
                sizes.Add(bin.Size);

            sizes.Sort();

            // Get the 98th percentile of bin sizes
            int index = (int)(0.98 * (double)bins.Count);
            if (index >= sizes.Count)
            {
                Console.Error.WriteLine("Warning in CanvasClean: Too few bins to do outlier removal");
                return bins;
            }
            int thresh = sizes[index];

            List<GenomicBin> stripped = new List<GenomicBin>();

            // Remove bins whose size is greater than the 98th percentile
            foreach (GenomicBin bin in bins)
            {
                if (bin.Size <= thresh)
                    stripped.Add(bin);
            }
            return stripped;
        }