Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override void OnHandleCreated(EventArgs e)

private void Settings_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Properties.Settings.Default.CalibrationCurveOptions ))
if (e.PropertyName == nameof(Properties.Settings.Default.CalibrationCurveOptions))
{
Update(DisplaySettings);
}
Expand Down Expand Up @@ -355,6 +355,11 @@ private void DoUpdate(Settings displaySettings)
labelLines.Add(CalibrationCurveMetrics.RSquaredDisplayText(CalibrationCurveMetrics.RSquared.Value));
}

if (CalibrationCurveMetrics.RelativeStandardError.HasValue)
{
labelLines.Add(CalibrationCurveMetrics.RelativeStandardErrorDisplayText(CalibrationCurveMetrics.RelativeStandardError.Value));
}

if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
{
labelLines.Add(string.Format(@"{0}: {1}",
Expand Down Expand Up @@ -406,7 +411,7 @@ private void DoUpdate(Settings displaySettings)
{
ArrowObj arrow = new ArrowObj(xSelected.Value, ySelected.Raw, xSelected.Value,
ySelected.Raw)
{ Line = { Color = GraphSummary.ColorSelected } };
{ Line = { Color = GraphSummary.ColorSelected } };
zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
var verticalLine = new LineObj(xSelected.Value, ySelected.Raw, xSelected.Value,
options.LogYAxis ? minY / 10 : 0)
Expand Down Expand Up @@ -439,7 +444,7 @@ private void DoUpdate(Settings displaySettings)
// If the point has a specified concentration, then use that.
ArrowObj arrow = new ArrowObj(xSpecified.Value, ySelected.Raw, xSpecified.Value,
ySelected.Raw)
{ Line = { Color = GraphSummary.ColorSelected } };
{ Line = { Color = GraphSummary.ColorSelected } };
zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
}
else
Expand Down Expand Up @@ -726,7 +731,7 @@ ToolStripMenuItem excludeStandardMenuItem
menuStrip.Items.Insert(index++, moreDisplayOptionsContextMenuItem);
menuStrip.Items.Insert(index++, new ToolStripSeparator());
}

}
private bool IsEnableIsotopologResponseCurve()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ public CalibrationCurveMetrics ChangeRSquared(double? rSquared)
return ChangeProp(ImClone(this), im => im.RSquared = rSquared);
}

[Format(Formats.Integer, NullValue = TextUtil.EXCEL_NA)]
public int? FittedParameters { get; private set; }
public CalibrationCurveMetrics ChangeFittedParameters(int? fittedParameters)
{
return ChangeProp(ImClone(this), im => im.FittedParameters = fittedParameters);
}

[Format(Formats.Percent, NullValue = TextUtil.EXCEL_NA)]
public double? RelativeStandardError { get; private set; }

public CalibrationCurveMetrics ChangeRelativeStandardError(double? relStdError)
{
return ChangeProp(ImClone(this), im => im.RelativeStandardError = relStdError);
}

public string ErrorMessage { get; private set; }
public CalibrationCurveMetrics ChangeErrorMessage(string errorMessage)
{
Expand Down Expand Up @@ -136,5 +151,11 @@ public static string RSquaredDisplayText(double rSquared)
return QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ +
rSquared.ToString(@"0.####");
}

