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;
}