Skip to content

Instantly share code, notes, and snippets.

@gpratt
Created September 24, 2013 23:50
Show Gist options
  • Save gpratt/6692981 to your computer and use it in GitHub Desktop.
Save gpratt/6692981 to your computer and use it in GitHub Desktop.
rainbow colors
def calculate_on_target(barcodes, barcode_map, expected):
figsize(4,4)
total = 0
on_target = 0
off_target = 0
no_target = 0
expected_counts = []
off_target_counts = []
expected_names = []
off_target_names = []
for barcode, count in barcodes.items():
if barcode in barcode_map:
if barcode_map[barcode] in expected:
on_target += count
expected_counts.append(count)
expected_names.append(barcode_map[barcode])
else:
off_target += count
off_target_counts.append(count)
off_target_names.append(barcode_map[barcode])
else:
no_target += count
total += count
#subplot(1,2,1)
#pie([on_target, off_target, no_target], labels=["On Target", "Off Target", "No Target"])
#subplot(1,2,2)
expected_colors = cm.Blues(np.linspace(0, 1, len(expected_counts)))
off_target_colors = cm.Reds(np.linspace(0, 1, len(off_target_counts) + 1))
pie(expected_counts + off_target_counts + [no_target],
labels= expected_names + off_target_names + ["No Target"],
colors=np.concatenate((expected_colors, off_target_colors)))
print "on_target", "off_target"
print on_target / float(total), off_target / float(total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment