Skip to content

Commit 5ee79a5

Browse files
authored
Merge pull request #25 from abzer005/main
2 parents 89e743b + 75e17e4 commit 5ee79a5

8 files changed

+63
-20
lines changed

Statistics_for_Metabolomics.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
## Quickstart Guide
1111
1212
Welcome to the FBMN-STATS, a web app implementation of the [statistics notebooks](https://github.com/Functional-Metabolomics-Lab/Statistical-analysis-of-non-targeted-LC-MSMS-data) for metabolomics by the [Functional Metabolomics Lab](https://github.com/Functional-Metabolomics-Lab).
13-
as part of the article '[The Hitchhiker’s Guide to Statistical Analysis of Feature-based Molecular Networks from Non-Targeted Metabolomics Data](https://doi.org/10.26434/chemrxiv-2023-wwbt0)'.
14-
These notebooks are developed by the Virtual Multi Omics Lab ([VMOL](https://vmol.org/)).
13+
as part of the article '[The Statistical Analysis of Feature-based Molecular Networking Results from Non-Targeted Metabolomics Data](https://doi.org/10.26434/chemrxiv-2023-wwbt0)'.
14+
These notebooks are developed by the Virtual MultiOmics Lab ([VMOL](https://vmol.org/)).
1515
This app facilitates downstream statistical analysis of Feature-Based Molecular Networking data, simplifying the process for researchers.
1616
1717
### Getting Started
@@ -81,7 +81,7 @@
8181

8282
st.subheader('Settings Panel')
8383
st.markdown("""
84-
1. **P-value Correction:** These are FDR (False Disovery Rate) corrections applied for multiple univariate tests. Available options include Bonferroni, Sidak, Benjamini-Hochberg (BH), Benjamini-Yekutieli (BY), and an option for no correction, with Bonferroni set as the default.
84+
1. **P-value Correction:** These are FDR (False Disovery Rate) corrections applied for multiple univariate tests. Available options include Bonferroni, Sidak, Benjamini-Hochberg (BH), Benjamini-Yekutieli (BY), and an option for no correction.
8585
While Bonferroni is known for controlling false positives, it may inadvertently increase false negatives. Advanced methods like BH and BY aim to balance true discoveries against false positives more effectively. We recommend BH for FDR correction to optimize analysis outcomes.
8686
8787
Note that changing the p-value correction settings does not automatically update the corrected p-values. To update results re-run the analysis.
@@ -98,7 +98,7 @@
9898

9999
st.subheader('Citation and Resources')
100100
st.markdown("""
101-
For citations and further resources, please refer to our [article](https://doi.org/10.26434/chemrxiv-2023-wwbt0).
101+
For citations and further resources, please refer to our [article](https://doi.org/10.26434/chemrxiv-2023-wwbt0). You can download the Windows executables of the app from our [homepage](https://www.functional-metabolomics.com/resources).
102102
""")
103103

104104

@@ -123,18 +123,18 @@
123123
unsafe_allow_html=True,
124124
)
125125
c2.markdown(
126-
"""<a href="https://www.youtube.com/@functionalmetabolomics">
126+
"""<a href="https://www.functional-metabolomics.com/">
127127
<img src="data:image/png;base64,{}" width="100">
128128
</a>""".format(
129-
base64.b64encode(open("./assets/youtube-logo.png", "rb").read()).decode()
129+
base64.b64encode(open("./assets/fmlab_logo_colored.png", "rb").read()).decode()
130130
),
131131
unsafe_allow_html=True,
132132
)
133133
c3.markdown(
134-
"""<a href="https://twitter.com/func_metabo_lab">
134+
"""<a href="https://www.youtube.com/@functionalmetabolomics">
135135
<img src="data:image/png;base64,{}" width="100">
136136
</a>""".format(
137-
base64.b64encode(open("./assets/x-logo.png", "rb").read()).decode()
137+
base64.b64encode(open("./assets/youtube-logo.png", "rb").read()).decode()
138138
),
139139
unsafe_allow_html=True,
140140
)

assets/GNPS2_logo.png

56.1 KB
Loading

assets/fmlab_logo_colored.png

33.9 KB
Loading

src/common.py

+48-9
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"md_gnps",
1818
"df_gnps_annotations")
1919

20-
corrections_map = {"Bonferroni": "bonf",
20+
corrections_map = {"Benjamini/Hochberg FDR": "fdr_bh",
2121
"Sidak": "sidak",
22-
"Benjamini/Hochberg FDR": "fdr_bh",
22+
"Bonferroni": "bonf",
2323
"Benjamini/Yekutieli FDR": "fdr_by",
2424
"no correction": "none"}
2525

@@ -28,6 +28,14 @@ def reset_dataframes():
2828
for key in dataframe_names:
2929
st.session_state[key] = pd.DataFrame()
3030

31+
def clear_cache_button():
32+
if st.button("Clear Cache"):
33+
# Clear cache for both newer and older Streamlit versions
34+
if hasattr(st, "cache_data"):
35+
st.cache_data.clear()
36+
if hasattr(st, "cache_resource"):
37+
st.cache_resource.clear()
38+
st.success("Cache cleared!")
3139

3240
def page_setup():
3341
# streamlit configs
@@ -56,11 +64,42 @@ def page_setup():
5664
["svg", "png", "jpeg", "webp"],
5765
key="image_format",
5866
)
67+
68+
# Add the clear cache button
69+
v_space(1)
70+
clear_cache_button()
71+
72+
# Display two images side by side in the sidebar
5973
v_space(1)
60-
st.image("assets/FBMN-STATS-GUIed_logo2.png", use_column_width=True)
74+
col1, col2 = st.columns(2)
75+
with col1:
76+
st.markdown(
77+
f'<a href="https://github.com/Functional-Metabolomics-Lab/FBMN-STATS" target="_blank">'
78+
f'<img src="data:image/png;base64,{base64.b64encode(open("assets/FBMN-STATS-GUIed_logo2.png", "rb").read()).decode()}" width="130">'
79+
'</a>',
80+
unsafe_allow_html=True,
81+
)
82+
with col2:
83+
st.markdown(
84+
f'<a href="https://gnps2.org/homepage" target="_blank">'
85+
f'<img src="data:image/png;base64,{base64.b64encode(open("assets/GNPS2_logo.png", "rb").read()).decode()}" width="150">'
86+
'</a>',
87+
unsafe_allow_html=True,
88+
)
89+
90+
# st.image("assets/GNPS2_logo.png", use_column_width=True)
91+
6192
v_space(1)
62-
st.image("assets/vmol-icon.png", use_column_width=True)
93+
94+
#st.image("assets/vmol-icon.png", use_column_width=True)
95+
st.markdown(
96+
f'<a href="https://vmol.org/ " target="_blank">'
97+
f'<img src="data:image/png;base64,{base64.b64encode(open("assets/vmol-icon.png", "rb").read()).decode()}" width="300">'
98+
'</a>',
99+
unsafe_allow_html=True,
100+
)
63101
v_space(1)
102+
64103
st.markdown("## Functional-Metabolomics-Lab")
65104
c1, c2, c3 = st.columns(3)
66105
c1.markdown(
@@ -72,20 +111,20 @@ def page_setup():
72111
unsafe_allow_html=True,
73112
)
74113
c2.markdown(
75-
"""<a href="https://www.youtube.com/@functionalmetabolomics">
114+
"""<a href="https://www.functional-metabolomics.com/">
76115
<img src="data:image/png;base64,{}" width="50">
77116
</a>""".format(
78-
base64.b64encode(open("./assets/youtube-logo.png", "rb").read()).decode()
117+
base64.b64encode(open("./assets/fmlab_logo_colored.png", "rb").read()).decode()
79118
),
80119
unsafe_allow_html=True,
81120
)
82121
c3.markdown(
83-
"""<a href="https://twitter.com/func_metabo_lab">
122+
"""<a href="https://www.youtube.com/@functionalmetabolomics">
84123
<img src="data:image/png;base64,{}" width="50">
85124
</a>""".format(
86-
base64.b64encode(open("./assets/x-logo.png", "rb").read()).decode()
125+
base64.b64encode(open("./assets/youtube-logo.png", "rb").read()).decode()
87126
),
88-
unsafe_allow_html=True
127+
unsafe_allow_html=True,
89128
)
90129

91130

src/fileselection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def load_example():
5353
md = open_df("example-data/MetaData.txt").set_index("filename")
5454
return ft, md
5555

56-
@st.cache_data
56+
5757
def load_from_gnps(task_id, cmn=False):
5858

5959
try: # GNPS2 will run here

src/pcoa.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import skbio
66
from scipy.spatial import distance
77

8-
8+
@st.cache_data
99
def permanova_pcoa(scaled, distance_matrix, attribute):
1010
# Create the distance matrix from the original data
1111
distance_matrix = skbio.stats.distance.DistanceMatrix(

src/randomforest.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from sklearn.metrics import classification_report
1010
from sklearn.metrics import confusion_matrix, accuracy_score
1111

12-
@st.cache_data
1312
def run_random_forest(attribute, n_trees, random_seed=None):
1413
# initialize a log to print out in the app later
1514
log = ""

src/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,8 @@ def download_plotly_figure(fig, col=None, filename=""):
133133
file_name=filename,
134134
mime="application/png",
135135
)
136+
137+
# Button to clear the cache
138+
if st.button("Clear Cache"):
139+
st.cache_data.clear()
140+
st.success("Cache cleared!")

0 commit comments

Comments
 (0)