Spaces:
Running
Running
supercat666
commited on
Commit
•
82aadd9
1
Parent(s):
78c921d
add igv
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import cas9off
|
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
from pathlib import Path
|
|
|
8 |
|
9 |
# title and documentation
|
10 |
st.markdown(Path('crisprTool.md').read_text(), unsafe_allow_html=True)
|
@@ -91,38 +92,36 @@ if selected_model == 'Cas9':
|
|
91 |
)
|
92 |
|
93 |
if target_selection == 'on-target':
|
94 |
-
# Gene symbol entry
|
95 |
gene_symbol = st.text_input('Enter a Gene Symbol:', key='gene_symbol')
|
96 |
|
97 |
-
#
|
|
|
|
|
98 |
predict_button = st.button('Predict on-target')
|
99 |
|
100 |
-
# Process predictions
|
101 |
if predict_button and gene_symbol:
|
102 |
predictions = cas9on.process_gene(gene_symbol, cas9on_path)
|
103 |
-
# Store only first 10 for display and save full predictions for download
|
104 |
st.session_state['on_target_results'] = predictions[:10]
|
105 |
st.session_state['full_on_target_results'] = predictions
|
106 |
|
107 |
-
# On-target results display
|
108 |
if 'on_target_results' in st.session_state and st.session_state['on_target_results']:
|
109 |
-
# Convert the results to a pandas DataFrame for better display
|
110 |
df = pd.DataFrame(st.session_state['on_target_results'],
|
111 |
columns=["Gene ID", "Start Pos", "End Pos", "Strand", "gRNA", "Prediction"])
|
112 |
st.write('On-target predictions:')
|
113 |
st.dataframe(df)
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
if 'full_on_target_results' in st.session_state:
|
116 |
-
# Convert full results to a CSV for download
|
117 |
full_df = pd.DataFrame(st.session_state['full_on_target_results'],
|
118 |
columns=["Gene ID", "Start Pos", "End Pos", "Strand", "gRNA", "Prediction"])
|
119 |
full_predictions_csv = full_df.to_csv(index=False).encode('utf-8')
|
120 |
-
st.download_button(
|
121 |
-
|
122 |
-
data=full_predictions_csv,
|
123 |
-
file_name='on_target_results.csv',
|
124 |
-
mime='text/csv'
|
125 |
-
)
|
126 |
|
127 |
elif target_selection == 'off-target':
|
128 |
ENTRY_METHODS = dict(
|
|
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
from pathlib import Path
|
8 |
+
from igv_component import igv_component
|
9 |
|
10 |
# title and documentation
|
11 |
st.markdown(Path('crisprTool.md').read_text(), unsafe_allow_html=True)
|
|
|
92 |
)
|
93 |
|
94 |
if target_selection == 'on-target':
|
|
|
95 |
gene_symbol = st.text_input('Enter a Gene Symbol:', key='gene_symbol')
|
96 |
|
97 |
+
# Add genome reference selection
|
98 |
+
genome_reference = st.selectbox('Select a Genome Reference:', ['hg19', 'hg38'], key='genome_reference')
|
99 |
+
|
100 |
predict_button = st.button('Predict on-target')
|
101 |
|
|
|
102 |
if predict_button and gene_symbol:
|
103 |
predictions = cas9on.process_gene(gene_symbol, cas9on_path)
|
|
|
104 |
st.session_state['on_target_results'] = predictions[:10]
|
105 |
st.session_state['full_on_target_results'] = predictions
|
106 |
|
|
|
107 |
if 'on_target_results' in st.session_state and st.session_state['on_target_results']:
|
|
|
108 |
df = pd.DataFrame(st.session_state['on_target_results'],
|
109 |
columns=["Gene ID", "Start Pos", "End Pos", "Strand", "gRNA", "Prediction"])
|
110 |
st.write('On-target predictions:')
|
111 |
st.dataframe(df)
|
112 |
|
113 |
+
# Pass the gene symbol, genome reference, and predictions to IGV Component
|
114 |
+
igv_component(crispr_results=st.session_state['on_target_results'],
|
115 |
+
genome_reference=genome_reference,
|
116 |
+
gene_symbol=gene_symbol,
|
117 |
+
key="igv_viewer")
|
118 |
+
|
119 |
if 'full_on_target_results' in st.session_state:
|
|
|
120 |
full_df = pd.DataFrame(st.session_state['full_on_target_results'],
|
121 |
columns=["Gene ID", "Start Pos", "End Pos", "Strand", "gRNA", "Prediction"])
|
122 |
full_predictions_csv = full_df.to_csv(index=False).encode('utf-8')
|
123 |
+
st.download_button(label='Download on-target predictions', data=full_predictions_csv,
|
124 |
+
file_name='on_target_results.csv', mime='text/csv')
|
|
|
|
|
|
|
|
|
125 |
|
126 |
elif target_selection == 'off-target':
|
127 |
ENTRY_METHODS = dict(
|