'this work\n(correction applied\nto all cells)', 'Garcia & Phillips\n2011', 'Brewster et al.\n 2014', 'Razo-Mejia et al.\n 2018' ]) ax[1].set_xlabel('repressors per cell') ax[1].set_ylabel('fold-change') # Plot the "gold standard" binding energy. ax[0].fill_betweenx([-1, 10], epRA_low, epRA_high, color=colors['black'], alpha=0.25, zorder=1) # Plot the inferred DNA binding energies. for g, d in stats.groupby('source'): if g == 'no_correction': alpha = 0.25 else: alpha = 1 epRA_median, low, high = d[d['parameter'] == 'epRA'][[ 'median', 'hpd_min', 'hpd_max' ]].values[0] ax[0].hlines(position[g], low, high, lw=1, color=edge_colors[g], alpha=alpha, zorder=99) ax[0].plot(epRA_median,
gamma = mwc.bayes.Jeffreys('gamma', lower=1E-9, upper=100) # Compute the expected value. time = data['elapsed_time_min'].values mu = np.log(a0) + time * lam # Define the likelihood and sample. like = pm.Cauchy('like', mu, gamma, observed=np.log(data['OD_600'].values)) trace = pm.sample(tune=5000, draws=5000) trace_df = mwc.stats.trace_to_dataframe(trace, model) stats = mwc.stats.compute_statistics(trace_df) # %% Compute the best fit and credible region modes = {} hpds = {} grouped = stats.groupby('parameter') for g, d in grouped: modes[g] = d['mode'].values[0] hpds[g] = [d[['hpd_min', 'hpd_max']].values] time_range = np.linspace(data['elapsed_time_min'].min(), data['elapsed_time_min'].max(), 500) best_fit = modes['a0'] * np.exp(modes['lambda'] * time_range) cred_region = np.zeros((2, len(time_range))) for i, t in enumerate(time_range): theo = trace_df['a0'] * np.exp(t * trace_df['lambda']) cred_region[:, i] = mwc.stats.compute_hpd(theo, mass_frac=0.95) # %% Compute the doubling time. t_double = np.log(2) / modes['lambda']
# Load the plates and statistics plates = pd.read_csv('../../data/compiled_growth_plates.csv', comment='#') stats = pd.read_csv('../../data/compiled_growth_statistics.csv', comment="#") plates['temp_C'] = np.round(plates['temp_C']) plates['time_min'] = np.round(plates['time_min']) plates = plates[plates['time_min'] <= 600] #%% # reform the stats stats = stats[((stats['carbon'] == 'glucose') | (stats['carbon'] == 'acetate') | (stats['carbon'] == 'glycerol')) & ((stats['temp'] == 37) | (stats['temp'] == 32) | (stats['temp'] == 42))] tidy_stats = pd.DataFrame([]) for g, d in stats.groupby(['date', 'carbon', 'temp', 'run_number']): growth_rate = d[d['parameter'] == 'max df']['value'].values[0] growth_err = d[d['parameter'] == 'max df std']['value'].values[0] dbl_time = d[d['parameter'] == 'inverse max df']['value'].values[0] dbl_err = d[d['parameter'] == 'inverse max df std']['value'].values[0] tidy_stats = tidy_stats.append( { 'date': g[0], 'carbon': g[1], 'temp_C': g[2], 'run_number': g[3], 'growth_rate': growth_rate, 'dbl_time': dbl_time, 'growth_err': growth_err, 'dbl_err': dbl_err