public static string RelativeStandardErrorDisplayText(double relStdError)
{
return QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_RelativeStandardError +
relStdError.ToString(@"0.##%");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@
<data name="FirstPosition">
<value>最初の位置</value>
</data>
<data name="FittedParameters">
<value>推定パラメータ</value>
</data>
<data name="FoldChange">
<value>倍率変化</value>
</data>
Expand Down Expand Up @@ -1428,6 +1431,9 @@
<data name="RSquared">
<value>R平方</value>
</data>
<data name="RelativeStandardError">
<value>相対標準誤差</value>
</data>
<data name="SampleDilutionFactor">
<value>試料希釈倍数</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@
<data name="FirstPosition">
<value>First Position</value>
</data>
<data name="FittedParameters">
<value>Fitted Parameters</value>
</data>
<data name="FoldChange">
<value>Fold Change</value>
</data>
Expand Down Expand Up @@ -1431,6 +1434,9 @@
<data name="RSquared">
<value>R Squared</value>
</data>
<data name="RelativeStandardError">
<value>Relative Standard Error</value>
</data>
<data name="SampleDilutionFactor">
<value>Sample Dilution Factor</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@
<data name="FirstPosition">
<value>第一个位置</value>
</data>
<data name="FittedParameters">
<value>拟合参数</value>
</data>
<data name="FoldChange">
<value>倍数变化</value>
</data>
Expand Down Expand Up @@ -1428,6 +1431,9 @@
<data name="RSquared">
<value>R 平方</value>
</data>
<data name="RelativeStandardError">
<value>相对标准误差</value>
</data>
<data name="SampleDilutionFactor">
<value>样品稀释因子</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@
<data name="FirstPosition">
<value>ペプチドに含まれるタンパク質シークエンスの最初の(N末端)アミノ酸の位置です。タンパク質シークエンスがない場合には#N/Aとなります。</value>
</data>
<data name="FittedParameters">
<value>検量線において、校正データに適合されたパラメータ(例:傾き、切片)の数。</value>
</data>
<data name="FoldChange">
<value>倍率変化値。倍率変化とは、対照群の正規化強度に対する治療群の正規化強度の比率です。</value>
</data>
Expand Down Expand Up @@ -1451,6 +1454,9 @@
<data name="RSquared">
<value>決定係数</value>
</data>
<data name="RelativeStandardError">
<value>相対標準誤差</value>
</data>
<data name="SampleDilutionFactor">
<value>試料が分析される前に希釈される量です。
外部標準の希釈倍率は一般的に1で、不明の試料は、装置の定量可能範囲に収まるようにするため1を上回る倍率で希釈された可能性があります。</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ to be the Analyte Concentration from the Replicate times the Concentration Multi
<value>The position of the first (N-terminal) amino acid of the peptide within its
containing protein sequence, or #N/A if no protein sequence is available.</value>
</data>
<data name="FittedParameters">
<value>The number of parameters fitted to calibration data in the calibration curve.</value>
</data>
<data name="FoldChange">
<value>The fold change value. The fold change is the ratio of the normalized intensity of the treatment group to the normalized intensity of the control group.</value>
</data>
Expand Down Expand Up @@ -1547,6 +1550,9 @@ retention score calculator, if one is used (e.g. SSRCalc or iRT score)
<data name="RSquared">
<value>Coefficient of determination</value>
</data>
<data name="RelativeStandardError">
<value>Relative Standard Error</value>
</data>
<data name="SampleDilutionFactor">
<value>The amount by which the sample was diluted before being analyzed.
External standards typically have a dilution factor of 1, and unknown samples may have been diluted by a factor greater than 1 in order to bring them into the quantifiable range for the instrument.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@
<value>肽段的第一个 (N-末端) 氨基酸在其包含的蛋白质序列中的位置,
如果没有可用的蛋白质序列,则为 #N/A。</value>
</data>
<data name="FittedParameters">
<value>校准曲线中拟合至校准数据的参数(例如斜率、截距)数量</value>
</data>
<data name="FoldChange">
<value>倍数变化值。倍数变化是试验组的归一化强度与对照组归一化强度的比率。</value>
</data>
Expand Down Expand Up @@ -1530,6 +1533,9 @@
<data name="RSquared">
<value>测定系数</value>
</data>
<data name="RelativeStandardError">
<value>相对标准误差</value>
</data>
<data name="SampleDilutionFactor">
<value>在分析之前稀释样品的量。
外部标准通常具有 1 的稀释因子,并且未知样品可能已被稀释大于 1 的因子,以使它们进入仪器的可量化范围。</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static readonly CalibrationCurve NO_EXTERNAL_STANDARDS

public double? GetY(double? x)
{
return x == null ? (double?) null : GetY(x.Value);
return x == null ? (double?)null : GetY(x.Value);
}
public abstract double GetY(double x);

Expand Down Expand Up @@ -61,13 +61,54 @@ public CalibrationCurveMetrics GetMetrics(IList<WeightedPoint> points)
{
calibrationCurveRow = calibrationCurveRow.ChangeRSquared(rSquared);
}
// Assuming the fields are already populated as needed
double? relStdError = CalculateRelativeStandardError(points, calibrationCurveRow.FittedParameters);
if (relStdError.HasValue)
{
calibrationCurveRow = calibrationCurveRow.ChangeRelativeStandardError(relStdError);
}
}
return calibrationCurveRow;
}

protected abstract CalibrationCurveMetrics CreateCalibrationCurveMetrics();
public abstract override string ToString();

