Spaces:
Build error
Build error
Commit
·
8c638cc
1
Parent(s):
7275554
Improved visual rendering large scoring matrices via Gallery
Browse files
app.py
CHANGED
@@ -21,7 +21,27 @@ tokenizer = PreTrainedTokenizerFast(tokenizer_file="./tranception/utils/tokenize
|
|
21 |
############################################### HELPER FUNCTIONS ####################################################################
|
22 |
#######################################################################################################################################
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
AA_vocab = "ACDEFGHIKLMNPQRSTVWY"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
def create_all_single_mutants(sequence,AA_vocab=AA_vocab,mutation_range_start=None,mutation_range_end=None):
|
26 |
all_single_mutants={}
|
27 |
sequence_list=list(sequence)
|
@@ -38,13 +58,14 @@ def create_all_single_mutants(sequence,AA_vocab=AA_vocab,mutation_range_start=No
|
|
38 |
all_single_mutants.columns = ['mutant','mutated_sequence']
|
39 |
return all_single_mutants
|
40 |
|
41 |
-
def create_scoring_matrix_visual(scores,sequence,
|
42 |
-
|
43 |
-
|
44 |
-
piv=
|
45 |
-
|
|
|
46 |
scores_dict = {}
|
47 |
-
valid_mutant_set=set(
|
48 |
ax.tick_params(bottom=True, top=True, left=True, right=True)
|
49 |
ax.tick_params(labelbottom=True, labeltop=True, labelleft=True, labelright=True)
|
50 |
if annotate:
|
@@ -52,10 +73,10 @@ def create_scoring_matrix_visual(scores,sequence,AA_vocab=AA_vocab,mutation_rang
|
|
52 |
for target_AA in list(AA_vocab):
|
53 |
mutant = sequence[position-1]+str(position)+target_AA
|
54 |
if mutant in valid_mutant_set:
|
55 |
-
scores_dict[mutant]= float(
|
56 |
else:
|
57 |
scores_dict[mutant]=0.0
|
58 |
-
labels = (np.asarray(["{} \n {:.4f}".format(symb,value) for symb, value in scores_dict.items() ])).reshape(
|
59 |
heat = sns.heatmap(piv,annot=labels,fmt="",cmap='RdYlGn',linewidths=0.30,ax=ax,vmin=np.percentile(scores.avg_score,2),vmax=np.percentile(scores.avg_score,98),\
|
60 |
cbar_kws={'label': 'Log likelihood ratio (mutant / starting sequence)'},annot_kws={"size": fontsize})
|
61 |
else:
|
@@ -71,9 +92,10 @@ def create_scoring_matrix_visual(scores,sequence,AA_vocab=AA_vocab,mutation_rang
|
|
71 |
heat.set_xticklabels(heat.get_xmajorticklabels(), fontsize = fontsize)
|
72 |
heat.set_yticklabels(heat.get_ymajorticklabels(), fontsize = fontsize, rotation=0)
|
73 |
plt.tight_layout()
|
74 |
-
|
|
|
75 |
plt.show()
|
76 |
-
return
|
77 |
|
78 |
def suggest_mutations(scores):
|
79 |
intro_message = "The following mutations may be sensible options to improve fitness: \n\n"
|
@@ -106,7 +128,11 @@ def get_mutated_protein(sequence,mutant):
|
|
106 |
mutated_sequence[int(mutant[1:-1])-1]=mutant[-1]
|
107 |
return ''.join(mutated_sequence)
|
108 |
|
109 |
-
def score_and_create_matrix_all_singles(sequence,mutation_range_start=None,mutation_range_end=None,model_type="Small",scoring_mirror=False,batch_size_inference=20,num_workers=0,AA_vocab=AA_vocab):
|
|
|
|
|
|
|
|
|
110 |
if model_type=="Small":
|
111 |
model = tranception.model_pytorch.TranceptionLMHeadModel.from_pretrained(pretrained_model_name_or_path="PascalNotin/Tranception_Small")
|
112 |
elif model_type=="Medium":
|
@@ -130,8 +156,18 @@ def score_and_create_matrix_all_singles(sequence,mutation_range_start=None,mutat
|
|
130 |
scores = pd.merge(scores,all_single_mutants,on="mutated_sequence",how="left")
|
131 |
scores["position"]=scores["mutant"].map(lambda x: int(x[1:-1]))
|
132 |
scores["target_AA"] = scores["mutant"].map(lambda x: x[-1])
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
def extract_sequence(example):
|
137 |
label, taxon, sequence = example
|
@@ -150,8 +186,8 @@ def clear_inputs(protein_sequence_input,mutation_range_start,mutation_range_end)
|
|
150 |
tranception_design = gr.Blocks()
|
151 |
|
152 |
with tranception_design:
|
153 |
-
gr.Markdown("#
|
154 |
-
gr.Markdown(" Perform in silico directed evolution with Tranception to iteratively improve the fitness of a protein of interest, one mutation at a time. At each step, the Tranception model computes the log likelihood ratios of all possible single amino acid
|
155 |
|
156 |
with gr.Tabs():
|
157 |
with gr.TabItem("Input"):
|
@@ -162,8 +198,8 @@ with tranception_design:
|
|
162 |
)
|
163 |
|
164 |
with gr.Row():
|
165 |
-
mutation_range_start = gr.Number(label="Start of mutation window (first position indexed at 1)",value=1,precision=0)
|
166 |
-
mutation_range_end = gr.Number(label="End of mutation window (leave empty for full lenth)",value=10,precision=0)
|
167 |
|
168 |
with gr.TabItem("Parameters"):
|
169 |
with gr.Row():
|
@@ -172,6 +208,8 @@ with tranception_design:
|
|
172 |
value="Small")
|
173 |
with gr.Row():
|
174 |
scoring_mirror = gr.Checkbox(label="Score protein from both directions (leads to more robust fitness predictions, but doubles inference time)")
|
|
|
|
|
175 |
with gr.Row():
|
176 |
gr.Markdown("Note: the current version does not leverage retrieval of homologs at inference time to increase fitness prediction performance.")
|
177 |
with gr.Row():
|
@@ -187,20 +225,20 @@ with tranception_design:
|
|
187 |
['ADRB2_HUMAN' ,'Human', 'MGQPGNGSAFLLAPNGSHAPDHDVTQERDEVWVVGMGIVMSLIVLAIVFGNVLVITAIAKFERLQTVTNYFITSLACADLVMGLAVVPFGAAHILMKMWTFGNFWCEFWTSIDVLCVTASIETLCVIAVDRYFAITSPFKYQSLLTKNKARVIILMVWIVSGLTSFLPIQMHWYRATHQEAINCYANETCCDFFTNQAYAIASSIVSFYVPLVIMVFVYSRVFQEAKRQLQKIDKSEGRFHVQNLSQVEQDGRTGHGLRRSSKFCLKEHKALKTLGIIMGTFTLCWLPFFIVNIVHVIQDNLIRKEVYILLNWIGYVNSGFNPLIYCRSPDFRIAFQELLCLRRSSLKAYGNGYSSNGNTGEQSGYHVEQEKENKLLCEDLPGTEDFVGHQGTVPSDNIDSQGRNCSTNDSLL'],
|
188 |
['IF1_ECOLI' ,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 @@ with tranception_design:
|
|
209 |
gr.Markdown("<br>")
|
210 |
gr.Markdown("# Fitness predictions for all single amino acid substitutions in mutation range")
|
211 |
gr.Markdown("Inference may take a few seconds for short proteins & mutation ranges to several minutes for longer ones")
|
212 |
-
#output_plot = gr.Plot(label="Fitness predictions for all single amino acid substitutions in mutation range")
|
213 |
-
#output_image = gr.Image(label="Fitness predictions for all single amino acid substitutions in mutation range",type="filepath")
|
214 |
output_image = gr.Gallery(label="Fitness predictions for all single amino acid substitutions in mutation range",type="filepath") #Using Gallery to be able to scroll large matrix images
|
215 |
|
216 |
output_recommendations = gr.Textbox(label="Mutation recommendations")
|
@@ -222,7 +258,7 @@ with tranception_design:
|
|
222 |
)
|
223 |
run_button.click(
|
224 |
fn=score_and_create_matrix_all_singles,
|
225 |
-
inputs=[protein_sequence_input,mutation_range_start,mutation_range_end,model_size_selection,scoring_mirror],
|
226 |
outputs=[output_image,output_recommendations],
|
227 |
)
|
228 |
gr.Markdown("# Mutate the starting protein sequence")
|
|
|
21 |
############################################### HELPER FUNCTIONS ####################################################################
|
22 |
#######################################################################################################################################
|
23 |
|
24 |
+
import torch
|
25 |
+
import transformers
|
26 |
+
from transformers import PreTrainedTokenizerFast
|
27 |
+
import tranception
|
28 |
+
import datasets
|
29 |
+
from tranception import config, model_pytorch
|
30 |
+
import pandas as pd
|
31 |
+
import matplotlib.pyplot as plt
|
32 |
+
import seaborn as sns
|
33 |
+
import numpy as np
|
34 |
+
import gradio as gr
|
35 |
+
|
36 |
AA_vocab = "ACDEFGHIKLMNPQRSTVWY"
|
37 |
+
tokenizer = PreTrainedTokenizerFast(tokenizer_file="./tranception/utils/tokenizers/Basic_tokenizer",
|
38 |
+
unk_token="[UNK]",
|
39 |
+
sep_token="[SEP]",
|
40 |
+
pad_token="[PAD]",
|
41 |
+
cls_token="[CLS]",
|
42 |
+
mask_token="[MASK]"
|
43 |
+
)
|
44 |
+
|
45 |
def create_all_single_mutants(sequence,AA_vocab=AA_vocab,mutation_range_start=None,mutation_range_end=None):
|
46 |
all_single_mutants={}
|
47 |
sequence_list=list(sequence)
|
|
|
58 |
all_single_mutants.columns = ['mutant','mutated_sequence']
|
59 |
return all_single_mutants
|
60 |
|
61 |
+
def create_scoring_matrix_visual(scores,sequence,image_index=0,mutation_range_start=None,mutation_range_end=None,AA_vocab=AA_vocab,annotate=True,fontsize=20):
|
62 |
+
filtered_scores=scores.copy()
|
63 |
+
filtered_scores=filtered_scores[filtered_scores.position.isin(range(mutation_range_start,mutation_range_end+1))]
|
64 |
+
piv=filtered_scores.pivot(index='position',columns='target_AA',values='avg_score').round(4)
|
65 |
+
mutation_range_len = mutation_range_end - mutation_range_start + 1
|
66 |
+
fig, ax = plt.subplots(figsize=(50,mutation_range_len))
|
67 |
scores_dict = {}
|
68 |
+
valid_mutant_set=set(filtered_scores.mutant)
|
69 |
ax.tick_params(bottom=True, top=True, left=True, right=True)
|
70 |
ax.tick_params(labelbottom=True, labeltop=True, labelleft=True, labelright=True)
|
71 |
if annotate:
|
|
|
73 |
for target_AA in list(AA_vocab):
|
74 |
mutant = sequence[position-1]+str(position)+target_AA
|
75 |
if mutant in valid_mutant_set:
|
76 |
+
scores_dict[mutant]= float(filtered_scores.loc[filtered_scores.mutant==mutant,'avg_score'])
|
77 |
else:
|
78 |
scores_dict[mutant]=0.0
|
79 |
+
labels = (np.asarray(["{} \n {:.4f}".format(symb,value) for symb, value in scores_dict.items() ])).reshape(mutation_range_len,len(AA_vocab))
|
80 |
heat = sns.heatmap(piv,annot=labels,fmt="",cmap='RdYlGn',linewidths=0.30,ax=ax,vmin=np.percentile(scores.avg_score,2),vmax=np.percentile(scores.avg_score,98),\
|
81 |
cbar_kws={'label': 'Log likelihood ratio (mutant / starting sequence)'},annot_kws={"size": fontsize})
|
82 |
else:
|
|
|
92 |
heat.set_xticklabels(heat.get_xmajorticklabels(), fontsize = fontsize)
|
93 |
heat.set_yticklabels(heat.get_ymajorticklabels(), fontsize = fontsize, rotation=0)
|
94 |
plt.tight_layout()
|
95 |
+
image_path = 'fitness_scoring_substitution_matrix_{}.png'.format(image_index)
|
96 |
+
plt.savefig(image_path,dpi=100)
|
97 |
plt.show()
|
98 |
+
return image_path
|
99 |
|
100 |
def suggest_mutations(scores):
|
101 |
intro_message = "The following mutations may be sensible options to improve fitness: \n\n"
|
|
|
128 |
mutated_sequence[int(mutant[1:-1])-1]=mutant[-1]
|
129 |
return ''.join(mutated_sequence)
|
130 |
|
131 |
+
def score_and_create_matrix_all_singles(sequence,mutation_range_start=None,mutation_range_end=None,model_type="Small",scoring_mirror=False,batch_size_inference=20,max_number_positions_per_heatmap=50,num_workers=0,AA_vocab=AA_vocab):
|
132 |
+
if mutation_range_start is None: mutation_range_start=1
|
133 |
+
if mutation_range_end is None: mutation_range_end=len(sequence)
|
134 |
+
assert len(sequence) > 0, "no sequence entered"
|
135 |
+
assert mutation_range_start <= mutation_range_end, "mutation range is invalid"
|
136 |
if model_type=="Small":
|
137 |
model = tranception.model_pytorch.TranceptionLMHeadModel.from_pretrained(pretrained_model_name_or_path="PascalNotin/Tranception_Small")
|
138 |
elif model_type=="Medium":
|
|
|
156 |
scores = pd.merge(scores,all_single_mutants,on="mutated_sequence",how="left")
|
157 |
scores["position"]=scores["mutant"].map(lambda x: int(x[1:-1]))
|
158 |
scores["target_AA"] = scores["mutant"].map(lambda x: x[-1])
|
159 |
+
score_heatmaps = []
|
160 |
+
mutation_range = mutation_range_end - mutation_range_start + 1
|
161 |
+
number_heatmaps = int((mutation_range - 1) / max_number_positions_per_heatmap) + 1
|
162 |
+
image_index = 0
|
163 |
+
window_start = mutation_range_start
|
164 |
+
window_end = min(mutation_range_end,mutation_range_start+max_number_positions_per_heatmap-1)
|
165 |
+
for image_index in range(number_heatmaps):
|
166 |
+
score_heatmaps.append(create_scoring_matrix_visual(scores,sequence,image_index,window_start,window_end,AA_vocab))
|
167 |
+
window_start += max_number_positions_per_heatmap
|
168 |
+
window_end = min(mutation_range_end,window_start+max_number_positions_per_heatmap-1)
|
169 |
+
print(score_heatmaps)
|
170 |
+
return score_heatmaps, suggest_mutations(scores)
|
171 |
|
172 |
def extract_sequence(example):
|
173 |
label, taxon, sequence = example
|
|
|
186 |
tranception_design = gr.Blocks()
|
187 |
|
188 |
with tranception_design:
|
189 |
+
gr.Markdown("# Interactive in silico directed evolution with Tranception")
|
190 |
+
gr.Markdown(" Perform in silico directed evolution with Tranception to iteratively improve the fitness of a protein of interest, one mutation at a time. At each step, the Tranception model computes the log likelihood ratios of all possible single amino acid substitution Vs the starting sequence, and outputs a fitness heatmap and recommandations to guide the selection of the mutation to apply.")
|
191 |
|
192 |
with gr.Tabs():
|
193 |
with gr.TabItem("Input"):
|
|
|
198 |
)
|
199 |
|
200 |
with gr.Row():
|
201 |
+
mutation_range_start = gr.Number(label="Start of mutation window (first position indexed at 1)", value=1, precision=0)
|
202 |
+
mutation_range_end = gr.Number(label="End of mutation window (leave empty for full lenth)", value=10, precision=0)
|
203 |
|
204 |
with gr.TabItem("Parameters"):
|
205 |
with gr.Row():
|
|
|
208 |
value="Small")
|
209 |
with gr.Row():
|
210 |
scoring_mirror = gr.Checkbox(label="Score protein from both directions (leads to more robust fitness predictions, but doubles inference time)")
|
211 |
+
with gr.Row():
|
212 |
+
batch_size_inference = gr.Number(label="Model batch size at inference time",value = 100, precision=0)
|
213 |
with gr.Row():
|
214 |
gr.Markdown("Note: the current version does not leverage retrieval of homologs at inference time to increase fitness prediction performance.")
|
215 |
with gr.Row():
|
|
|
225 |
['ADRB2_HUMAN' ,'Human', 'MGQPGNGSAFLLAPNGSHAPDHDVTQERDEVWVVGMGIVMSLIVLAIVFGNVLVITAIAKFERLQTVTNYFITSLACADLVMGLAVVPFGAAHILMKMWTFGNFWCEFWTSIDVLCVTASIETLCVIAVDRYFAITSPFKYQSLLTKNKARVIILMVWIVSGLTSFLPIQMHWYRATHQEAINCYANETCCDFFTNQAYAIASSIVSFYVPLVIMVFVYSRVFQEAKRQLQKIDKSEGRFHVQNLSQVEQDGR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LLDDGEIKEDTSFAENDIKESSAVFSKSVQKGELSRSPSPFTHTHLAQGYRRGAKKLESSEENLSSEDEELPCFQHLLFGKVNNIPSQSTRHSTVATECLSKNTEENLLSLKNSLNDCSNQVILAKASQEHHLSEETKCSASLFSSQCSELEDLTANTNTQDPFLIGSSKQMRHQSESQGVGLSDKELVSDDEERGTGLEENNQEEQSMDSNLGEAASGCESETSVSEDCSGLSSQSDILTTQQRDTMQHNLIKLQQEMAELEAVLEQHGSQPSNSYPSIISDSSALEDLRNPEQSTSEKAVLTSQKSSEYPISQNPEGLSADKFEVSADSSTSKNKEPGVERSSPSKCPSLDDRWYMHSCSGSLQNRNYPSQEELIKVVDVEEQQLEESGPHDLTETSYLPRQDLEGTPYLESGISLFSDDPESDPSEDRAPESARVGNIPSSTSALKVPQLKVAESAQSPAAAHTTDTAGYNAMEESVSREKPELTASTERVNKRMSMVVSGLTPEEFMLVYKFARKHHITLTNLITEETTHVVMKTDAEFVCERTLKYFLGIAGGKWVVSYFWVTQSIKERKMLNEHDFEVRGDVVNGRNHQGPKRARESQDRKIFRGLEICCYGPFTNMPTDQLEWMVQLCGASVVKELSSFTLGTGVHPIVVVQPDAWTEDNGFHAIGQMCEAPVVTREWVLDSVALYQCQELDTYLIPQIPHSHY'],
|
230 |
['CALM1_HUMAN' ,'Human', 'MADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTIDFPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREADIDGDGQVNYEEFVQMMTAK'],
|
231 |
+
['CCDB_ECOLI' ,'Prokaryote', 'MQFKVYTYKRESRYRLFVDVQSDIIDTPGRRMVIPLASARLLSDKVSRELYPVVHIGDESWRMMTTDMASVPVSVIGEEVADLSHRENDIKNAINLMFWGI'],
|
232 |
+
['GFP_AEQVI' ,'Other eukaryote', 'MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICT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CSEGSTADMTNTAELLEQIPDLGQDVKDPEDCFTEGCVRRCPCCAVDTTQAPGKVWWRLRKTCYHIVEHSWFETFIIFMILLSSGALAFEDIYLEERKTIKVLLEYADKMFTYVFVLEMLLKWVAYGFKKYFTNAWCWLDFLIVDVSLVSLVANTLGFAEMGPIKSLRTLRALRPLRALSRFEGMRVVVNALVGAIPSIMNVLLVCLIFWLIFSIMGVNLFAGKFGRCINQTEGDLPLNYTIVNNKSQCESLNLTGELYWTKVKVNFDNVGAGYLALLQVATFKGWMDIMYAAVDSRGYEEQPQWEYNLYMYIYFVIFIIFGSFFTLNLFIGVIIDNFNQQKKKLGGQDIFMTEEQKKYYNAMKKLGSKKPQKPIPRPLNKYQGFIFDIVTKQAFDVTIMFLICLNMVTMMVETDDQSPEKINILAKINLLFVAIFTGECIVKLAALRHYYFTNSWNIFDFVVVILSIVGTVLSDIIQKYFFSPTLFRVIRLARIGRILRLIRGAKGIRTLLFALMMSLPALFNIGLLLFLVMFIYSIFGMANFAYVKWEAGIDDMFNFQTFANSMLCLFQITTSAGWDGLLSPILNTGPPYCDPTLPNSNGSRGDCGSPAVGILFFTTYIIISFLIVVNMYIAIILENFSVATEESTEPLSEDDFDMFYEIWEKFDPEATQFIEYSVLSDFADALSEPLRIAKPNQISLINMDLPMVSGDRIHCMDILFAFTKRVLGESGEMDALKIQMEEKFMAANPSKISYEPITTTLRRKHEEVSAMVIQRAFRRHLLQRSLKHASFLFRQQAGSGLSEEDAPEREGLIAYVMSENFSRPLGPPSSSSISSTSFPPSYDSVTRATSDNLQVRGSDYSHSEDLADFPPSPDRDRESIV'],
|
244 |
['SUMO1_HUMAN' ,'Human', 'MSDQEAKPSTEDLGDKKEGEYIKLKVIGQDSSEIHFKVKMTTHLKKLKESYCQRQGVPMNSLRFLFEGQRIADNHTPKELGMEEEDVIEVYQEQTGGHSTV']
|
|
|
247 |
gr.Markdown("<br>")
|
248 |
gr.Markdown("# Fitness predictions for all single amino acid substitutions in mutation range")
|
249 |
gr.Markdown("Inference may take a few seconds for short proteins & mutation ranges to several minutes for longer ones")
|
|
|
|
|
250 |
output_image = gr.Gallery(label="Fitness predictions for all single amino acid substitutions in mutation range",type="filepath") #Using Gallery to be able to scroll large matrix images
|
251 |
|
252 |
output_recommendations = gr.Textbox(label="Mutation recommendations")
|
|
|
258 |
)
|
259 |
run_button.click(
|
260 |
fn=score_and_create_matrix_all_singles,
|
261 |
+
inputs=[protein_sequence_input,mutation_range_start,mutation_range_end,model_size_selection,scoring_mirror,batch_size_inference],
|
262 |
outputs=[output_image,output_recommendations],
|
263 |
)
|
264 |
gr.Markdown("# Mutate the starting protein sequence")
|