import matplotlib.pyplot as plt import numpy as np import sys """A = np.random.random((5,5)) print A plt.gray() plt.imshow(A, interpolation='nearest') plt.show()""" """plt.gray() A = np.zeros((100,100,3)) for i in range(100): for j in range(100): A[i,j,0] = 1.0 - i*0.01 # red A[i,j,1] = 0.0 # green A[i,j,2] = 0.0# blue plt.imshow(A,interpolation='nearest') plt.show()""" """ A = np.zeros( (100,100,3) ) # i is the rows, j is the columns for i in range(100): for j in range(100): if i < 50: # Red to black A[i,j,0] = 1 - 0.02*i #red A[i,j,1] = 0.0# Green A[i,j,2] = 0.0# blue else: # Black to green A[i,j,0] = 0.0 #red A[i,j,1] = 0.02*(i-50)# Green A[i,j,2] = 0.0# blue plt.gray() plt.imshow(A, interpolation='nearest') plt.show()""" values = np.zeros((100,7)) i = 0 for line in open('../files/geneexpression.txt'): line = line.strip().split() j = 0 for el in line[1:]: values[i,j] = float(el) j += 1 i += 1 all_lines = open('../files/geneexpression.txt').readlines() allvalues = [] for i in range(len(all_lines)): line = all_lines[i] columns = line.strip().split('\t') # columns[1:] for j in range(1,len(columns)): # range(1, len(columns)) = 1,2,3,4,5,6,7 # i and j here should be set values[i,j-1] = columns[j] allvalues.append(float(columns[j])) max_value = max(allvalues) min_value = min(allvalues) GE_colors = np.zeros((100,7,3)) for i in range(100): for j in range(7): value = values[i,j] if value < 0.: # Very Red - > Black GE_colors[i,j,0] = value/min_value#Red GE_colors[i,j,1] = 0.#Green GE_colors[i,j,2] = 0.#Blue else: # Black to Green GE_colors[i,j,0] = 0.#Red GE_colors[i,j,1] = value/max_value#Green GE_colors[i,j,2] = 0.#Blue plt.figure() plt.imshow(GE_colors, interpolation='nearest',aspect='auto') plt.show()