Skip to content

Commit

Permalink
Cole asymmetrical cut point (#453)
Browse files Browse the repository at this point in the history
* Pin versions of numpy and matplotlib in CI environment (#84) (#452)

* Reduce duplication and implement cut_point_ind in plot_alleles_heatmap_hist
  • Loading branch information
Colelyman authored Jul 16, 2024
1 parent 27d731a commit 2672ba8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/envs/test_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ channels:
dependencies:
- pip
- fastp
- numpy
- numpy<2
- cython
- jinja2
- tbb=2020.2
- pyparsing=2.3.1
- scipy
- matplotlib
- matplotlib=3.8.4
- pandas
39 changes: 20 additions & 19 deletions CRISPResso2/CRISPRessoPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2888,9 +2888,8 @@ def plot_alleles_heatmap(
#cut point vertical line
if plot_cut_point:
if cut_point_ind is None:
ax_hm.vlines([plot_nuc_len/2],*ax_hm.get_ylim(),linestyles='dashed')
else:
ax_hm.vlines(cut_point_ind,*ax_hm.get_ylim(),linestyles='dashed')
cut_point_ind = [plot_nuc_len / 2]
ax_hm.vlines(cut_point_ind,*ax_hm.get_ylim(),linestyles='dashed')


ax_hm_ref.yaxis.tick_right()
Expand Down Expand Up @@ -3021,7 +3020,9 @@ def plot_alleles_heatmap_hist(reference_seq,fig_filename_root,X,annot,y_labels,i

#cut point vertical line
if plot_cut_point:
ax_hm.vlines([plot_nuc_len/2], *ax_hm.get_ylim(), linestyles='dashed')
if cut_point_ind is None:
cut_point_ind = [plot_nuc_len / 2]
ax_hm.vlines(cut_point_ind, *ax_hm.get_ylim(), linestyles='dashed')

#create boxes for ins
for idx, lss in insertion_dict.items():
Expand Down Expand Up @@ -3085,19 +3086,19 @@ def plot_alleles_table(reference_seq,df_alleles,fig_filename_root,custom_colors,
if is_ref:
y_labels[ix] += annotate_wildtype_allele

plot_alleles_heatmap(reference_seq=reference_seq,
fig_filename_root=fig_filename_root,
X=X,
annot=annot,
y_labels=y_labels,
insertion_dict=insertion_dict,
per_element_annot_kws=per_element_annot_kws,
custom_colors=custom_colors,
SAVE_ALSO_PNG=SAVE_ALSO_PNG,
plot_cut_point=plot_cut_point,
plot_alleles_heatmap(reference_seq=reference_seq,
fig_filename_root=fig_filename_root,
X=X,
annot=annot,
y_labels=y_labels,
insertion_dict=insertion_dict,
per_element_annot_kws=per_element_annot_kws,
custom_colors=custom_colors,
SAVE_ALSO_PNG=SAVE_ALSO_PNG,
plot_cut_point=plot_cut_point,
cut_point_ind=cut_point_ind,
sgRNA_intervals=sgRNA_intervals,
sgRNA_names=sgRNA_names,
sgRNA_intervals=sgRNA_intervals,
sgRNA_names=sgRNA_names,
sgRNA_mismatches=sgRNA_mismatches)

def plot_alleles_table_from_file(alleles_file_name,fig_filename_root,custom_colors,MIN_FREQUENCY=0.5,MAX_N_ROWS=100,SAVE_ALSO_PNG=False,plot_cut_point=True,cut_point_ind=None,sgRNA_intervals=None,sgRNA_names=None,sgRNA_mismatches=None,annotate_wildtype_allele='',**kwargs):
Expand Down Expand Up @@ -3217,9 +3218,9 @@ def plot_alleles_tables_from_folder(crispresso_output_folder,fig_filename_root,c
new_sgRNA_intervals += [(int_start - new_sel_cols_start - 1, int_end - new_sel_cols_start - 1)]

X, annot, y_labels, insertion_dict, per_element_annot_kws, is_reference = prep_alleles_table(df_alleles, ref_seq_around_cut, MAX_N_ROWS, MIN_FREQUENCY)
plot_alleles_heatmap(reference_seq=ref_seq_around_cut,
fig_filename_root=fig_filename_root+"_"+ref_name+"_"+sgRNA_label,
X=X,
plot_alleles_heatmap(reference_seq=ref_seq_around_cut,
fig_filename_root=fig_filename_root+"_"+ref_name+"_"+sgRNA_label,
X=X,
annot=annot,
y_labels=y_labels,
insertion_dict=insertion_dict,
Expand Down

0 comments on commit 2672ba8

Please sign in to comment.