コード例 #1
0
ファイル: RetentionTimeValues.cs プロジェクト: zrolfs/pwiz
        public RetentionTimeValues Scale(IRegressionFunction regressionFunction)
        {
            if (null == regressionFunction)
            {
                return(this);
            }
            double startRetentionTime = regressionFunction.GetY(StartRetentionTime);
            double endRetentionTime   = regressionFunction.GetY(EndRetentionTime);
            double retentionTime      = regressionFunction.GetY(RetentionTime);
            double?fwhm;

            if (Fwhm.HasValue)
            {
                double t1 = regressionFunction.GetY(RetentionTime - Fwhm.Value / 2);
                double t2 = regressionFunction.GetY(RetentionTime + Fwhm.Value / 2);
                fwhm = t2 - t1;
            }
            else
            {
                fwhm = null;
            }
            return(new RetentionTimeValues
            {
                RetentionTime = retentionTime,
                StartRetentionTime = startRetentionTime,
                EndRetentionTime = endRetentionTime,
                Fwhm = fwhm,
            });
        }
コード例 #2
0
        public RetentionTimeValues Scale(IRegressionFunction regressionFunction)
        {
            if (null == regressionFunction)
            {
                return(this);
            }
            double startRetentionTime = regressionFunction.GetY(StartRetentionTime);
            double endRetentionTime   = regressionFunction.GetY(EndRetentionTime);
            double retentionTime      = regressionFunction.GetY(RetentionTime);
            double?fwhm;

            if (Fwhm.HasValue)
            {
                double t1 = regressionFunction.GetY(RetentionTime - Fwhm.Value / 2);
                double t2 = regressionFunction.GetY(RetentionTime + Fwhm.Value / 2);
                fwhm = t2 - t1;
            }
            else
            {
                fwhm = null;
            }

            return(ChangeProp(ImClone(this), im =>
            {
                im.RetentionTime = retentionTime;
                im.StartRetentionTime = startRetentionTime;
                im.EndRetentionTime = endRetentionTime;
                im.Fwhm = fwhm;
            }));
        }
コード例 #3
0
        private static void AddRetentionTimesToDict(IRetentionTimeProvider retentionTimes,
                                                    IRegressionFunction regressionLine,
                                                    IDictionary <Target, IrtPeptideAverages> dictPeptideAverages,
                                                    IEnumerable <DbIrtPeptide> standardPeptideList)
        {
            var setStandards = new TargetMap <bool>(standardPeptideList.Select(peptide => new KeyValuePair <Target, bool>(peptide.Target, true)));

            foreach (var pepTime in retentionTimes.PeptideRetentionTimes.Where(p => !setStandards.ContainsKey(p.PeptideSequence)))
            {
                var peptideModSeq = pepTime.PeptideSequence;
                var timeSource    = retentionTimes.GetTimeSource(peptideModSeq);
                var irt           = regressionLine.GetY(pepTime.RetentionTime);
                if (!dictPeptideAverages.TryGetValue(peptideModSeq, out var pepAverage))
                {
                    dictPeptideAverages.Add(peptideModSeq, new IrtPeptideAverages(peptideModSeq, irt, timeSource));
                }
                else
                {
                    pepAverage.AddIrt(irt);
                }
            }
        }
コード例 #4
0
ファイル: RTReplicateGraphPane.cs プロジェクト: zrolfs/pwiz
            private PointPair CalculatePointPair <TChromInfoData>(int iResult, IEnumerable <TChromInfoData> chromInfoDatas, Func <TChromInfoData, RetentionTimeValues?> getRetentionTimeValues)
                where TChromInfoData : ChromInfoData
            {
                var startTimes     = new List <double>();
                var endTimes       = new List <double>();
                var retentionTimes = new List <double>();
                var fwhms          = new List <double>();

                foreach (var chromInfoData in chromInfoDatas)
                {
                    var retentionTimeValues = getRetentionTimeValues(chromInfoData).GetValueOrDefault();
                    IRegressionFunction regressionFunction = null;
                    if (null != RetentionTimeTransform.RtTransformOp)
                    {
                        RetentionTimeTransform.RtTransformOp.TryGetRegressionFunction(chromInfoData.ChromFileInfo.FileId, out regressionFunction);
                    }
                    if (regressionFunction == null)
                    {
                        startTimes.Add(retentionTimeValues.StartRetentionTime);
                        endTimes.Add(retentionTimeValues.EndRetentionTime);
                        retentionTimes.Add(retentionTimeValues.RetentionTime);
                        fwhms.Add(retentionTimeValues.Fwhm ?? 0);
                    }
                    else
                    {
                        startTimes.Add(regressionFunction.GetY(retentionTimeValues.StartRetentionTime));
                        endTimes.Add(regressionFunction.GetY(retentionTimeValues.EndRetentionTime));
                        retentionTimes.Add(regressionFunction.GetY(retentionTimeValues.RetentionTime));
                        if (retentionTimeValues.Fwhm.HasValue)
                        {
                            fwhms.Add(regressionFunction.GetY(retentionTimeValues.RetentionTime +
                                                              retentionTimeValues.Fwhm.Value / 2)
                                      -
                                      regressionFunction.GetY(retentionTimeValues.RetentionTime -
                                                              retentionTimeValues.Fwhm.Value / 2));
                        }
                        else
                        {
                            fwhms.Add(0);
                        }
                    }
                }
                if (RTPeptideValue.All == RTPeptideGraphPane.RTValue)
                {
                    var point = HiLowMiddleErrorBarItem.MakePointPair(iResult,
                                                                      new Statistics(endTimes).Mean(),
                                                                      new Statistics(startTimes).Mean(),
                                                                      new Statistics(retentionTimes).Mean(),
                                                                      new Statistics(fwhms).Mean());
                    return(point.IsInvalid ? PointPairMissing(iResult) : point);
                }
                IEnumerable <double> values;

                switch (RTPeptideGraphPane.RTValue)
                {
                case RTPeptideValue.FWB:
                    values = startTimes.Select((startTime, index) => endTimes[index] - startTime);
                    break;

                case RTPeptideValue.FWHM:
                    values = fwhms;
                    break;

                default:
                    values = retentionTimes;
                    break;
                }
                return(RetentionTimeTransform.AggregateOp.MakeBarValue(iResult, values));
            }
コード例 #5
0
 public RetentionTimeValues Scale(IRegressionFunction regressionFunction)
 {
     if (null == regressionFunction)
     {
         return this;
     }
     double startRetentionTime = regressionFunction.GetY(StartRetentionTime);
     double endRetentionTime = regressionFunction.GetY(EndRetentionTime);
     double retentionTime = regressionFunction.GetY(RetentionTime);
     double? fwhm;
     if (Fwhm.HasValue)
     {
         double t1 = regressionFunction.GetY(RetentionTime - Fwhm.Value/2);
         double t2 = regressionFunction.GetY(RetentionTime + Fwhm.Value/2);
         fwhm = t2 - t1;
     }
     else
     {
         fwhm = null;
     }
     return new RetentionTimeValues
         {
             RetentionTime = retentionTime,
             StartRetentionTime = startRetentionTime,
             EndRetentionTime = endRetentionTime,
             Fwhm = fwhm,
         };
 }