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

changing dot size in plot depending if new submission #75 #93

Merged
merged 9 commits into from
Sep 25, 2023
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

{
"version": "0.2.0",
"configurations": [
{
"name": "Python: BStreamlit",
"type": "python",
"request": "launch",
"module": "streamlit",
"args": [
"run",
"Home.py",
"--server.port",
"8080"
],
"cwd": "${workspaceFolder}/webinterface/",
"justMyCode":false
}
]
}
7 changes: 6 additions & 1 deletion proteobench/modules/dda_quant/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pandas as pd
import streamlit as st

from proteobench.modules.dda_quant.datapoint import Datapoint
from proteobench.modules.dda_quant.parse import ParseInputs
from proteobench.modules.dda_quant.parse_settings import (
Expand Down Expand Up @@ -168,7 +167,11 @@ def add_current_data_point(self, all_datapoints, current_datapoint):
"""Add current data point to all data points and load them from file if empty. TODO: Not clear why is the df transposed here."""
if not isinstance(all_datapoints, pd.DataFrame):
all_datapoints = pd.read_json(DDA_QUANT_RESULTS_PATH)
all_datapoints["old_new"] = "old"

all_datapoints = all_datapoints.T

current_datapoint["old_new"] = "new"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could remember the index and use df.loc[idx_new]

all_datapoints = pd.concat([all_datapoints, current_datapoint], axis=1)
all_datapoints = all_datapoints.T.reset_index(drop=True)
return all_datapoints
Expand All @@ -194,6 +197,8 @@ def benchmarking(
current_datapoint = self.generate_datapoint(
intermediate_data_structure, input_format, user_input
)


all_datapoints = self.add_current_data_point(all_datapoints, current_datapoint)

return intermediate_data_structure, all_datapoints
30 changes: 25 additions & 5 deletions proteobench/modules/dda_quant/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def plot_bench(self, result_df: pd.DataFrame) -> go.Figure:
fig.update_layout(
width=700,
height=700,
title="Distplot",
# title="Distplot",
xaxis=dict(
title="1|2_ratio",
color="white",
Expand All @@ -40,6 +40,8 @@ def plot_bench(self, result_df: pd.DataFrame) -> go.Figure:
),
)
fig.update_xaxes(range=[0, 4])
fig.update_xaxes(showgrid=True, gridcolor="lightgray", gridwidth=1)
# fig.update_yaxes(showgrid=True, gridcolor="lightgray", gridwidth=1)

return fig

Expand Down Expand Up @@ -75,26 +77,41 @@ def plot_metric(self, benchmark_metrics_df: pd.DataFrame) -> go.Figure:

# Add hover text
hover_texts = [
f"Search Engine: {benchmark_metrics_df.search_engine[idx]} {benchmark_metrics_df.software_version[idx]}<br>FDR psm: {benchmark_metrics_df.fdr_psm[idx]}<br>FDR Peptide: {benchmark_metrics_df.fdr_peptide[idx]}<br>FRD Protein: {benchmark_metrics_df.fdr_protein[idx]}<br>MBR: {benchmark_metrics_df.MBR[idx]}<br>Precursor Tolerance: {benchmark_metrics_df.precursor_tol[idx]} {benchmark_metrics_df.precursor_tol_unit[idx]}<br>Fragment Tolerance: {benchmark_metrics_df.fragment_tol_unit[idx]}<br>Enzyme: {benchmark_metrics_df.enzyme_name[idx]} <br>Missed Cleavages: {benchmark_metrics_df.missed_cleavages[idx]}<br>Min peptide length: {benchmark_metrics_df.min_pep_length[idx]}<br>Max peptide length: {benchmark_metrics_df.max_pep_length[idx]}"
f"Search Engine: {benchmark_metrics_df.search_engine[idx]} {benchmark_metrics_df.software_version[idx]}<br>"
+ f"FDR psm: {benchmark_metrics_df.fdr_psm[idx]}<br>"
+ f"FDR Peptide: {benchmark_metrics_df.fdr_peptide[idx]}<br>"
+ f"FRD Protein: {benchmark_metrics_df.fdr_protein[idx]}<br>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ f"FRD Protein: {benchmark_metrics_df.fdr_protein[idx]}<br>"
+ f"FDR Protein: {benchmark_metrics_df.fdr_protein[idx]}<br>"

+ f"MBR: {benchmark_metrics_df.MBR[idx]}<br>"
+ f"Precursor Tolerance: {benchmark_metrics_df.precursor_tol[idx]} {benchmark_metrics_df.precursor_tol_unit[idx]}<br>"
+ f"Fragment Tolerance: {benchmark_metrics_df.fragment_tol_unit[idx]}<br>"
+ f"Enzyme: {benchmark_metrics_df.enzyme_name[idx]} <br>"
+ f"Missed Cleavages: {benchmark_metrics_df.missed_cleavages[idx]}<br>"
+ f"Min peptide length: {benchmark_metrics_df.min_pep_length[idx]}<br>"
+ f"Max peptide length: {benchmark_metrics_df.max_pep_length[idx]}"
for idx, row in benchmark_metrics_df.iterrows()
]

# spellerror {meta_data.fragmnent_tol[idx]}

mapping = {"old": 10, "new": 20}

fig = go.Figure(
data=[
go.Scatter(
x=benchmark_metrics_df["weighted_sum"],
y=benchmark_metrics_df["nr_prec"],
mode="markers",
text=hover_texts,
marker=dict(color=colors, showscale=True, size=20),
marker=dict(color=colors, showscale=False, size=20),
marker_size=[
mapping[item] for item in benchmark_metrics_df["old_new"]
],
)
]
)

fig.update_layout(
title="Metric",
# title="Metric",
width=700,
height=700,
xaxis=dict(
Expand All @@ -107,8 +124,11 @@ def plot_metric(self, benchmark_metrics_df: pd.DataFrame) -> go.Figure:
gridcolor="white",
gridwidth=2,
),
# paper_bgcolor='rgb(243, 243, 243)',
# plot_bgcolor="rgb(243, 243, 243)",
)

fig.update_xaxes(showgrid=True, gridcolor="lightgray", gridwidth=1)
fig.update_yaxes(showgrid=True, gridcolor="lightgray", gridwidth=1)
# selected_points = plotly_events(
# fig,
# select_event=True,
Expand Down
7 changes: 5 additions & 2 deletions test/test_module_dda_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from proteobench.modules.dda_quant.module import Module
from proteobench.modules.dda_quant.parse import ParseInputs
from proteobench.modules.dda_quant.parse_settings import (
DDA_QUANT_RESULTS_PATH, INPUT_FORMATS, ParseSettings)
DDA_QUANT_RESULTS_PATH,
INPUT_FORMATS,
ParseSettings,
)
from proteobench.modules.dda_quant.plot import PlotDataPoint

# genereate_input_field
Expand Down Expand Up @@ -125,9 +128,9 @@ class TestPlot(unittest.TestCase):
"""Test if the plots return a figure."""

def test_plot_metric(self):

all_datapoints = pd.read_json(DDA_QUANT_RESULTS_PATH)

all_datapoints["old_new"] = "old"
fig = PlotDataPoint().plot_metric(all_datapoints)
self.assertIsNotNone(fig)

Expand Down
18 changes: 12 additions & 6 deletions webinterface/pages/DDA_Quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def _main_page(self):
"""Format main page."""
st.title("Module 2: DDA quantification")
st.header("Description of the module")
st.markdown("""
st.markdown(
"""
This module compares the MS1-level quantification tools for
data-dependent acquisition (DDA). The raw files provided for
this module are presented in the comprehensive LFQ benchmark
Expand All @@ -98,9 +99,11 @@ def _main_page(self):
sets of parameters for the search and quantification.
The full description of the pre-processing steps and metrics
calculation is available here: LINK.
""")
"""
)
st.header("Downloading associated files")
st.markdown("""
st.markdown(
"""
The raw files used for this module were acquired on an Orbitrap
Q-Exactive H-FX (ThermoScientific). They can be downloaded from the
proteomeXchange repository PXD028735. You can download them here:
Expand All @@ -112,13 +115,16 @@ def _main_page(self):
[LFQ_Orbitrap_AIF_Condition_B_Sample_Alpha_03.raw](https://ftp.pride.ebi.ac.uk/pride/data/archive/2022/02/PXD028735/LFQ_Orbitrap_AIF_Condition_B_Sample_Alpha_03.raw)

**It is imperative not to rename the files once downloaded!**
""")
st.markdown("""
"""
)
st.markdown(
"""
Download the fasta file here: [TODO]
The fasta file provided for this module contains the three species
present in the samples and contaminant proteins
([Frankenfield et al., JPR](https://pubs.acs.org/doi/10.1021/acs.jproteome.2c00145))
""")
"""
)

st.header("Input and configuration")

Expand Down