/// <summary>
/// Returns Relative Standard Error (formatted typically as a percent like %RSD).
/// This method uses degrees of freedom (n - p) which depends on the calibration type
/// and which parameters are allowed to be fitted (e.g., intercept forced through 0 or not).
/// </summary>
public virtual double? CalculateRelativeStandardError(IList<WeightedPoint> points, int? fittedParameters)
{
if (!fittedParameters.HasValue)
{
return null;
}
List<double> relativeErrors = new List<double>();
foreach (var point in points)
{
double? xFitted = GetX(point.Y);
if (xFitted.HasValue && point.X != 0 && !double.IsNaN(xFitted.Value))
{
relativeErrors.Add((xFitted.Value - point.X) / point.X);
}

}
if (!relativeErrors.Any())
{
return null;
}
int degreesOfFreedom = relativeErrors.Count - fittedParameters.Value;
if (degreesOfFreedom <= 0)
{
return null;
}
double sumOfSquaresOfResiduals = relativeErrors.Sum(r => r * r);
double relStdError = Math.Sqrt(sumOfSquaresOfResiduals / degreesOfFreedom);
return relStdError;
}

public virtual double? CalculateRSquared(IEnumerable<WeightedPoint> points)
{
List<double> yValues = new List<double>();
Expand Down Expand Up @@ -111,7 +152,11 @@ public override double GetY(double x)

protected override CalibrationCurveMetrics CreateCalibrationCurveMetrics()
{
return new CalibrationCurveMetrics().ChangeSlope(Slope).ChangeIntercept(Intercept);

return new CalibrationCurveMetrics()
.ChangeSlope(Slope)
.ChangeIntercept(Intercept)
.ChangeFittedParameters(1 + (Intercept.HasValue ? 1 : 0));
}

public override string ToString()
Expand Down Expand Up @@ -164,8 +209,11 @@ public override double GetY(double x)

protected override CalibrationCurveMetrics CreateCalibrationCurveMetrics()
{
return new CalibrationCurveMetrics().ChangeIntercept(Intercept).ChangeSlope(Slope)
.ChangeQuadraticCoefficient(QuadraticCoefficient);
return new CalibrationCurveMetrics()
.ChangeIntercept(Intercept)
.ChangeSlope(Slope)
.ChangeQuadraticCoefficient(QuadraticCoefficient)
.ChangeFittedParameters(3); // 2 if intercept forced to 0
}

public override string ToString()
Expand Down Expand Up @@ -213,7 +261,10 @@ public override double GetY(double x)

protected override CalibrationCurveMetrics CreateCalibrationCurveMetrics()
{
return new CalibrationCurveMetrics().ChangeSlope(Slope).ChangeIntercept(Intercept);
return new CalibrationCurveMetrics()
.ChangeSlope(Slope)
.ChangeIntercept(Intercept)
.ChangeFittedParameters(2); // 1 if intercept forced to 0
}

/// <summary>
Expand Down Expand Up @@ -288,8 +339,11 @@ public override double GetY(double x)

protected override CalibrationCurveMetrics CreateCalibrationCurveMetrics()
{
return new CalibrationCurveMetrics().ChangeSlope(Slope).ChangeIntercept(Intercept)
.ChangeTurningPoint(TurningPoint);
return new CalibrationCurveMetrics()
.ChangeSlope(Slope)
.ChangeIntercept(Intercept)
.ChangeTurningPoint(TurningPoint)
.ChangeFittedParameters(3); // Bilinear turning point counts as fitted parameter
}

public override string ToString()
Expand Down Expand Up @@ -323,7 +377,10 @@ public override double GetY(double x)

protected override CalibrationCurveMetrics CreateCalibrationCurveMetrics()
{
return new CalibrationCurveMetrics().ChangeSlope(Slope).ChangePointCount(0);
return new CalibrationCurveMetrics()
.ChangeSlope(Slope)
.ChangePointCount(0)
.ChangeFittedParameters(1); // slope only
}

public override string ToString()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,7 @@
<value>{0} ({1})</value>
<comment>Example: Standard (MyMolecule)</comment>
</data>
<data name="CalibrationForm_DisplayCalibrationCurve_RelativeStandardError" xml:space="preserve">
<value>RSE = </value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,7 @@
<value>{0} ({1})</value>
<comment>Example: Standard (MyMolecule)</comment>
</data>
<data name="CalibrationForm_DisplayCalibrationCurve_RelativeStandardError" xml:space="preserve">
<value>RSE = </value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,7 @@
<value>{0} ({1})</value>
<comment>Example: Standard (MyMolecule)</comment>
</data>
<data name="CalibrationForm_DisplayCalibrationCurve_RelativeStandardError" xml:space="preserve">
<value>RSE = </value>
</data>
</root>
2 changes: 1 addition & 1 deletion pwiz_tools/Skyline/Model/Hibernate/Formats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static class Formats
public const string OneOverK0 = "0.####";
public const string Percent = "0%";
public const string PEAK_SCORE = "0.####";

public const string Integer = "0";
public const string IonMobility = "0.###";
public const string CCS = "0.##";
public const string Skewness = "0.###";
Expand Down
Loading