Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7ffb396
Added Precursor Mass and Precursor M/z histograms
weaversd Sep 15, 2022
b14019d
Moved PlotModelStat to GuiFunctions, added histogram test
weaversd Sep 15, 2022
19ebb41
added additional tests
weaversd Sep 15, 2022
f23ad84
added test coverage for all plot types
weaversd Sep 16, 2022
b948cc0
removed tests for plots that are not options in gui
weaversd Sep 16, 2022
b271c20
added test coverage for variants
weaversd Sep 16, 2022
ddd78e9
Merge branch 'master' into mass_histogram_metadraw
weaversd Sep 20, 2022
2d9604b
Added plots for fragment error. Allowed parsing of fragment error fro…
weaversd Sep 20, 2022
bb1237c
Merge branch 'mass_histogram_metadraw' of https://github.com/weaversd…
weaversd Sep 20, 2022
05feeb5
Removed fragment ppm error vs RT because of long load time
weaversd Sep 21, 2022
e7517e2
Fix pdf export bug
weaversd Sep 22, 2022
f8f67f1
Fixed bug for exporting data visualization. Will now create export di…
weaversd Sep 22, 2022
50eac8f
changed plot name in test
weaversd Sep 22, 2022
b4eb1e7
Merge branch 'master' into mass_histogram_metadraw
weaversd Sep 23, 2022
7e9eb2a
renamed variables for clarity between experimental and theoretical
weaversd Oct 5, 2022
c1b1533
updated naming of "m over z" to "m/z"
weaversd Oct 5, 2022
61b8091
removed commented code
weaversd Oct 6, 2022
3b6a40d
Merge branch 'master' of https://github.com/smith-chem-wisc/MetaMorph…
weaversd Oct 10, 2022
d728aad
Added hydrophobicity score histogram
weaversd Oct 10, 2022
e016e29
Merge branch 'master' into gravyHistogram
weaversd Oct 19, 2022
d60429b
Merge branch 'master' into gravyHistogram
trishorts Oct 19, 2022
b9cd748
Merge branch 'master' of https://github.com/smith-chem-wisc/MetaMorph…
weaversd Oct 24, 2022
3fb1edd
added checkboxes and CZE plots
weaversd Oct 26, 2022
70b76ca
Merge branch 'master' into VisualizationOptions
weaversd Oct 26, 2022
31edfe4
updated because of bin size
weaversd Oct 26, 2022
9a0804c
unit tests to cover checkbox options and new plots
weaversd Oct 26, 2022
083c1a1
Refactored Converters
weaversd Oct 27, 2022
395be32
Added filter for PSM plot visualization
weaversd Oct 27, 2022
15ff15b
Fixed Errors
weaversd Oct 28, 2022
621e282
Added comments
weaversd Oct 28, 2022
259eab8
Updated button layout
weaversd Nov 4, 2022
4b198d3
Added new mobility charge, not used in PEP yet
weaversd Nov 4, 2022
bde9977
Merge branch 'master' into VisualizationOptions
trishorts Nov 17, 2022
58c7d13
Merge branch 'master' into VisualizationOptions
trishorts Jan 17, 2023
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
23 changes: 23 additions & 0 deletions EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,29 @@ private static double GetCifuentesMobility(PeptideWithSetModifications pwsm)
return mobility;
}

