Created
September 22, 2015 23:30
-
-
Save tlnagy/8903afc0c5371548bfcd to your computer and use it in GitHub Desktop.
pubs_plotting_code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import seaborn as sns | |
sns.set_style("whitegrid") | |
%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] = [] | |
aa_to_barcodes[aa].append(barcode) | |
pos_to_barcodes[pos].append(barcode) | |
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)) | |
plt.bar(scores[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") | |
plt.show() | |
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:])) | |
plt.bar(scores[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") | |
plt.show() | |
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)) | |
sns.heatmap(poses, | |
xticklabels=5, yticklabels=aas) | |
sns.axlabel("Ubiquitin AA position", "Amino Acid") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment