Massimo G. Totaro commited on
Commit
4f4563b
·
1 Parent(s): 8677ef1
Files changed (5) hide show
  1. README.md +14 -0
  2. app.py +10 -5
  3. data.py +5 -6
  4. instructions.md +6 -10
  5. requirements.txt +0 -1
README.md CHANGED
@@ -8,6 +8,20 @@ sdk_version: 5.5.0
8
  app_file: app.py
9
  pinned: false
10
  license: bsd-2-clause
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  app_file: app.py
9
  pinned: false
10
  license: bsd-2-clause
11
+ preload_from_hub:
12
+ - facebook/esm-1b
13
+ - facebook/esm2_t6_8M_UR50D
14
+ - facebook/esm2_t33_650M_UR50D
15
+ - facebook/esm2_t30_150M_UR50D
16
+ - facebook/esm2_t12_35M_UR50D
17
+ - facebook/esm1b_t33_650M_UR50S
18
+ - facebook/esm2_t36_3B_UR50D
19
+ - facebook/esm2_t48_15B_UR50D
20
+ - facebook/esm1v_t33_650M_UR90S_5
21
+ - facebook/esm1v_t33_650M_UR90S_4
22
+ - facebook/esm1v_t33_650M_UR90S_3
23
+ - facebook/esm1v_t33_650M_UR90S_2
24
+ - facebook/esm1v_t33_650M_UR90S_1
25
  ---
26
 
27
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from gradio import Blocks, Button, Checkbox, DownloadButton, Dropdown, Examples, File, Image, Markdown, Textbox
2
 
3
  from model import get_models
4
  from data import Data
@@ -19,8 +19,12 @@ def app(*argv):
19
  # Calculate the data based on the input parameters
20
  data = Data(seq, trg, model_name, scoring).calculate()
21
 
22
- # If no error occurs, return the calculated data
23
- return Image(value=data.image(), type='filepath', visible=True), DownloadButton(value=data.csv(), visible=True)
 
 
 
 
24
 
25
  # Create the Gradio interface
26
  with open("instructions.md", "r", encoding="utf-8") as md, Blocks() as esm_scan:
@@ -41,13 +45,14 @@ with open("instructions.md", "r", encoding="utf-8") as md, Blocks() as esm_scan:
41
  )
42
  model_name = Dropdown(MODELS, label="Model", value="facebook/esm2_t30_150M_UR50D")
43
  scoring_strategy = Checkbox(value=True, label="Use higher accuracy scoring", interactive=True)
 
44
  dlb = DownloadButton(label="Download raw data", visible=False)
45
  out = Image(visible=False)
46
- btn = Button(value="Run", variant="primary")
47
  btn.click(
48
  fn=app,
49
  inputs=[seq, trg, model_name],
50
- outputs=[out, dlb]
51
  )