//Mobility based on Charge calculation at a given a pH and ionizable group pKa values. default pH set to 2.4.
private static double GetPkaBasedMobility(PeptideWithSetModifications pwsm, double pH = 2.4)
{
double KCharge = Math.Pow(10, 10.8 - pH) / (1 + Math.Pow(10, 10.8 - pH));
; double RCharge = Math.Pow(10, 12.5 - pH) / (1 + Math.Pow(10, 12.5 - pH));
double HCharge = Math.Pow(10, 6.5 - pH) / (1 + Math.Pow(10, 6.5 - pH));
double NTermCharge = Math.Pow(10, 8.6 - pH) / (1 + Math.Pow(10, 8.6 - pH));
double CCharge = Math.Pow(10, pH - 8.5) / (1 + Math.Pow(10, pH - 8.5));
double YCharge = Math.Pow(10, pH - 10.1) / (1 + Math.Pow(10, pH - 10.1));
double ECharge = Math.Pow(10, pH - 4.1) / (1 + Math.Pow(10, pH - 4.1));
double DCharge = Math.Pow(10, pH - 3.9) / (1 + Math.Pow(10, pH - 3.9));
double CTermCharge = Math.Pow(10, pH - 3.6) / (1 + Math.Pow(10, pH - 3.6));

double peptideCharge = NTermCharge + CTermCharge + pwsm.BaseSequence.Count(f => f == 'K') * KCharge + pwsm.BaseSequence.Count(f => f == 'R') * RCharge
+ pwsm.BaseSequence.Count(f => f == 'H') * HCharge + pwsm.BaseSequence.Count(f => f == 'C') * CCharge + pwsm.BaseSequence.Count(f => f == 'Y') * YCharge
+ pwsm.BaseSequence.Count(f => f == 'E') * ECharge + pwsm.BaseSequence.Count(f => f == 'D') * DCharge
- CountModificationsThatShiftMobility(pwsm.AllModsOneIsNterminus.Values.AsEnumerable());

double mobility = (Math.Log(1 + 0.35 * peptideCharge)) / Math.Pow(pwsm.MonoisotopicMass, 0.411);

return mobility;
}

private static float GetSSRCalcHydrophobicityZScore(PeptideSpectralMatch psm, PeptideWithSetModifications Peptide, Dictionary<string, Dictionary<int, Tuple<double, double>>> d)
{
//Using SSRCalc3 but probably any number of different calculators could be used instead. One could also use the CE mobility.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BooleanToVisibilityConverter : BaseValueConverter<BooleanToVisibili
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Boolean && (bool)value)
if (value is bool && (bool)value)
{
return Visibility.Visible;
}
Expand Down
37 changes: 37 additions & 0 deletions GUI/Coverters/CheckboxUncheckConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MetaMorpheusGUI
{
public class CheckboxUncheckConverter : BaseValueConverter<CheckboxUncheckConverter>
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return false;
}
else
{
return (bool)value;
}
}

public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(bool)value)
{
return false;
}
else
{
return (bool)parameter;
}
}
}
}
21 changes: 18 additions & 3 deletions GUI/MetaDraw/MetaDraw.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
<!-- actual ptm legend -->
<local:PtmLegendControl x:Name="ChildScanPtmLegendControl" DataContext="{Binding}" />
</StackPanel>

</Grid>
</Grid>
</TabItem>
Expand Down Expand Up @@ -421,6 +421,7 @@
</DockPanel>
</TabItem>


<!--Stats tab-->
<TabItem Header="Data Visualization" Background="DarkGray">
<DockPanel>
Expand All @@ -437,8 +438,10 @@
<RowDefinition Height="29"/>
<RowDefinition Height="29"/>
<RowDefinition Height="50*"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40*"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>

<!--Select MetaMorpheus output file-->
Expand Down Expand Up @@ -467,12 +470,24 @@
</DockPanel>
</DockPanel>

<DockPanel Grid.Row="3">
<Label Height="25" VerticalAlignment="Top" HorizontalAlignment="Right">Filter Psms by Full Sequence</Label>
<TextBox TextChanged="TextBoxBase_OnTextChanged" DockPanel.Dock="Left" Width="125" Height="30" VerticalAlignment="Top" ToolTip="Shows only PSMs where the Full sequence (including PTMs) contains the value of this text box"/>
</DockPanel>

<!--List of plot options-->
<GroupBox Header="Plot Type" Name="plotType" Grid.Row="3">
<GroupBox Header="Plot Type" Name="plotType" Grid.Row="4">
<ListView x:Name="plotsListBox" ItemsSource="{Binding}" SelectionChanged ="PlotSelected" MaxHeight="400"/>
</GroupBox>

<DockPanel Grid.Row="4" Margin="2">
<!--Whether to display y-axis on a log scale-->
<DockPanel Grid.Row="5" Margin="5,5,0,0">
<CheckBox Name="yAxisLogScaleCheckbox" Content="y-axis log scale" IsChecked="False" Checked="YAxisLogScaleCheckbox_OnChecked" Unchecked="YAxisLogScaleCheckbox_OnUnchecked" Margin="0,0,10,0" ToolTip="Displays histogram y-axis on a logarithmic scale when checked"></CheckBox>
<CheckBox Name="stackedBars" Content="Stacked Bars" IsChecked="True" Checked="StackedBars_OnChecked" Unchecked="StackedBars_OnUnchecked" Margin="0,0,10,0" ToolTip="Stacks histogram bars for multiple files when checked"></CheckBox>
<CheckBox Name ="invertFilter" Content="Invert Filter" IsChecked="False" Checked="InvertFilter_OnChecked" Unchecked="InvertFilter_OnUnchecked" ToolTip="Displays PSMs that DO NOT pass the Full Sequence filter"></CheckBox>
</DockPanel>

