Spaces:
Sleeping
Sleeping
Commit
•
e7225c8
1
Parent(s):
7274bd3
fixed bugs
Browse files
app.py
CHANGED
@@ -136,35 +136,46 @@ if selected_model == 'Cas9':
|
|
136 |
# Now create a Plotly plot with the sorted_predictions
|
137 |
fig = go.Figure()
|
138 |
|
139 |
-
#
|
140 |
-
|
|
|
|
|
141 |
|
142 |
# Iterate over the sorted predictions to create the plot
|
143 |
for i, prediction in enumerate(sorted_predictions, start=1):
|
144 |
# Extract data for plotting
|
145 |
-
chrom, start, end, strand, target, gRNA, pred_score = prediction
|
146 |
-
|
147 |
-
y_value = strand_y_values[str(strand)] # Convert strand to string for dict lookup
|
148 |
fig.add_trace(go.Scatter(
|
149 |
x=[start, end],
|
150 |
-
y=[y_value]
|
151 |
mode='lines+markers+text',
|
152 |
name=f"gRNA: {gRNA}",
|
153 |
-
text=f"Rank: {i}", #
|
154 |
hoverinfo='text',
|
155 |
-
hovertext=
|
|
|
|
|
|
|
156 |
))
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
# Update the layout of the plot
|
159 |
fig.update_layout(
|
160 |
-
title='
|
161 |
xaxis_title='Genomic Position',
|
|
|
162 |
yaxis=dict(
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
)
|
|
|
168 |
)
|
169 |
|
170 |
# Display the plot
|
@@ -351,35 +362,46 @@ elif selected_model == 'Cas12':
|
|
351 |
# Now create a Plotly plot with the sorted_predictions
|
352 |
fig = go.Figure()
|
353 |
|
354 |
-
#
|
355 |
-
|
|
|
|
|
356 |
|
357 |
# Iterate over the sorted predictions to create the plot
|
358 |
for i, prediction in enumerate(sorted_predictions, start=1):
|
359 |
# Extract data for plotting
|
360 |
-
chrom, start, end, strand, target, gRNA, pred_score = prediction
|
361 |
-
|
362 |
-
y_value = strand_y_values[str(strand)] # Convert strand to string for dict lookup
|
363 |
fig.add_trace(go.Scatter(
|
364 |
x=[start, end],
|
365 |
-
y=[y_value]
|
366 |
mode='lines+markers+text',
|
367 |
name=f"gRNA: {gRNA}",
|
368 |
-
text=f"Rank: {i}", #
|
369 |
hoverinfo='text',
|
370 |
-
hovertext=
|
|
|
|
|
|
|
371 |
))
|
|
|
|
|
|
|
|
|
|
|
372 |
|
373 |
# Update the layout of the plot
|
374 |
fig.update_layout(
|
375 |
-
title='
|
376 |
xaxis_title='Genomic Position',
|
|
|
377 |
yaxis=dict(
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
)
|
|
|
383 |
)
|
384 |
|
385 |
# Display the plot
|
@@ -417,8 +439,7 @@ elif selected_model == 'Cas12':
|
|
417 |
st.download_button(label="Download CSV File", data=file, file_name=csv_file_path,
|
418 |
mime="text/csv")
|
419 |
|
420 |
-
|
421 |
-
clean_up_old_files(gene_symbol)
|
422 |
|
423 |
elif selected_model == 'Cas13d':
|
424 |
ENTRY_METHODS = dict(
|
|
|
136 |
# Now create a Plotly plot with the sorted_predictions
|
137 |
fig = go.Figure()
|
138 |
|
139 |
+
# Variables to help spread gRNAs on the y-axis based on their strand
|
140 |
+
y_positive_strand = 10
|
141 |
+
y_negative_strand = -10
|
142 |
+
strand_offset = 1 # This will space out each subsequent guide on the same strand
|
143 |
|
144 |
# Iterate over the sorted predictions to create the plot
|
145 |
for i, prediction in enumerate(sorted_predictions, start=1):
|
146 |
# Extract data for plotting
|
147 |
+
chrom, start, end, strand, target, gRNA, pred_score = prediction
|
148 |
+
y_value = y_positive_strand if strand == 1 else y_negative_strand
|
|
|
149 |
fig.add_trace(go.Scatter(
|
150 |
x=[start, end],
|
151 |
+
y=[y_value, y_value], # Assign all points the same y value based on strand
|
152 |
mode='lines+markers+text',
|
153 |
name=f"gRNA: {gRNA}",
|
154 |
+
text=[f"Rank: {i}", ""], # Text at the start position only
|
155 |
hoverinfo='text',
|
156 |
+
hovertext=[
|
157 |
+
f"Rank: {i}<br>Target: {target}<br>gRNA: {gRNA}<br>Cutsite: {start}<br>On Target Score: {pred_score:.4f}",
|
158 |
+
""
|
159 |
+
],
|
160 |
))
|
161 |
+
# Update the y-value for the next guide on the same strand
|
162 |
+
if strand == 1:
|
163 |
+
y_positive_strand += strand_offset
|
164 |
+
else:
|
165 |
+
y_negative_strand -= strand_offset
|
166 |
|
167 |
# Update the layout of the plot
|
168 |
fig.update_layout(
|
169 |
+
title='Top 10 gRNA Sequences by Prediction Score',
|
170 |
xaxis_title='Genomic Position',
|
171 |
+
yaxis_title='Strand',
|
172 |
yaxis=dict(
|
173 |
+
showgrid=True, # Show horizontal gridlines for clarity
|
174 |
+
zeroline=True, # Show a line at y=0
|
175 |
+
zerolinecolor='Black',
|
176 |
+
zerolinewidth=2,
|
177 |
+
),
|
178 |
+
showlegend=False # Hide the legend if it's not necessary
|
179 |
)
|
180 |
|
181 |
# Display the plot
|
|
|
362 |
# Now create a Plotly plot with the sorted_predictions
|
363 |
fig = go.Figure()
|
364 |
|
365 |
+
# Variables to help spread gRNAs on the y-axis based on their strand
|
366 |
+
y_positive_strand = 10
|
367 |
+
y_negative_strand = -10
|
368 |
+
strand_offset = 1 # This will space out each subsequent guide on the same strand
|
369 |
|
370 |
# Iterate over the sorted predictions to create the plot
|
371 |
for i, prediction in enumerate(sorted_predictions, start=1):
|
372 |
# Extract data for plotting
|
373 |
+
chrom, start, end, strand, target, gRNA, pred_score = prediction
|
374 |
+
y_value = y_positive_strand if strand == 1 else y_negative_strand
|
|
|
375 |
fig.add_trace(go.Scatter(
|
376 |
x=[start, end],
|
377 |
+
y=[y_value, y_value], # Assign all points the same y value based on strand
|
378 |
mode='lines+markers+text',
|
379 |
name=f"gRNA: {gRNA}",
|
380 |
+
text=[f"Rank: {i}", ""], # Text at the start position only
|
381 |
hoverinfo='text',
|
382 |
+
hovertext=[
|
383 |
+
f"Rank: {i}<br>Target: {target}<br>gRNA: {gRNA}<br>Cutsite: {start}<br>On Target Score: {pred_score:.4f}",
|
384 |
+
""
|
385 |
+
],
|
386 |
))
|
387 |
+
# Update the y-value for the next guide on the same strand
|
388 |
+
if strand == 1:
|
389 |
+
y_positive_strand += strand_offset
|
390 |
+
else:
|
391 |
+
y_negative_strand -= strand_offset
|
392 |
|
393 |
# Update the layout of the plot
|
394 |
fig.update_layout(
|
395 |
+
title='Top 10 gRNA Sequences by Prediction Score',
|
396 |
xaxis_title='Genomic Position',
|
397 |
+
yaxis_title='Strand',
|
398 |
yaxis=dict(
|
399 |
+
showgrid=True, # Show horizontal gridlines for clarity
|
400 |
+
zeroline=True, # Show a line at y=0
|
401 |
+
zerolinecolor='Black',
|
402 |
+
zerolinewidth=2,
|
403 |
+
),
|
404 |
+
showlegend=False # Hide the legend if it's not necessary
|
405 |
)
|
406 |
|
407 |
# Display the plot
|
|
|
439 |
st.download_button(label="Download CSV File", data=file, file_name=csv_file_path,
|
440 |
mime="text/csv")
|
441 |
|
442 |
+
|
|
|
443 |
|
444 |
elif selected_model == 'Cas13d':
|
445 |
ENTRY_METHODS = dict(
|