private HalfLifeSettings GetHalfLifeSettingsFromUi(HalfLifeSettings value) { value.NewlySynthesizedTracerQuantity = radioLabeledAminoAcid.Checked ? TracerQuantity.LabeledAminoAcid : radioLabelDistribution.Checked ? TracerQuantity.PartialLabelDistribution : radioUnlabeledPeptide.Checked ? TracerQuantity.UnlabeledPeptide : 0; value.InitialPrecursorPool = HalfLifeSettings.TryParseDouble(tbxInitialPrecursorPool.Text, 0); value.CurrentPrecursorPool = HalfLifeSettings.TryParseDouble(tbxCurrentPrecursorPool.Text, 0); value.PrecursorPoolCalculation = radioFixedPrecursorPool.Checked ? PrecursorPoolCalculation.Fixed : radioUseMedianPrecursorPool.Checked ? PrecursorPoolCalculation.MedianPerSample : radioIndividualPrecursorPool.Checked ? PrecursorPoolCalculation.Individual : 0; value.MinimumAuc = HalfLifeSettings.TryParseDouble(tbxMinAuc.Text, 0); value.MinimumDeconvolutionScore = HalfLifeSettings.TryParseDouble(tbxMinimumDeconvolutionScore.Text, 0); value.MinimumTurnoverScore = HalfLifeSettings.TryParseDouble(tbxMinTurnoverScore.Text, 0); value.EvviesFilter = (EvviesFilterEnum)comboEvviesFilter.SelectedIndex; value.ForceThroughOrigin = cbxForceThroughOrigin.Checked; value.SimpleLinearRegression = cbxSimpleLinearRegression.Checked; return(value); }
private bool IsIncluded(HalfLifeSettings halfLifeSettings, PeptideFileAnalysis peptideFileAnalysis) { if (!string.IsNullOrEmpty(Cohort)) { if (Cohort != HalfLifeCalculator.GetCohort(peptideFileAnalysis.MsDataFile, GetHalfLifeSettings().BySample)) { return(false); } } if (peptideFileAnalysis.MsDataFile.TimePoint == null) { return(false); } if (IsTimePointExcluded(peptideFileAnalysis.MsDataFile.TimePoint.Value)) { return(false); } if (halfLifeSettings.PrecursorPoolCalculation == PrecursorPoolCalculation.Individual) { if (null == peptideFileAnalysis.CalculatedPeaks || !peptideFileAnalysis.CalculatedPeaks.Turnover.HasValue) { return(false); } } return(true); }
public HalfLifeSettings GetHalfLifeSettings(HalfLifeSettings halfLifeSettings) { var tracerDef = GetTracerDefs().FirstOrDefault(); if (tracerDef != null) { halfLifeSettings.InitialPrecursorPool = tracerDef.InitialApe; halfLifeSettings.CurrentPrecursorPool = tracerDef.FinalApe; } return(halfLifeSettings); }
private void UpdateSettings(object sender, EventArgs e) { HalfLifeSettings = GetHalfLifeSettingsFromUi(HalfLifeSettings); }
private HalfLifeCalculator UpdateGraph(List <PeptideFileAnalysis> peptideFileAnalyses, HalfLifeSettings halfLifeSettings, out HalfLifeCalculator.ResultData resultData) { var halfLifeCalculator = new HalfLifeCalculator(Workspace, halfLifeSettings); var halfLife = resultData = halfLifeCalculator.CalculateHalfLife(peptideFileAnalyses); _zedGraphControl.GraphPane.CurveList.Clear(); _zedGraphControl.GraphPane.GraphObjList.Clear(); _pointsCurve = null; _peptideFileAnalysisPoints = null; var xValues = new List <double>(); var yValues = new List <double>(); var fileAnalysisPoints = new List <PeptideFileAnalysis>(); var filteredFileAnalysisIds = new HashSet <long>(resultData.FilteredRowDatas.Select(rd => rd.RawRowData.PeptideFileAnalysisId)); foreach (var peptideFileAnalysis in peptideFileAnalyses) { if (!filteredFileAnalysisIds.Contains(peptideFileAnalysis.Id)) { continue; } double?value; var processedRowData = halfLifeCalculator.ToRowData(peptideFileAnalysis); if (!processedRowData.Turnover.HasValue) { continue; } if (LogPlot) { value = 2 - Math.Log10(100 - processedRowData.Turnover.Value * 100); } else { value = processedRowData.Turnover.Value * 100; } if (double.IsInfinity(value.Value) || double.IsNaN(value.Value)) { continue; } Debug.Assert(peptideFileAnalysis.MsDataFile.TimePoint != null); xValues.Add(peptideFileAnalysis.MsDataFile.TimePoint.Value); yValues.Add(value.Value); fileAnalysisPoints.Add(peptideFileAnalysis); } UpdateStatsGrid(xValues, yValues); var pointsCurve = _zedGraphControl.GraphPane.AddCurve("Data Points", xValues.ToArray(), yValues.ToArray(), Color.Black); pointsCurve.Line.IsVisible = false; pointsCurve.Label.IsVisible = false; Func <double, double> funcMiddle = x => halfLife.YIntercept + halfLife.RateConstant * x; Func <double, double> funcMin = x => halfLife.YIntercept + (halfLife.RateConstant - halfLife.RateConstantError) * x; Func <double, double> funcMax = x => halfLife.YIntercept + (halfLife.RateConstant + halfLife.RateConstantError) * x; Func <double, double> funcConvertToDisplayedValue; if (LogPlot) { _zedGraphControl.GraphPane.YAxis.Title.Text = "-Log(100% - % Newly Synthesized)"; funcConvertToDisplayedValue = x => - x / Math.Log(10); } else { _zedGraphControl.GraphPane.YAxis.Title.Text = "% Newly Synthesized"; funcConvertToDisplayedValue = x => (1 - Math.Exp(x)) * 100; } // ReSharper disable ImplicitlyCapturedClosure AddFunction("Best Fit", x => funcConvertToDisplayedValue(funcMiddle(x)), Color.Black); AddFunction("Minimum Bound", x => funcConvertToDisplayedValue(funcMin(x)), Color.LightBlue); AddFunction("Maximum Bound", x => funcConvertToDisplayedValue(funcMax(x)), Color.LightGreen); // ReSharper restore ImplicitlyCapturedClosure _zedGraphControl.GraphPane.AxisChange(); _zedGraphControl.Invalidate(); _pointsCurve = pointsCurve; _peptideFileAnalysisPoints = fileAnalysisPoints; tbxRateConstant.Text = resultData.RateConstant.ToString("0.##E0") + "+/-" + resultData.RateConstantError.ToString("0.##E0"); tbxHalfLife.Text = resultData.HalfLife.ToString("0.##") + "(" + resultData.MinHalfLife.ToString("0.##") + "-" + resultData.MaxHalfLife.ToString("0.##") + ")"; if (resultData.RSquared.HasValue) { tbxCorrelationCoefficient.Text = Math.Sqrt(resultData.RSquared.Value).ToString(CultureInfo.InvariantCulture); } else { tbxCorrelationCoefficient.Text = ""; } return(halfLifeCalculator); }
public void SetHalfLifeSettings(HalfLifeSettings halfLifeSettings) { cbxBySample.Checked = halfLifeSettings.BySample; halfLifeSettingsControl.HalfLifeSettings = halfLifeSettings; UpdateRows(true); }