<DockPanel Grid.Row="6" Margin="2">
<Button Content="Export to PDF" Width="100" Click="CreatePlotPdf_Click" />
</DockPanel>
</Grid>
Expand Down
103 changes: 100 additions & 3 deletions GUI/MetaDraw/MetaDraw.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Easy.Common.Extensions;
using Org.BouncyCastle.Asn1.Crmf;
using OxyPlot.Wpf;

namespace MetaMorpheusGUI
{
Expand All @@ -43,6 +46,8 @@ public partial class MetaDraw : Window
private static List<string> AcceptedResultsFormats = new List<string> { ".psmtsv", ".tsv" };
private static List<string> AcceptedSpectralLibraryFormats = new List<string> { ".msp" };
private SettingsViewModel SettingsView;
private string searchString = string.Empty;
private bool plotInverseBool = false;

public MetaDraw()
{
Expand Down Expand Up @@ -737,13 +742,47 @@ private async void PlotSelected(object sender, SelectionChangedEventArgs e)
Dictionary<string, ObservableCollection<PsmFromTsv>> psmsBSF = new Dictionary<string, ObservableCollection<PsmFromTsv>>();
foreach (string fileName in selectSourceFileListBox.SelectedItems)
{
psmsBSF.Add(fileName, MetaDrawLogic.PsmsGroupedByFile[fileName]);
//pull out those PSMs for each file that have a full sequence matching the filter
var filteredPSMsForPlotsBSF = MetaDrawLogic.PsmsGroupedByFile[fileName]
.Where(p => p.FullSequence.ToUpper().Contains(searchString));
if (!filteredPSMsForPlotsBSF.Any()) continue;

//If the inverse box is checked, take the opposite PSMs
if (plotInverseBool)
{
filteredPSMsForPlotsBSF = MetaDrawLogic.PsmsGroupedByFile[fileName]
.Where(p => !p.FullSequence.ToUpper().Contains(searchString));
}

//Save PSMs as observable collection
var filteredPSMsForPLotsBSFOC = new ObservableCollection<PsmFromTsv>(filteredPSMsForPlotsBSF);
psmsBSF.Add(fileName, filteredPSMsForPLotsBSFOC);
foreach (PsmFromTsv psm in MetaDrawLogic.PsmsGroupedByFile[fileName])
{
psms.Add(psm);
}
}
PlotModelStat plot = await Task.Run(() => new PlotModelStat(plotName, psms, psmsBSF));

//Filter all PSMs that pass the filter
var filteredPSMsForPlots = psms.Where(p => p.FullSequence.ToUpper().Contains(searchString));

//check that there are some PSMs
if (!filteredPSMsForPlots.Any())
{
MessageBox.Show("No PSMs pass the filter");
return;
}

//If the inverse box is checked, take the opposite PSMs
if (plotInverseBool)
{
filteredPSMsForPlots = psms.Where(p => !p.FullSequence.ToUpper().Contains(searchString.ToUpper()));
}

//Save as observable collection
var filteredPSMsForPlotsOC = new ObservableCollection<PsmFromTsv>(filteredPSMsForPlots);
//Create the PlotModelStat with the filtered psms
PlotModelStat plot = await Task.Run(() => new PlotModelStat(plotName, filteredPSMsForPlotsOC, psmsBSF));
plotViewStat.DataContext = plot;
PlotViewStat_SizeChanged(plotViewStat, null);
}
Expand Down Expand Up @@ -1016,7 +1055,7 @@ private void ClearPresentationArea()
/// <param name="value">true = enabled, false = disable</param>
private void ToggleButtonsEnabled(bool value)
{
loadFiles.IsEnabled = value;
loadFiles.IsEnabled = value;
selectSpectraFileButton.IsEnabled = value;
selectPsmFileButton.IsEnabled = value;
selectSpecLibraryButton.IsEnabled = value;
Expand All @@ -1025,5 +1064,63 @@ private void ToggleButtonsEnabled(bool value)
resetSpectraFileButton.IsEnabled = value;
ExportButton.IsEnabled = value;
}

private void YAxisLogScaleCheckbox_OnChecked(object sender, RoutedEventArgs e)
{
if (MetaDrawSettings.stackedBool)
{
MessageBox.Show("Stacked bars with logarithmic scale not recommended");
}
MetaDrawSettings.yAxisLogScale = yAxisLogScaleCheckbox.IsChecked.Value;
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}

private void YAxisLogScaleCheckbox_OnUnchecked(object sender, RoutedEventArgs e)
{
MetaDrawSettings.yAxisLogScale = yAxisLogScaleCheckbox.IsChecked.Value;
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}

private void StackedBars_OnChecked(object sender, RoutedEventArgs e)
{
if (MetaDrawSettings.yAxisLogScale)
{
MessageBox.Show("Stacked bars with logarithmic scale not recommended");
}
MetaDrawSettings.stackedBool = stackedBars.IsChecked.Value;
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}

private void StackedBars_OnUnchecked(object sender, RoutedEventArgs e)
{
MetaDrawSettings.stackedBool = stackedBars.IsChecked.Value;
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}

private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
string txt = (sender as TextBox).Text;
searchString = txt.ToUpper();
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}

