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

Enhance plot #401

Merged
merged 22 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
12 changes: 6 additions & 6 deletions proteobench/modules/dda_quant_ion/dda_quant_ion_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def is_implemented(self) -> bool:
return True

def benchmarking(
self, input_file: str, input_format: str, user_input: dict, all_datapoints, default_cutoff_min_prec: int = 3
self, input_file_loc: any, input_format: str, user_input: dict, all_datapoints, default_cutoff_min_prec: int = 3
) -> tuple[DataFrame, DataFrame, DataFrame]:
"""
Main workflow of the module. Used to benchmark workflow results.
Expand All @@ -81,7 +81,7 @@ def benchmarking(
# Parse workflow output file

try:
input_df = load_input_file(input_file, input_format)
input_df = load_input_file(input_file_loc, input_format)
except pd.errors.ParserError as e:
raise ParseError(
f"Error parsing {input_format} file, please make sure the format is correct and the correct software tool is chosen: {e}"
Expand Down Expand Up @@ -128,10 +128,10 @@ def benchmarking(
# raise DatapointGenerationError(f"Error generating datapoint: {e}")

# add current data point to all datapoints
try:
all_datapoints = self.add_current_data_point(current_datapoint, all_datapoints=all_datapoints)
except Exception as e:
raise DatapointAppendError(f"Error adding current data point: {e}")
# try:
all_datapoints = self.add_current_data_point(current_datapoint, all_datapoints=all_datapoints)
# except Exception as e:
# raise DatapointAppendError(f"Error adding current data point: {e}")

# return intermediate data structure, all datapoints, and input DataFrame
# TODO check why there are NA and inf/-inf values
Expand Down
14 changes: 10 additions & 4 deletions proteobench/modules/quant_base/quant_base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,18 @@ def add_current_data_point(
if not isinstance(all_datapoints, pd.DataFrame):
all_datapoints = self.github_repo.read_results_json_repo()

all_datapoints["old_new"] = "old"
all_datapoints = all_datapoints.T

current_datapoint["old_new"] = "new"
all_datapoints = pd.concat([all_datapoints, current_datapoint], axis=1)
all_datapoints = all_datapoints.T.reset_index(drop=True)
return all_datapoints

if current_datapoint["intermediate_hash"] not in all_datapoints.loc["intermediate_hash", :].values:
all_datapoints.loc["old_new", :] = "old"
all_datapoints_new = pd.concat([all_datapoints, current_datapoint], axis=1)
all_datapoints_new = all_datapoints_new.T.reset_index(drop=True)
else:
all_datapoints_new = all_datapoints.T.reset_index(drop=True)

return all_datapoints_new

def obtain_all_data_points(self, all_datapoints: Optional[pd.DataFrame] = None):
"""
Expand Down Expand Up @@ -147,6 +152,7 @@ def filter_data_point(all_datapoints: pd.DataFrame, default_val_slider: int = 3)
pd.DataFrame
All data points with the filtered data points.
"""
print(all_datapoints)

all_datapoints["median_abs_epsilon"] = [
filter_df_numquant_median_abs_epsilon(v, min_quant=default_val_slider) for v in all_datapoints["results"]
Expand Down
42 changes: 32 additions & 10 deletions proteobench/plotting/plot_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def plot_metric(
},
mapping={"old": 10, "new": 20},
highlight_color: str = "#d30067",
label: str = "None",
) -> go.Figure:
"""
Plot mean metrics in a scatterplot with plotly.
Expand Down Expand Up @@ -151,24 +152,45 @@ def plot_metric(
for item, highlight in zip(colors, benchmark_metrics_df["Highlight"])
]

benchmark_metrics_df["color"] = colors
benchmark_metrics_df["hover_text"] = hover_texts
benchmark_metrics_df["scatter_size"] = scatter_size

