Skip to content

Commit

Permalink
Only show config if dataset is present
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaS92 committed Sep 10, 2024
1 parent f477837 commit fa23c20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 10 additions & 7 deletions alphastats/gui/pages/03_Preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
update_workflow,
run_preprocessing,
reset_preprocessing,
PREDEFINED_ORDER
)
from alphastats.gui.utils.ui_helper import sidebar_info

Expand All @@ -16,30 +17,32 @@

if "workflow" not in st.session_state:
st.session_state['workflow'] = [
"remove contaminations",
"subset data",
"log2 transform",
"remove_contaminations",
"subset",
"log2_transform",
]

st.markdown("### Preprocessing")
c1, c2 = st.columns([1, 1])

with c2:
settings = configure_preprocessing(dataset=st.session_state['dataset'])
if "dataset" not in st.session_state:
settings = {k: True for k in st.session_state.workflow}
else:
settings = configure_preprocessing(dataset=st.session_state['dataset'])

new_workflow = update_workflow(settings)

if new_workflow != st.session_state.workflow:
st.session_state.workflow = new_workflow
st.rerun()

with c1:
st.write("#### Flowchart of currently selected workflow:")
st.write("#### Flowchart of preprocessing workflow:")

selected_nodes = draw_workflow(st.session_state.workflow)

if "dataset" not in st.session_state:
st.info("Import data first to run preprocessing")
st.info("Import data first to configure and run preprocessing")

else:
c11, c12 = st.columns([1, 1])
Expand Down
15 changes: 5 additions & 10 deletions alphastats/gui/utils/preprocessing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ def draw_workflow(workflow: list[str], order: list[str] = PREDEFINED_ORDER):
return selected


def configure_preprocessing(dataset=None):
def configure_preprocessing(dataset):
st.markdown(
"Before analyzing your data, consider normalizing and imputing your data as well as the removal of contaminants. "
+ "A more detailed description about the preprocessing methods can be found in the AlphaPeptStats "
+ "[documentation](https://alphapeptstats.readthedocs.io/en/main/data_preprocessing.html)."
)

remove_contaminations = st.selectbox(
f"Remove contaminations annotated in {'contaminations library' if dataset is None else dataset.filter_columns}",
f"Remove contaminations annotated in {dataset.filter_columns}",
options=[True, False],
)

Expand All @@ -143,13 +143,10 @@ def configure_preprocessing(dataset=None):
options=[True, False],
)

# TODO: value of this widget does not persist across dataset reset (likely because the metadata is reset)
remove_samples = st.multiselect(
"Remove samples from analysis",
options=[]
if dataset is None
else dataset.metadata[
dataset.sample
].to_list(),
options=dataset.metadata[dataset.sample].to_list(),
)

data_completeness = st.number_input(
Expand All @@ -175,9 +172,7 @@ def configure_preprocessing(dataset=None):

batch = st.selectbox(
"Batch",
options=[False]
if dataset is None
else [False] + dataset.metadata.columns.to_list(),
options=[False] + dataset.metadata.columns.to_list(),
)

return {
Expand Down

0 comments on commit fa23c20

Please sign in to comment.