Skip to content

Instantly share code, notes, and snippets.

@tlnagy tlnagy/
Created Sep 22, 2015

What would you like to do?
import pickle
import seaborn as sns
%pylab --no-import-all
%matplotlib inline
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
data = pickle.load(open("allele_dic.pkl", "rb"))
translate = pickle.load(open("translate.pkl", "rb"))
aminotonumber = pickle.load(open("aminotonumber.pkl", "rb"))
aa_to_barcodes = {}
pos_to_barcodes = {}
for barcode, value in data.items():
pos, codon = value[0].split("_")
aa = translate[codon.replace("T", "U")]
if aa not in aa_to_barcodes:
aa_to_barcodes[aa] = []
if pos not in pos_to_barcodes:
pos_to_barcodes[pos] = []
scores = []
for key, value in aa_to_barcodes.items():
scores.append((aminotonumber[key], len(value), key))
scores = list(zip(*scores))
sns.set_palette(sns.color_palette(flatui))[0], scores[1])
plt.xlim(0, len(scores[0]))
sns.axlabel("Amino acids", "Barcode count")
plt.xticks(np.arange(len(scores[0]))+0.5, scores[2])
plt.title("Number of barcodes mapped to each amino acid")
scores = []
for pos, barcodes in pos_to_barcodes.items():
scores.append((int(pos), len(barcodes)))
scores = list(zip(*scores))
sns.set_palette(sns.color_palette(flatui[1:]))[0], scores[1], width=1.0, edgecolor="none")
plt.xlim(2, len(scores[0]))
sns.axlabel("Position", "Barcode count")
plt.title("Number of barcodes mapped to Ubiquitin AA position")
poses = np.zeros((len(aminotonumber), 77))
for barcode, value in data.items():
pos, codon = value[0].split("_")
aa = aminotonumber[translate[codon.replace("T", "U")]]
poses[int(aa), int(pos) - 1] += 1
plt.figure(figsize=(10, 4))
xticklabels=5, yticklabels=aas)
sns.axlabel("Ubiquitin AA position", "Amino Acid")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.