Esempio n. 1
0
        private void ConfirmPeak(Peak p, List <AnalysisResult <Peak, Metadata> .SupportingPeak> supportingPeaks)
        {
            var anRe = new AnalysisResult <Peak, Metadata> .ProcessedPeak()
            {
                peak            = p,
                xSquared        = tXsqrd,
                rtp             = ChiSquaredCache.ChiSqrdDistRTP(tXsqrd, 2 + (supportingPeaks.Count * 2)),
                supportingPeaks = supportingPeaks
            };

            if (p.metadata.value <= Options.tauS)
            {
                analysisResults.R_j___sc[chrTitle]++;
                anRe.classification = PeakClassificationType.StringentConfirmed;
            }
            else
            {
                analysisResults.R_j___wc[chrTitle]++;
                anRe.classification = PeakClassificationType.WeakConfirmed;
            }

            if (!analysisResults.R_j__c[chrTitle].ContainsKey(p.metadata.hashKey))
            {
                analysisResults.R_j__c[chrTitle].Add(p.metadata.hashKey, anRe);
            }

            ConfirmeSupportingPeaks(p, supportingPeaks);
        }
Esempio n. 2
0
        private void DiscardSupportingPeaks(Peak p, List <AnalysisResult <Peak, Metadata> .SupportingPeak> supportingPeaks, byte discardReason)
        {
            foreach (var supPeak in supportingPeaks)
            {
                if (!Data <Peak, Metadata> .analysisResults[supPeak.sampleIndex].R_j__d[chrTitle].ContainsKey(supPeak.peak.metadata.hashKey))
                {
                    var tSupPeak     = new List <AnalysisResult <Peak, Metadata> .SupportingPeak>();
                    var targetSample = Data <Peak, Metadata> .analysisResults[supPeak.sampleIndex];
                    tSupPeak.Add(new AnalysisResult <Peak, Metadata> .SupportingPeak()
                    {
                        peak = p, sampleIndex = sampleHashKey
                    });

                    foreach (var sP in supportingPeaks)
                    {
                        if (supPeak.CompareTo(sP) != 0)
                        {
                            tSupPeak.Add(sP);
                        }
                    }

                    var anRe = new AnalysisResult <Peak, Metadata> .ProcessedPeak()
                    {
                        peak            = supPeak.peak,
                        xSquared        = tXsqrd,
                        reason          = discardReason,
                        rtp             = ChiSquaredCache.ChiSqrdDistRTP(tXsqrd, 2 + (supportingPeaks.Count * 2)),
                        supportingPeaks = tSupPeak
                    };


                    if (supPeak.peak.metadata.value <= Options.tauS)
                    {
                        targetSample.R_j__sdt[chrTitle]++;
                        anRe.classification = PeakClassificationType.StringentDiscarded;
                    }
                    else
                    {
                        targetSample.R_j__wdt[chrTitle]++;
                        anRe.classification = PeakClassificationType.WeakDiscarded;
                    }

                    targetSample.R_j__d[chrTitle].Add(supPeak.peak.metadata.hashKey, anRe);
                }
            }
        }
Esempio n. 3
0
        public void Run(AnalysisOptions options)
        {
            Options.replicateType         = options.replicateType;
            Options.C                     = options.C;
            Options.tauS                  = options.tauS;
            Options.tauW                  = options.tauW;
            Options.gamma                 = options.gamma;
            Options.alpha                 = options.alpha;
            Options.multipleIntersections = options.multipleIntersections;

            Data <Peak, Metadata> .cachedChiSqrd = new List <double>();
            for (int i = 1; i <= Data <Peak, Metadata> .sampleKeys.Count; i++)
            {
                Data <Peak, Metadata> .cachedChiSqrd.Add(Math.Round(ChiSquaredCache.ChiSqrdINVRTP(Options.gamma, (byte)(i * 2)), 3));
            }

            Data <Peak, Metadata> .BuildSharedItems();

            processor = new Processor <Peak, Metadata>();

            #region .::.    Status      .::.
            int totalSteps  = Data <Peak, Metadata> .sampleKeys.Count + 3;
            int stepCounter = 0;
            #endregion

            Console.WriteLine("");
            foreach (var sampleKey in Data <Peak, Metadata> .sampleKeys)
            {
                var sample = Samples <Peak, Metadata> .Data[sampleKey.Key];

                #region .::.    Status      .::.
                if (sampleKey.Value.Length > 36)
                {
                    Console.Write("\r[" + (++stepCounter).ToString() + "\\" + totalSteps + "] processing sample: ..." + sampleKey.Value.Substring(sampleKey.Value.Length - 35, 35));
                }
                else
                {
                    Console.Write("\r[" + (++stepCounter).ToString() + "\\" + totalSteps + "] processing sample: " + sampleKey.Value);
                }
                Console.WriteLine("");
                #endregion

                foreach (var chr in sample.intervals)
                {
                    foreach (var strand in chr.Value)
                    {
                        int currentLineCursor = Console.CursorTop;
                        Console.SetCursorPosition(0, Console.CursorTop);
                        Console.Write(new string(' ', Console.WindowWidth));
                        Console.SetCursorPosition(0, currentLineCursor);
                        Console.Write("\r .::. Processing {0}", chr.Key);

                        processor.Run(sampleKey.Key, chr.Key, strand.Key);
                    }
                }
            }

            #region .::.    Status      .::.
            Console.Write("\r[" + (++stepCounter).ToString() + "\\" + totalSteps + "] Purifying intermediate sets.");
            #endregion
            processor.IntermediateSetsPurification();

            #region .::.    Status      .::.
            Console.WriteLine("[" + (++stepCounter).ToString() + "\\" + totalSteps + "] Creating output set.");
            #endregion
            processor.CreateOuputSet();

            #region .::.    Status      .::.
            Console.WriteLine("[" + stepCounter + "\\" + totalSteps + "] Performing Multiple testing correction.");
            #endregion
            processor.EstimateFalseDiscoveryRate();
        }