52
  ex = Examples(
53
  examples=[
 
1
+ from gradio import Blocks, Button, Checkbox, DataFrame, DownloadButton, Dropdown, Examples, File, Image, Markdown, Textbox
2
 
3
  from model import get_models
4
  from data import Data
 
19
  # Calculate the data based on the input parameters
20
  data = Data(seq, trg, model_name, scoring).calculate()
21
 
22
+ if isinstance(data.image(), str):
23
+ out = Image(value=data.image(), type='filepath', visible=True), DataFrame(visible=False)
24
+ else:
25
+ out = Image(visible=False), DataFrame(value=data.image(), visible=True)
26
+
27
+ return *out, DownloadButton(value=data.csv(), visible=True)
28
 
29
  # Create the Gradio interface
30
  with open("instructions.md", "r", encoding="utf-8") as md, Blocks() as esm_scan:
 
45
  )
46
  model_name = Dropdown(MODELS, label="Model", value="facebook/esm2_t30_150M_UR50D")
47
  scoring_strategy = Checkbox(value=True, label="Use higher accuracy scoring", interactive=True)
48
+ btn = Button(value="Run", variant="primary")
49
  dlb = DownloadButton(label="Download raw data", visible=False)
50
  out = Image(visible=False)
51
+ ouu = DataFrame(visible=False)
52
  btn.click(
53
  fn=app,
54
  inputs=[seq, trg, model_name],
55
+ outputs=[out, ouu, dlb]
56
  )
57
  ex = Examples(
58
  examples=[
data.py CHANGED
@@ -1,4 +1,3 @@
1
- import dataframe_image as dfi
2
  from math import ceil
3
  import matplotlib.pyplot as plt
4
  import pandas as pd
@@ -86,11 +85,11 @@ class Data:
86
  self.sort_by_score()
87
  else:
88
  raise RuntimeError(f"Unrecognised mode {self.mode}")
89
- out_df = (self.out.style
90
- .format(lambda x: f'{x:.2f}' if isinstance(x, float) else x)
91
- .hide(axis=0).hide(axis=1)
92
- .background_gradient(cmap="RdYlGn", vmax=8, vmin=-8))
93
- dfi.export(out_df, self.out_img, max_rows=-1, max_cols=-1, dpi=300)
94
  self.out.to_csv(self.out_csv, float_format='%.2f', index=False, header=False)
95
 
96
  def sort_by_score(self):
 
 
1
  from math import ceil
2
  import matplotlib.pyplot as plt
3
  import pandas as pd
 
85
  self.sort_by_score()
86
  else:
87
  raise RuntimeError(f"Unrecognised mode {self.mode}")
88
+ self.out.columns = [str(i) for i in range(self.out.shape[1])]
89
+ self.out_img = (self.out.style
90
+ .format(lambda x: f'{x:.2f}' if isinstance(x, float) else x)
91
+ .hide(axis=0)
92
+ .background_gradient(cmap="RdYlGn", vmax=8, vmin=-8))
93
  self.out.to_csv(self.out_csv, float_format='%.2f', index=False, header=False)
94
 
95
  def sort_by_score(self):
instructions.md CHANGED
@@ -2,10 +2,6 @@
2
 
3
  Calculate the <u>fitness of single amino acid substitutions</u> on proteins, using a [zero-shot](https://doi.org/10.1101/2021.07.09.450648) [language model predictor](https://github.com/facebookresearch/esm)
4
 
5
- If you use this tool in your research, please cite:
6
- - Totaro, M.G. (2023). “ESM-Scan - a tool to guide amino acid substitutions.” bioRxiv. [doi.org/10.1101/2023.12.12.571273](https://doi.org/10.1101/2023.12.12.571273)
7
- - Meier, J. (2021). “Language Models Enable Zero-Shot Prediction of the Effects of Mutations on Protein Function.” bioRxiv (Cold Spring Harbor Laboratory), July. [doi.org/10.1101/2021.07.09.450648](https://doi.org/10.1101/2021.07.09.450648)
8
-
9
  <details>
10
  <summary> <b> USAGE INSTRUCTIONS </b> </summary>
11
 
@@ -45,21 +41,21 @@ If the server remains idle for a period, it will enter standby mode. Running a c
45
  Results are displayed in a color-coded table, except for deep mutational scans, which produce a heatmap.
46
  In the table:
47
 
48
- - Beneficial substitutions are highlighted in blue with positive values.
49
- - Detrimental substitutions appear in red with negative values.
50
 
51
  As a rule of thumb, score differences of *4* or more are considered significant. For instance:
52
 
53
  - A substitution scoring *-6* is likely detrimental to protein functionality.
54
  - A score of *+2* is generally regarded as neutral.
55
 
56
- You can download the output raw data from the **button at the bottom of the page.
57
 
58
- <b>
59
- If you use this tool in your research, please cite:
60
 
61
  - Totaro, M.G. (2023). “ESM-Scan - a tool to guide amino acid substitutions.” bioRxiv. [doi.org/10.1101/2023.12.12.571273](https://doi.org/10.1101/2023.12.12.571273)
62
  - Meier, J. (2021). “Language Models Enable Zero-Shot Prediction of the Effects of Mutations on Protein Function.” bioRxiv (Cold Spring Harbor Laboratory), July. [doi.org/10.1101/2021.07.09.450648](https://doi.org/10.1101/2021.07.09.450648)
63
- </b>
64
 
65
  </details>
 
 
2
 
3
  Calculate the <u>fitness of single amino acid substitutions</u> on proteins, using a [zero-shot](https://doi.org/10.1101/2021.07.09.450648) [language model predictor](https://github.com/facebookresearch/esm)
4
 
 
 
 
 
5
  <details>
6
  <summary> <b> USAGE INSTRUCTIONS </b> </summary>
7
 
 
41
  Results are displayed in a color-coded table, except for deep mutational scans, which produce a heatmap.
42
  In the table:
43
 
44
+ - Beneficial substitutions are highlighted in green with positive values.
45
+ - Detrimental substitutions appear in red with negative values.
46
 
47
  As a rule of thumb, score differences of *4* or more are considered significant. For instance:
48
 
49
  - A substitution scoring *-6* is likely detrimental to protein functionality.
50
  - A score of *+2* is generally regarded as neutral.
51
 
52
+ The **Download raw data** button lets you download the output in CSV format.
53
 
54
+
55
+ **If you use this tool in your research, please cite**:
56
 
57
  - Totaro, M.G. (2023). “ESM-Scan - a tool to guide amino acid substitutions.” bioRxiv. [doi.org/10.1101/2023.12.12.571273](https://doi.org/10.1101/2023.12.12.571273)
58
  - Meier, J. (2021). “Language Models Enable Zero-Shot Prediction of the Effects of Mutations on Protein Function.” bioRxiv (Cold Spring Harbor Laboratory), July. [doi.org/10.1101/2021.07.09.450648](https://doi.org/10.1101/2021.07.09.450648)
 
59
 
60
  </details>
61
+
requirements.txt CHANGED
@@ -1,4 +1,3 @@
1
- dataframe-image
2
  gradio
3
  pandas
4
  seaborn
 
 
1
  gradio
2
  pandas
3
  seaborn