Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deprecated numpy type names (fixes pinellolab#269)
Browse files Browse the repository at this point in the history
In the most recent version of numpy (1.24) some of the types have been
deprecated. This commit fixes these errors.
Colelyman committed Dec 22, 2022
1 parent b822612 commit de9eeb0
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions CRISPResso2/CRISPResso2Align.pyx
Original file line number Diff line number Diff line change
@@ -166,14 +166,14 @@ def global_align(str pystr_seqj, str pystr_seqi, np.ndarray[DTYPE_INT, ndim=2] m
#init i matrix
for i in range(1,max_j+1):
iScore[0,i] = gap_extend * i + gap_incentive[0]
# iScore[0,1:] = [gap_extend * np.arange(1, max_j+1, dtype=np.int)]
# iScore[0,1:] = [gap_extend * np.arange(1, max_j+1, dtype=int)]
iScore[0:,0] = min_score
iPointer[0,1:] = IARRAY

#init j matrix
for i in range(1,max_i+1):
jScore[i,0] = gap_extend * i + gap_incentive[0]
#jScore[1:,0] = np.vectorize(gap_extend * np.arange(1, max_i+1, dtype=np.int))
#jScore[1:,0] = np.vectorize(gap_extend * np.arange(1, max_i+1, dtype=int))
jScore[0,0:] = min_score
jPointer[1:,0] = JARRAY

2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoBatchCORE.py
Original file line number Diff line number Diff line change
@@ -451,7 +451,7 @@ def main():

mod_pcts = {}
for key in mod_freqs:
mod_pcts[key] = np.array(mod_freqs[key]).astype(np.float)/float(mod_freqs['Total'][0])
mod_pcts[key] = np.array(mod_freqs[key]).astype(float)/float(mod_freqs['Total'][0])

amp_found_count += 1

34 changes: 17 additions & 17 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
@@ -3514,11 +3514,11 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
if not args.suppress_plots:
mod_pcts = []
tot = float(counts_total[ref_name])
mod_pcts.append(np.concatenate((['Insertions'], np.array(all_insertion_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate((['Insertions_Left'], np.array(all_insertion_left_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate((['Deletions'], np.array(all_deletion_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate((['Substitutions'], np.array(all_substitution_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate((['All_modifications'], np.array(all_indelsub_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate((['Insertions'], np.array(all_insertion_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate((['Insertions_Left'], np.array(all_insertion_left_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate((['Deletions'], np.array(all_deletion_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate((['Substitutions'], np.array(all_substitution_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate((['All_modifications'], np.array(all_indelsub_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate((['Total'], [counts_total[ref_name]]*refs[ref_name]['sequence_length'])))
colnames = ['Modification']+list(ref_seq)
modification_percentage_summary_df = pd.DataFrame(mod_pcts, columns=colnames).apply(pd.to_numeric, errors='ignore')
@@ -3897,18 +3897,18 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
for ref_name_for_hdr in ref_names_for_hdr:
tot = float(counts_total[ref_name_for_hdr])
for nuc in ['A', 'C', 'G', 'T', 'N', '-']:
nuc_pcts.append(np.concatenate(([ref_name_for_hdr, nuc], np.array(ref1_all_base_count_vectors[ref_name_for_hdr+"_"+nuc]).astype(np.float)/tot)))
nuc_pcts.append(np.concatenate(([ref_name_for_hdr, nuc], np.array(ref1_all_base_count_vectors[ref_name_for_hdr+"_"+nuc]).astype(float)/tot)))
colnames = ['Batch', 'Nucleotide']+list(refs[ref_names_for_hdr[0]]['sequence'])
hdr_nucleotide_percentage_summary_df = pd.DataFrame(nuc_pcts, columns=colnames).apply(pd.to_numeric, errors='ignore')

mod_pcts = []
for ref_name_for_hdr in ref_names_for_hdr:
tot = float(counts_total[ref_name_for_hdr])
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Insertions'], np.array(ref1_all_insertion_count_vectors[ref_name_for_hdr]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Insertions_Left'], np.array(ref1_all_insertion_left_count_vectors[ref_name_for_hdr]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Deletions'], np.array(ref1_all_deletion_count_vectors[ref_name_for_hdr]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Substitutions'], np.array(ref1_all_substitution_count_vectors[ref_name_for_hdr]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'All_modifications'], np.array(ref1_all_indelsub_count_vectors[ref_name_for_hdr]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Insertions'], np.array(ref1_all_insertion_count_vectors[ref_name_for_hdr]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Insertions_Left'], np.array(ref1_all_insertion_left_count_vectors[ref_name_for_hdr]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Deletions'], np.array(ref1_all_deletion_count_vectors[ref_name_for_hdr]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Substitutions'], np.array(ref1_all_substitution_count_vectors[ref_name_for_hdr]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'All_modifications'], np.array(ref1_all_indelsub_count_vectors[ref_name_for_hdr]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name_for_hdr, 'Total'], [counts_total[ref_name_for_hdr]]*refs[ref_names_for_hdr[0]]['sequence_length'])))
colnames = ['Batch', 'Modification']+list(refs[ref_names_for_hdr[0]]['sequence'])
hdr_modification_percentage_summary_df = pd.DataFrame(mod_pcts, columns=colnames).apply(pd.to_numeric, errors='ignore')
@@ -4465,18 +4465,18 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
for ref_name in ref_names_for_pe:
tot = float(counts_total[ref_name])
for nuc in ['A', 'C', 'G', 'T', 'N', '-']:
nuc_pcts.append(np.concatenate(([ref_name, nuc], np.array(ref1_all_base_count_vectors[ref_name+"_"+nuc]).astype(np.float)/tot)))
nuc_pcts.append(np.concatenate(([ref_name, nuc], np.array(ref1_all_base_count_vectors[ref_name+"_"+nuc]).astype(float)/tot)))
colnames = ['Batch', 'Nucleotide']+list(refs[ref_names[0]]['sequence'])
pe_nucleotide_percentage_summary_df = pd.DataFrame(nuc_pcts, columns=colnames).apply(pd.to_numeric,errors='ignore')

mod_pcts = []
for ref_name in ref_names_for_pe:
tot = float(counts_total[ref_name])
mod_pcts.append(np.concatenate(([ref_name, 'Insertions'], np.array(ref1_all_insertion_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Insertions_Left'], np.array(ref1_all_insertion_left_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Deletions'], np.array(ref1_all_deletion_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Substitutions'], np.array(ref1_all_substitution_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'All_modifications'], np.array(ref1_all_indelsub_count_vectors[ref_name]).astype(np.float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Insertions'], np.array(ref1_all_insertion_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Insertions_Left'], np.array(ref1_all_insertion_left_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Deletions'], np.array(ref1_all_deletion_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Substitutions'], np.array(ref1_all_substitution_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'All_modifications'], np.array(ref1_all_indelsub_count_vectors[ref_name]).astype(float)/tot)))
mod_pcts.append(np.concatenate(([ref_name, 'Total'], [counts_total[ref_name]]*refs[ref_names_for_pe[0]]['sequence_length'])))
colnames = ['Batch', 'Modification']+list(refs[ref_names_for_pe[0]]['sequence'])
pe_modification_percentage_summary_df = pd.DataFrame(mod_pcts, columns=colnames).apply(pd.to_numeric,errors='ignore')
8 changes: 4 additions & 4 deletions CRISPResso2/CRISPRessoPlot.py
Original file line number Diff line number Diff line change
@@ -2507,7 +2507,7 @@ def __init__(self, data, vmin, vmax, cmap, center, robust, annot, fmt,

if annot is not None:
if per_element_annot_kws is None:
self.per_element_annot_kws=np.empty_like(annot, dtype=np.object)
self.per_element_annot_kws=np.empty_like(annot, dtype=object)
self.per_element_annot_kws[:]=dict()
else:
self.per_element_annot_kws=per_element_annot_kws
@@ -2641,7 +2641,7 @@ def prep_alleles_table(df_alleles, reference_seq, MAX_N_ROWS, MIN_FREQUENCY):
(row['Reference_Sequence'][i_sub]!=idx[i_sub]) and \
(row['Reference_Sequence'][i_sub]!='-') and\
(idx[i_sub]!='-')]
to_append=np.array([{}]*len(idx), dtype=np.object)
to_append=np.array([{}]*len(idx), dtype=object)
to_append[ idxs_sub]={'weight':'bold', 'color':'black','size':16}
per_element_annot_kws.append(to_append)

@@ -2693,7 +2693,7 @@ def prep_alleles_table_compare(df_alleles, sample_name_1, sample_name_2, MAX_N_R
(row['Reference_Sequence'][i_sub]!=idx[i_sub]) and \
(row['Reference_Sequence'][i_sub]!='-') and\
(idx[i_sub]!='-')]
to_append=np.array([{}]*len(idx), dtype=np.object)
to_append=np.array([{}]*len(idx), dtype=object)
to_append[ idxs_sub]={'weight':'bold', 'color':'black','size':16}
per_element_annot_kws.append(to_append)

@@ -3198,7 +3198,7 @@ def plot_nucleotide_quilt_from_folder(crispresso_output_folder,fig_filename_root

mod_pcts = {}
for key in mod_counts:
mod_pcts[key] = np.array(mod_counts[key]).astype(np.float)/float(mod_counts['Total'][0])
mod_pcts[key] = np.array(mod_counts[key]).astype(float)/float(mod_counts['Total'][0])

modification_percentage_summary = []
for mod in ['Insertions', 'Insertions_Left', 'Deletions', 'Substitutions', 'All_modifications']:

0 comments on commit de9eeb0

Please sign in to comment.