Hack90 commited on
Commit
3d0065b
·
verified ·
1 Parent(s): 130e329

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +18 -0
utils.py CHANGED
@@ -68,6 +68,24 @@ def plot_2d_comparison(dna_sequences_grouped, labels, mapping=mapping_easy):
68
  ax.legend(by_label.values(), by_label.keys())
69
  return fig
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  ############################################################# Virus Dataset ########################################################
73
  #ds = load_dataset('Hack90/virus_tiny')
 
68
  ax.legend(by_label.values(), by_label.keys())
69
  return fig
70
 
71
+ # Function to plot a comparison of DNA sequences
72
+ def plot_distrobutions(dna_sequences_grouped, labels, basepair, mapping=mapping_easy):
73
+ fig, ax = plt.subplots()
74
+ colors = plt.cm.rainbow(np.linspace(0, 1, len(dna_sequences_grouped)))
75
+ for count, (dna_sequences, color) in enumerate(zip(dna_sequences_grouped, colors)):
76
+ virus_y = []
77
+ for dna_sequence in dna_sequences:
78
+ mapped_coords = _dna_to_coordinates(dna_sequence, mapping)
79
+ cumulative_coords = _get_cumulative_coords(mapped_coords)
80
+ y = cumulative_coords[:, 1][basepair]
81
+ virus_y.append(y)
82
+ count_bins, bins = np.histogram(virus_y)
83
+ ax.stairs(count_bins, bins , color= color, label[count])
84
+ # Only show unique labels in the legend
85
+ handles, labels = ax.get_legend_handles_labels()
86
+ by_label = dict(zip(labels, handles))
87
+ ax.legend(by_label.values(), by_label.keys())
88
+ return fig
89
 
90
  ############################################################# Virus Dataset ########################################################
91
  #ds = load_dataset('Hack90/virus_tiny')