Skip to content

Instantly share code, notes, and snippets.

@vighneshbirodkar
Created March 2, 2016 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vighneshbirodkar/50cffaa60db41ecf1c41 to your computer and use it in GitHub Desktop.
Save vighneshbirodkar/50cffaa60db41ecf1c41 to your computer and use it in GitHub Desktop.
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