Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated PEP to use set seed (42) #2408

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MetaMorpheus/CMD/CMD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.ML.CpuMath" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="mzLib" Version="1.0.551" />
<PackageReference Include="mzLib" Version="1.0.552" />
<PackageReference Include="Nett" Version="0.15.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/EngineLayer/EngineLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.ML.CpuMath" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="mzLib" Version="1.0.551" />
<PackageReference Include="mzLib" Version="1.0.552" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
11 changes: 11 additions & 0 deletions MetaMorpheus/EngineLayer/FdrAnalysis/FdrInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,16 @@ public class FdrInfo
public double QValueNotch { get; set; }
public double PEP { get; set; }
public double PEP_QValue { get; set; }

/// <summary>
/// Creates a new FdrInfo object where Q-Values and PEP_Qvalues are set to 2 by default
/// This is done to avoid situations where q-values aren't calcualted for a given peptides, but it is still
/// reported in the final results.
/// </summary>
public FdrInfo()
{
QValue = 2;
PEP_QValue = 2;
}
}
}
25 changes: 23 additions & 2 deletions MetaMorpheus/EngineLayer/FdrAnalysis/PEPAnalysisEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ namespace EngineLayer
{
public class PepAnalysisEngine
{
private int _randomSeed = 42;

/// <summary>
/// This method contains the hyper-parameters that will be used when training the machine learning model
/// </summary>
/// <returns> Options object to be passed in to the FastTree constructor </returns>
public Microsoft.ML.Trainers.FastTree.FastTreeBinaryTrainer.Options BGDTreeOptions =>
new Microsoft.ML.Trainers.FastTree.FastTreeBinaryTrainer.Options
{
NumberOfThreads = 1,
NumberOfTrees = 400,
MinimumExampleCountPerLeaf = 10,
NumberOfLeaves = 20,
LearningRate = 0.2,
LabelColumnName = "Label",
FeatureColumnName = "Features",
Seed = _randomSeed,
FeatureSelectionSeed = _randomSeed,
RandomStart = false
};

private static readonly double AbsoluteProbabilityThatDistinguishesPeptides = 0.05;

//These two dictionaries contain the average and standard deviations of hydrophobicitys measured in 1 minute increments accross each raw
Expand Down Expand Up @@ -105,10 +126,10 @@ public string ComputePEPValuesForAllPSMs()
}
}

MLContext mlContext = new MLContext();
MLContext mlContext = new MLContext(seed: _randomSeed);
TransformerChain<BinaryPredictionTransformer<Microsoft.ML.Calibrators.CalibratedModelParametersBase<Microsoft.ML.Trainers.FastTree.FastTreeBinaryModelParameters, Microsoft.ML.Calibrators.PlattCalibrator>>>[] trainedModels = new TransformerChain<BinaryPredictionTransformer<Microsoft.ML.Calibrators.CalibratedModelParametersBase<Microsoft.ML.Trainers.FastTree.FastTreeBinaryModelParameters, Microsoft.ML.Calibrators.PlattCalibrator>>>[numGroups];

var trainer = mlContext.BinaryClassification.Trainers.FastTree(labelColumnName: "Label", featureColumnName: "Features", numberOfTrees: 400);
var trainer = mlContext.BinaryClassification.Trainers.FastTree(BGDTreeOptions);
var pipeline = mlContext.Transforms.Concatenate("Features", TrainingVariables)
.Append(trainer);

Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/GUI/GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<PackageReference Include="Microsoft.ML.CpuMath" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="mzLib" Version="1.0.551" />
<PackageReference Include="mzLib" Version="1.0.552" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/GuiFunctions/GuiFunctions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="itext7" Version="8.0.5" />
<PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.5" />
<PackageReference Include="mzLib" Version="1.0.551" />
<PackageReference Include="mzLib" Version="1.0.552" />
<PackageReference Include="OxyPlot.Wpf" Version="2.0.0" />
<PackageReference Include="Svg" Version="3.4.7" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private void CalculatePsmAndPeptideFdr(List<SpectralMatch> psms, string analysis
// this could cause weird PSM FDR issues

Status("Estimating PSM FDR...", Parameters.SearchTaskId);
new FdrAnalysisEngine(psms, Parameters.NumNotches, CommonParameters, this.FileSpecificParameters,
new List<string> { Parameters.SearchTaskId }, analysisType: analysisType, doPEP: doPep, outputFolder: Parameters.OutputFolder).Run();
new FdrAnalysisEngine(psms, Parameters.NumNotches, CommonParameters, this.FileSpecificParameters,
new List<string> { Parameters.SearchTaskId }, analysisType: analysisType, doPEP: doPep, outputFolder: Parameters.OutputFolder).Run();

Status("Done estimating PSM FDR!", Parameters.SearchTaskId);
}
Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/TaskLayer/TaskLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.ML.CpuMath" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="mzLib" Version="1.0.551" />
<PackageReference Include="mzLib" Version="1.0.552" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="Nett" Version="0.15.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.ML" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.CpuMath" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="mzLib" Version="1.0.551" />
<PackageReference Include="mzLib" Version="1.0.552" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
Expand Down
Loading