fig = go.Figure(
data=[
go.Scatter(
x=benchmark_metrics_df["median_abs_epsilon"],
y=benchmark_metrics_df["nr_prec"],
mode="markers",
text=hover_texts,
marker=dict(color=colors, showscale=False),
marker_size=scatter_size,
)
layout_yaxis_range=[
min(all_nr_prec) - min(max(all_nr_prec) * 0.05, 2000),
max(all_nr_prec) + min(max(all_nr_prec) * 0.05, 2000),
],
layout_yaxis_range=[min(all_nr_prec) - min(all_nr_prec) * 0.05, max(all_nr_prec) + min(all_nr_prec) * 0.05],
layout_xaxis_range=[
min(all_median_abs_epsilon) - min(all_median_abs_epsilon) * 0.05,
max(all_median_abs_epsilon) + min(all_median_abs_epsilon) * 0.05,
],
)

# Get all unique color-software combinations (necessary for highlighting)
color_software_combinations = benchmark_metrics_df[["color", "software_name"]].drop_duplicates()

# plot the data points, one trace per software tool
for _, row in color_software_combinations.iterrows():
color = row["color"]
software = row["software_name"]

tmp_df = benchmark_metrics_df[
(benchmark_metrics_df["color"] == color) & (benchmark_metrics_df["software_name"] == software)
]
fig.add_trace(
go.Scatter(
x=tmp_df["median_abs_epsilon"],
y=tmp_df["nr_prec"],
mode="markers" if label == "None" else "markers+text",
hovertext=tmp_df["hover_text"],
text=tmp_df[label] if label != "None" else None,
marker=dict(color=tmp_df["color"], showscale=False),
marker_size=tmp_df["scatter_size"],
name=tmp_df["software_name"].iloc[0],
)
)

fig.update_layout(
width=700,
height=700,
Expand Down
14 changes: 3 additions & 11 deletions webinterface/.streamlit/pages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ name = "Home"
path = "pages/DDA_Quant_ion.py"
name = "DDA Quant Ion Level -BETA-"

[[pages]]
path = "pages/DDA_Quant_peptidoform.py"
name = "DDA Quant Peptidoform Level -BETA-"

[[pages]]
path = "pages/DIA_Quant_ion.py"
name = "DIA Quant Ion Level -BETA-"

[[pages]]
path = "pages/DIA_Quant_peptidoform.py"
name = "DIA Quant Peptidoform Level -BETA-"
[[pages]]
path = "pages/DIA_Quant_ion.py"
name = "DIA Quant Ion Level -BETA-"
71 changes: 63 additions & 8 deletions webinterface/pages/DDA_Quant_ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,74 @@ def __init__(self):
def _main_page(self) -> None:
"""
Sets up the main page layout for the Streamlit application.
This includes the title, module descriptions, input forms, and configuration settings.
"""
self.quant_uiobjects.create_text_header()
self.quant_uiobjects.create_main_submission_form()
# Create tabs
(
tab_description,
tab_results_all,
tab_submission_details,
tab_indepth_plots,
tab_results_new,
tab_public_submission,
) = st.tabs(
[
"Module description",
"Results (All Data)",
"Submission form",
"In-depth submission",
"Results (New Submissions)",
"Public Submission",
]
)

self.quant_uiobjects.init_slider()
# Tab 0: Description
with tab_description:
self.quant_uiobjects.create_text_header()

if self.quant_uiobjects.variables_quant.fig_logfc in st.session_state:
self.quant_uiobjects.populate_results()
# Tab 1: Results (All Data)
with tab_results_all:
st.title(self.variables_dda_quant.texts.ShortMessages.title)
if self.variables_dda_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.display_results_all_data()

self.quant_uiobjects.create_results()
# Tab 2: Submission Details
with tab_submission_details:
self.quant_uiobjects.create_text_header()
self.quant_uiobjects.create_main_submission_form()
# self.quant_uiobjects.display_submission_details()

self.quant_uiobjects.render_download_container()
# Tab 2.5: in-depth plots current data
with tab_indepth_plots:
st.title(self.variables_dda_quant.texts.ShortMessages.title)
if self.variables_dda_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.plots_for_current_data(True)

# Tab 3: Results (New Submissions)
with tab_results_new:
st.title(self.variables_dda_quant.texts.ShortMessages.title)
if self.variables_dda_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.display_results_all_data_submitted()
# self.quant_uiobjects.display_results_new_submissions()

# Tab 4: Public Submission
with tab_public_submission:
st.title(self.variables_dda_quant.texts.ShortMessages.title)
if self.variables_dda_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.wrap_public_submission_form()
# self.quant_uiobjects.create_main_submission_form()
# self.quant_uiobjects.display_public_submission_form()


if __name__ == "__main__":
Expand Down
71 changes: 64 additions & 7 deletions webinterface/pages/DIA_Quant_ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,74 @@ def __init__(self):
def _main_page(self) -> None:
"""
Sets up the main page layout for the Streamlit application.
This includes the title, module descriptions, input forms, and configuration settings.
"""
self.quant_uiobjects.create_text_header()
self.quant_uiobjects.create_main_submission_form()
# Create tabs
(
tab_description,
tab_results_all,
tab_submission_details,
tab_indepth_plots,
tab_results_new,
tab_public_submission,
) = st.tabs(
[
"Module description",
"Results (All Data)",
"Submission form",
"In-depth submission",
"Results (New Submissions)",
"Public Submission",
]
)

self.quant_uiobjects.init_slider()
# Tab 0: Description
with tab_description:
self.quant_uiobjects.create_text_header()

if self.quant_uiobjects.variables_quant.fig_logfc in st.session_state:
self.quant_uiobjects.populate_results()
# Tab 1: Results (All Data)
with tab_results_all:
st.title(self.variables_dia_quant.texts.ShortMessages.title)
if self.variables_dia_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.display_results_all_data()

self.quant_uiobjects.create_results()
# Tab 2: Submission Details
with tab_submission_details:
self.quant_uiobjects.create_text_header()
self.quant_uiobjects.create_main_submission_form()
# self.quant_uiobjects.display_submission_details()

# Tab 2.5: in-depth plots current data
with tab_indepth_plots:
st.title(self.variables_dia_quant.texts.ShortMessages.title)
if self.variables_dia_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.plots_for_current_data(True)

# Tab 3: Results (New Submissions)
with tab_results_new:
st.title(self.variables_dia_quant.texts.ShortMessages.title)
if self.variables_dia_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.display_results_all_data_submitted()
# self.quant_uiobjects.display_results_new_submissions()

# Tab 4: Public Submission
with tab_public_submission:
st.title(self.variables_dia_quant.texts.ShortMessages.title)
if self.variables_dia_quant.beta_warning:
st.warning(
"This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future."
)
self.quant_uiobjects.wrap_public_submission_form()
# self.quant_uiobjects.create_main_submission_form()
# self.quant_uiobjects.display_public_submission_form()


if __name__ == "__main__":
Expand Down
Loading
Loading