Created
March 2, 2016 05:30
-
-
Save vighneshbirodkar/50cffaa60db41ecf1c41 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 numpy as np | |
from matplotlib import pyplot as plt | |
col_map = {} | |
concentrations = ['0.5', '2', '5', '10', '20', '40'] | |
kinds = ['R1', 'R2', 'R3', 'S1', 'S2', 'S3'] | |
gene_names = [] | |
gene_index = 125 | |
with open('/home/vighnesh/data/bio/HPK.counts.txt') as f: | |
c = 0 | |
line = f.readline() | |
col_names = [(name, i) for (i, name) in enumerate(line.split())] | |
col_map.update(col_names) | |
count = 0 | |
data = [] | |
for line in f: | |
#for w in line.split(): | |
# print(w) | |
#break | |
words = line.split() | |
name = words[0] | |
gene_names.append(name) | |
row = map(int, words[1:]) | |
data.append(row) | |
count += 1 | |
array = np.array(data) | |
if gene_index >= len(gene_names): | |
print('Index %d is too high, only %d genes exist in data' % | |
(gene_index, len(gene_names))) | |
exit(0) | |
for kind in kinds: | |
query_cols = ['HPK' + conc + '_' + kind for conc in concentrations] | |
query_col_index = [col_map[q] for q in query_cols] | |
values = array[gene_index][query_col_index] | |
plt.plot(values, label = kind) | |
plt.xticks(range(len(query_cols)), query_cols) | |
plt.grid(True) | |
plt.legend(loc='best') | |
plt.xlabel('Concentrations') | |
plt.ylabel('Expression of ' + gene_names[gene_index]) | |
plt.xlim([-0.5, 5.5]) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment