Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ LLR_FILE='ALL_hum_isoforms_ESM1b_LLR.zip'
|
|
11 |
|
12 |
df=pd.read_csv('isoform_list.csv',index_col=0)
|
13 |
uids=list(df.index.values)
|
|
|
14 |
|
15 |
def load_LLR(uniprot_id):
|
16 |
'''Loads the LLRs for a given uniprot id. Returns a 20xL dataframe
|
@@ -23,7 +24,7 @@ def load_LLR(uniprot_id):
|
|
23 |
return pd.read_csv(data,index_col=0)
|
24 |
|
25 |
|
26 |
-
def plot_interactive(uniprot_id):
|
27 |
primaryLLR = load_LLR(uniprot_id)
|
28 |
|
29 |
template='plotly_white'
|
@@ -46,6 +47,30 @@ def plot_interactive(uniprot_id):
|
|
46 |
" (%{z:.2f})",
|
47 |
])+'<extra></extra>'
|
48 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
return fig
|
51 |
|
@@ -53,6 +78,8 @@ def plot_interactive(uniprot_id):
|
|
53 |
selection = st.selectbox("uniprot_id:", df)
|
54 |
uid=df[df.txt==selection].index.values[0]
|
55 |
|
56 |
-
|
|
|
|
|
57 |
fig.update_layout(width = 800, height = 600, autosize = False)
|
58 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
11 |
|
12 |
df=pd.read_csv('isoform_list.csv',index_col=0)
|
13 |
uids=list(df.index.values)
|
14 |
+
clinvar = pd.read_csv('clinvar.csv.gz')
|
15 |
|
16 |
def load_LLR(uniprot_id):
|
17 |
'''Loads the LLRs for a given uniprot id. Returns a 20xL dataframe
|
|
|
24 |
return pd.read_csv(data,index_col=0)
|
25 |
|
26 |
|
27 |
+
def plot_interactive(uniprot_id, show_clinvar=False):
|
28 |
primaryLLR = load_LLR(uniprot_id)
|
29 |
|
30 |
template='plotly_white'
|
|
|
47 |
" (%{z:.2f})",
|
48 |
])+'<extra></extra>'
|
49 |
)
|
50 |
+
if show_clinvar:
|
51 |
+
iso_clinvar = clinvar[clinvar.LLR_file_id == uniprot_id]
|
52 |
+
hwt_x=[]
|
53 |
+
hwt_y=[]
|
54 |
+
cust=[]
|
55 |
+
for i in primaryLLR.columns:
|
56 |
+
for j in list(primaryLLR.index):
|
57 |
+
mut = i[0]+i[2:]+j
|
58 |
+
if mut in iso_clinvar.variant:
|
59 |
+
hwt_x+=[i]
|
60 |
+
hwt_y+=[j]
|
61 |
+
cust+=[primaryLLR.loc[j,i]]
|
62 |
+
|
63 |
+
fig.add_trace(go.Scatter(
|
64 |
+
x=hwt_x,
|
65 |
+
y=hwt_y,
|
66 |
+
customdata=cust,
|
67 |
+
mode='markers',
|
68 |
+
marker=dict(size=8),
|
69 |
+
hovertemplate="<br>".join([
|
70 |
+
"<b>%{x} %{y}</b>"+
|
71 |
+
" (%{customdata:.2f})",
|
72 |
+
])+'<extra></extra>')
|
73 |
+
)
|
74 |
|
75 |
return fig
|
76 |
|
|
|
78 |
selection = st.selectbox("uniprot_id:", df)
|
79 |
uid=df[df.txt==selection].index.values[0]
|
80 |
|
81 |
+
show_clinvar = st.checkbox('show clinvar annotations')
|
82 |
+
|
83 |
+
fig = plot_interactive(uid,show_clinvar=show_clinvar)
|
84 |
fig.update_layout(width = 800, height = 600, autosize = False)
|
85 |
st.plotly_chart(fig, use_container_width=True)
|