CanvasClean.CanvasClean.RemoveOutliers C# (CSharp) Метод

RemoveOutliers() статический приватный Метод

Removes point outliers from the dataset.
static private RemoveOutliers ( List bins ) : List
bins List Genomic bins.
Результат List
        static List<GenomicBin> RemoveOutliers(List<GenomicBin> bins)
        {
            List<GenomicBin> stripped = new List<GenomicBin>();

            // Check each point to see if it is different than both the point to left and the point to the right
            for (int binIndex = 0; binIndex < bins.Count; binIndex++)
            {
                bool hasPreviousBin = binIndex > 0;
                bool hasNextBin = binIndex < bins.Count - 1;
                string currentBinChromosome = bins[binIndex].Chromosome;
                string previousBinChromosome = hasPreviousBin ? bins[binIndex - 1].Chromosome : null;
                string nextBinChromosome = hasNextBin ? bins[binIndex + 1].Chromosome : null;
                // Different chromosome on both sides
                if ((hasPreviousBin && !currentBinChromosome.Equals(previousBinChromosome))
                    && (hasNextBin && !currentBinChromosome.Equals(nextBinChromosome)))
                    continue;
                // Same chromosome on at least on side or it's the only bin
                if ((hasPreviousBin && bins[binIndex].Chromosome.Equals(previousBinChromosome) && !SignificantlyDifferent(bins[binIndex].Count, bins[binIndex - 1].Count))
                    || (hasNextBin && bins[binIndex].Chromosome.Equals(nextBinChromosome) && !SignificantlyDifferent(bins[binIndex].Count, bins[binIndex + 1].Count))
                    || (!hasPreviousBin && !hasNextBin))
                {
                    stripped.Add(bins[binIndex]);
                }
            }

            return stripped;
        }