private void InvertFilter_OnChecked(object sender, RoutedEventArgs e)
{
plotInverseBool = invertFilter.IsChecked.Value;
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}

private void InvertFilter_OnUnchecked(object sender, RoutedEventArgs e)
{
plotInverseBool = invertFilter.IsChecked.Value;
if (MetaDrawLogic != null)
PlotSelected(plotsListBox, null);
}
}
}
9 changes: 9 additions & 0 deletions GuiFunctions/MetaDraw/MetaDrawSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public static class MetaDrawSettings
public static int SequenceAnnotationSegmentPerRow { get; set; } = 3;
public static int SequenceAnnotaitonResiduesPerSegment { get; set; } = 10;

public static bool yAxisLogScale { get; set; } = false;
public static bool stackedBool { get; set; } = true;

static MetaDrawSettings()
{
InitializeDictionaries();
Expand Down Expand Up @@ -248,6 +251,8 @@ public static MetaDrawSettingsSnapshot MakeSnapShot()
SpectrumDescriptionValues = SpectrumDescription.Values.ToList(),
UnannotatedPeakColor = UnannotatedPeakColor.GetColorName(),
InternalIonColor = InternalIonColor.GetColorName(),
yAxisLogScale = yAxisLogScale,
stackedBool = stackedBool,
};
}

Expand All @@ -271,6 +276,8 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings)
LocalizationLevelStart = settings.LocalizationLevelStart;
LocalizationLevelEnd = settings.LocalizationLevelEnd;
ExportType = settings.ExportType;
yAxisLogScale = settings.yAxisLogScale;
stackedBool = settings.stackedBool;

ProductTypeToColor = ((ProductType[])Enum.GetValues(typeof(ProductType))).ToDictionary(p => p, p => DrawnSequence.ParseOxyColorFromName(settings.ProductTypeToColorValues[Array.IndexOf(((ProductType[])Enum.GetValues(typeof(ProductType))), p)]));
BetaProductTypeToColor = ((ProductType[])Enum.GetValues(typeof(ProductType))).ToDictionary(p => p, p => DrawnSequence.ParseOxyColorFromName(settings.BetaProductTypeToColorValues[Array.IndexOf(((ProductType[])Enum.GetValues(typeof(ProductType))), p)]));
Expand Down Expand Up @@ -308,6 +315,8 @@ public static void ResetSettings()
ExportType = "Pdf";
UnannotatedPeakColor = OxyColors.LightGray;
InternalIonColor = OxyColors.Purple;
yAxisLogScale = false;
stackedBool = true;
}

public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue)
Expand Down
2 changes: 2 additions & 0 deletions GuiFunctions/MetaDraw/MetaDrawSettingsSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class MetaDrawSettingsSnapshot
public List<string> CoverageTypeToColorValues { get; set; }
public string UnannotatedPeakColor { get; set; }
public string InternalIonColor { get; set; }
public bool yAxisLogScale { get; set; }
public bool stackedBool { get; set; }

// filter settings
public bool ShowDecoys { get; set; } = false;
Expand Down
Loading