コード例 #1
0
        /// <summary>
        /// Default constructor for use in matching features.  Uses passed parameters to calculate desired results.
        /// </summary>
        /// <param name="observedFeatureList">List of features observed in an analysis.  Generally UMC or UMCCluster.</param>
        /// <param name="targetFeatureList">List of features to be matched to.  Generally AMTTags.</param>
        /// <param name="matchParameters">FeatureMatcherParameters object containing initial parameters and algorithm settings.</param>
        public FeatureMatcher(List <TObserved> observedFeatureList, List <TTarget> targetFeatureList, FeatureMatcherParameters matchParameters)
        {
            Clear();

            m_observedFeatureList = observedFeatureList;
            m_targetFeatureList   = targetFeatureList;
            m_matchParameters     = matchParameters;
        }
コード例 #2
0
        /// <summary>
        /// Does a zero mean drift time correction.
        /// </summary>
        /// <param name="observedEnumerable">All observed features to shift that should already be drift time aligned.</param>
        /// <param name="targetEnumerable">Expected features</param>
        /// <param name="massTolerance">PPM Mass Tolerance</param>
        /// <param name="netTolerance">Normalized Elution Time tolerance.</param>
        /// <param name="driftTimeTolerance">Drift time tolerance to use.</param>
        public static DriftTimeAlignmentResults <TTarget, TObserved> CorrectForOffset(IEnumerable <TTarget> observedEnumerable, IEnumerable <TObserved> targetEnumerable, double massTolerance, double netTolerance, double driftTimeTolerance)
        {
            // Setup Tolerance for Feature Matching
            var featureMatcherParameters = new FeatureMatcherParameters();

            featureMatcherParameters.SetTolerances(massTolerance, netTolerance, (float)driftTimeTolerance);
            featureMatcherParameters.UseDriftTime = true;

            // Find all matches based on defined tolerances
            var featureMatcher = new FeatureMatcher.FeatureMatcher <TTarget, TObserved>(observedEnumerable.ToList(), targetEnumerable.ToList(), featureMatcherParameters);
            var matchList      = featureMatcher.FindMatches(observedEnumerable.ToList(), targetEnumerable.ToList(), featureMatcherParameters.UserTolerances, 0);

            // Create List of Drift Time differences
            var differenceList = new List <double>(matchList.Count);

            foreach (var featureMatch in matchList)
            {
                var observedFeature = featureMatch.ObservedFeature;
                var targetFeature   = featureMatch.TargetFeature;

                double observedDriftTime;
                if (observedFeature.DriftTimeAligned != double.NaN && observedFeature.DriftTimeAligned > 0.0)
                {
                    observedDriftTime = observedFeature.DriftTimeAligned;
                }
                else
                {
                    observedDriftTime = observedFeature.DriftTime;
                }

                double targetDriftTime;
                if (!double.IsNaN(targetFeature.DriftTimeAligned) && targetFeature.DriftTimeAligned > 0.0)
                {
                    targetDriftTime = targetFeature.DriftTimeAligned;
                }
                else
                {
                    targetDriftTime = targetFeature.DriftTime;
                }

                differenceList.Add(observedDriftTime - targetDriftTime);
            }

            // Create bins for histogram
            var bins = new List <double>();

            for (var i = -driftTimeTolerance; i <= driftTimeTolerance; i += (driftTimeTolerance / 100.0))
            {
                bins.Add(i);
            }
            bins.Add(driftTimeTolerance);

            // Group drift time differences into the bins
            var groupings = differenceList.GroupBy(difference => bins.First(bin => bin >= difference));

            // Order the groupings by their count, so the group with the highest count will be first
            var orderGroupingsByCount = from singleGroup in groupings
                                        orderby singleGroup.Count() descending
                                        select singleGroup;

            // Grab the drift time from the group with the most counts
            var driftTimeOffset = orderGroupingsByCount.First().Key;

            // Update all of the observed features with the new drift time
            foreach (var observedFeature in observedEnumerable)
            {
                if (!double.IsNaN(observedFeature.DriftTimeAligned) && observedFeature.DriftTimeAligned > 0.0)
                {
                    observedFeature.DriftTimeAligned -= driftTimeOffset;
                }
                else
                {
                    observedFeature.DriftTime -= (float)driftTimeOffset;
                }
            }

            var linearEquation = new LinearRegressionResult {
                Slope = 0, Intercept = driftTimeOffset
            };
            var results = new DriftTimeAlignmentResults <TTarget, TObserved>(matchList, linearEquation);

            return(results);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: msdna/MultiAlign
 private static void WriteOptionsToLogFile(FeatureMatcherParameters featureMatcherParameters)
 {
     Logger.PrintMessage("STAC Options");
         Logger.PrintMessage(string.Format("\tUse Drift Time:{0}", featureMatcherParameters.UseDriftTime));
         Logger.PrintMessage(string.Format("\tHistgoram Width:{0}", featureMatcherParameters.HistogramBinWidth));
         Logger.PrintMessage(string.Format("\tHistogram Multiplier:{0}", featureMatcherParameters.HistogramMultiplier));
         Logger.PrintMessage(string.Format("\tShift Amount:{0}", featureMatcherParameters.ShiftAmount));
         Logger.PrintMessage(string.Format("\tShouldCalculateHistogramFDR:{0}", featureMatcherParameters.ShouldCalculateHistogramFDR));
         Logger.PrintMessage(string.Format("\tShouldCalculateSLiC:{0}", featureMatcherParameters.ShouldCalculateSLiC));
         Logger.PrintMessage(string.Format("\tShouldCalculateSTAC:{0}", featureMatcherParameters.ShouldCalculateSTAC));
         Logger.PrintMessage(string.Format("\tShouldCalculateShiftFDR:{0}", featureMatcherParameters.ShouldCalculateShiftFDR));
         Logger.PrintMessage(string.Format("\tUseEllipsoid:{0}", featureMatcherParameters.UseEllipsoid));
         Logger.PrintMessage(string.Format("\tUsePriors:{0}", featureMatcherParameters.UsePriors));
         Logger.PrintMessage(string.Format("\tUserTolerances.MassTolerancePPM:{0}", featureMatcherParameters.UserTolerances.MassTolerancePPM));
         Logger.PrintMessage(string.Format("\tUserTolerances.NETTolerance:{0}", featureMatcherParameters.UserTolerances.NETTolerance));
         Logger.PrintMessage(string.Format("\tUserTolerances.DriftTimeTolerance:{0}", featureMatcherParameters.UserTolerances.DriftTimeTolerance));
 }