rcParams["font.size"] = 8 rcParams["lines.linewidth"] = 0.6 rcParams["lines.markersize"] = 2 fit_window_size = 1.5 # hours fit_start_threshold = 0.01 leg = ["SOC+kana", "M9+CAS+Glu+kana", "M9+AA+Nt+Glu+kana", "M9+Glu+kana", "M9+Acetate+kana"] color = ["g", "r", "b", "m", "c"] gr_mat = zeros((5, 10)) subplot(2, 1, 1) for c in range(0, 5): for r in range(5): (t, v) = vp.get_data(0, r, c) plot(t, v - min(v), color[r]) (gr, err) = vp.fit_growth(t, v, fit_window_size, fit_start_threshold) gr_mat[r, c] = gr legend([leg[r] + " (%.0f min)" % (log(2) * 60 / mean(gr_mat[r, 0:5])) for r in range(5)], loc="lower right") title("PRK") xlabel("Time (hr)") ylabel("OD") yscale("log") axis([0, t.max(), 0.001, 1]) subplot(2, 1, 2) for c in range(5, 10): for r in range(5): (t, v) = vp.get_data(0, r, c) plot(t, v - min(v), color[r]) (gr, err) = vp.fit_growth(t, v, fit_window_size, fit_start_threshold)
for i in range(len(columns)): fig = figure() (name, c_list, max_T) = columns[i] gr_mat = zeros((len(c_list), len(rows))) for j in range(len(c_list)): for k in range(len(rows)): if (plot_index == "divide"): (time0, values0) = vp.get_data(0, rows[k][1], c_list[j]) (time1, values1) = vp.get_data(1, rows[k][1], c_list[j]) time = time0 values = values1/values0 else: (time, values) = vp.get_data(plot_index, rows[k][1], c_list[j]) plot(time, values, rows[k][2]) gr_mat[j, k] = vp.fit_growth(time, values, fit_window_size, fit_start_threshold) legend_text = [] for k in range(len(rows)): (leg, r, color) = rows[k] max_dt = log(2)*60/min(gr_mat[:,r]) min_dt = log(2)*60/max(gr_mat[:,r]) legend_text.append("%s (%.0f-%0.f min)" % (leg, min_dt, max_dt)) legend(legend_text, loc='lower right') title(name) xlabel('Time (hr)') ylabel(plot_label) yscale('log') axis([0, max_T, y_min, y_max]) pp.savefig(fig)
""" time - a vector of the time of each measurement (in hours) cell_count - a vector of the cell-count at each time point window - the size of the window for which to calculate the growth rates (in hours) start_time - the time point after which the input data can be trusted Note: the cell_count can be any measure that is proportional to the number of cells. For example, Optical Density (in OD), or level of luminescence (in CPS). """ from victor_parser import VictorParser import pylab if (__name__ == "__main__"): vp = VictorParser() fname = "../data/Elad's OD600_20100701_188.xls" vp.parse_excel(fname) (time, cell_count) = vp.get_data(0, 3, 0) pylab.figure() pylab.subplot(1,2,1) print "Logistic fit: gr = %.2f" % vp.fit_growth2(time, cell_count, plot_figure=True) pylab.subplot(1,2,2) print "linear fit in logscale: gr = %.2f" % vp.fit_growth(time, cell_count, window_size=1.5, start_threshold=0.01, plot_figure=True) pylab.show()
for (plot_title, victor_index, t_range, y_range, y_label, data_series) in plots: sys.stderr.write("Plotting %s (%s) ... \n" % (plot_title, str(victor_index))) fig = figure() title(plot_title) xlabel('Time (hr)') ylabel(y_label) legend_text = [] for (label, (color, cells)) in data_series.iteritems(): for (row, col) in cells: if (victor_index == "divide"): (time0, values0) = vp.get_data(0, row, col) (time1, values1) = vp.get_data(1, row, col) time = time0 values = values1 / values0 else: (time, values) = vp.get_data(victor_index, row, col) plot(time, values, color) growth_rate = vp.fit_growth(time, values, fit_window_size, fit_start_threshold) legend_text.append("%s (%.0f min)" % (label, log(2) * 60 / growth_rate)) legend(legend_text, loc='upper left') yscale('log') axis([t_range[0], t_range[1], y_range[0], y_range[1]]) pp.savefig(fig) pp.close()
('glucose', 6, 'm'),\ ('glucose stationary', 7, 'm:')] pp = PdfPages('../res/2010-07-04.pdf') columns = [('PRK', [0,1,2], 15), ('GFP', [3,4,5], 20), ('control', [6,7], 50)] for i in range(len(columns)): fig = figure() (name, c_list, max_T) = columns[i] gr_mat = zeros((len(c_list), len(rows))) for j in range(len(c_list)): for k in range(len(rows)): (t, v) = vp.get_data(0, rows[k][1], c_list[j]) plot(t, v-min(v), rows[k][2]) gr_mat[j, k] = vp.fit_growth(t, v, fit_window_size, fit_start_threshold) #gr_mat[j, k] = vp.fit_growth2(t, v) legend_text = [] for k in range(len(rows)): (leg, r, color) = rows[k] max_dt = log(2)*60/min(gr_mat[:,r]) min_dt = log(2)*60/max(gr_mat[:,r]) legend_text.append("%s (%.0f-%0.f min)" % (leg, min_dt, max_dt)) legend(legend_text, loc='lower right') title(name) xlabel('Time (hr)') ylabel('GFP') yscale('log') axis([0, max_T, 0.001, 1]) pp.savefig(fig)
""" time - a vector of the time of each measurement (in hours) cell_count - a vector of the cell-count at each time point window - the size of the window for which to calculate the growth rates (in hours) start_time - the time point after which the input data can be trusted Note: the cell_count can be any measure that is proportional to the number of cells. For example, Optical Density (in OD), or level of luminescence (in CPS). """ from victor_parser import VictorParser import pylab if (__name__ == "__main__"): vp = VictorParser() fname = "../data/Elad's OD600_20100701_188.xls" vp.parse_excel(fname) (time, cell_count) = vp.get_data(0, 3, 0) pylab.figure() pylab.subplot(1, 2, 1) print "Logistic fit: gr = %.2f" % vp.fit_growth2( time, cell_count, plot_figure=True) pylab.subplot(1, 2, 2) print "linear fit in logscale: gr = %.2f" % vp.fit_growth( time, cell_count, window_size=1.5, start_threshold=0.01, plot_figure=True) pylab.show()
('ALL', 2, 'g'),\ ('AA1', 3, 'c'),\ ('AA2', 4, 'k'),\ ('Gluc', 5, 'b'),\ ('M9-', 6, 'm')] for i in range(len(columns)): fig = figure() (name, c_list, max_T) = columns[i] gr_mat = zeros((len(c_list), len(rows))) for j in range(len(c_list)): for k in range(len(rows)): (t, v) = vp.get_data(0, rows[k][1], c_list[j]) plot(t, v-min(v), rows[k][2]) gr_mat[j, k] = vp.fit_growth(t, v, fit_window_size, fit_start_threshold) #gr_mat[j, k] = vp.fit_growth2(t, v) legend_text = [] for k in range(len(rows)): (leg, r, color) = rows[k] max_dt = log(2)*60/min(gr_mat[:,r]) min_dt = log(2)*60/max(gr_mat[:,r]) legend_text.append("%s (%.0f-%0.f min)" % (leg, min_dt, max_dt)) legend(legend_text, loc='lower right') title(name) xlabel('Time (hr)') ylabel('GFP') yscale('log') axis([0, max_T, 0.001, 1]) pp.savefig(fig)
fit_window_size = 1.5 # hours fit_start_threshold = 0.01 leg = [ 'SOC+kana', 'M9+CAS+Glu+kana', 'M9+AA+Nt+Glu+kana', 'M9+Glu+kana', 'M9+Acetate+kana' ] color = ['g', 'r', 'b', 'm', 'c'] gr_mat = zeros((5, 10)) subplot(2, 1, 1) for c in range(0, 5): for r in range(5): (t, v) = vp.get_data(0, r, c) plot(t, v - min(v), color[r]) (gr, err) = vp.fit_growth(t, v, fit_window_size, fit_start_threshold) gr_mat[r, c] = gr legend([ leg[r] + " (%.0f min)" % (log(2) * 60 / mean(gr_mat[r, 0:5])) for r in range(5) ], loc='lower right') title('PRK') xlabel('Time (hr)') ylabel('OD') yscale('log') axis([0, t.max(), 0.001, 1]) subplot(2, 1, 2) for c in range(5, 10): for r in range(5):
plots.append((row_labels[r], 0, (0, t_max), (3e-2, 7e-1), 'OD', y_label)) plots.append((row_labels[r], 1, (0, t_max), (1e1, 1e7), 'Lumin', y_label)) plots.append((row_labels[r], "divide", (0, t_max), (1e2, 1e7), 'Limun/OD', y_label)) for (plot_title, victor_index, t_range, y_range, y_label, data_series) in plots: sys.stderr.write("Plotting %s (%s) ... \n" % (plot_title, str(victor_index))) fig = figure() title(plot_title) xlabel('Time (hr)') ylabel(y_label) legend_text = [] for (label, (color, cells)) in data_series.iteritems(): for (row, col) in cells: if (victor_index == "divide"): (time0, values0) = vp.get_data(0, row, col) (time1, values1) = vp.get_data(1, row, col) time = time0 values = values1/values0 else: (time, values) = vp.get_data(victor_index, row, col) plot(time, values, color) growth_rate = vp.fit_growth(time, values, fit_window_size, fit_start_threshold) legend_text.append("%s (%.0f min)" % (label, log(2)*60/growth_rate)) legend(legend_text, loc='upper left') yscale('log') axis([t_range[0], t_range[1], y_range[0], y_range[1]]) pp.savefig(fig) pp.close()