def get_figure(ax, file_df, gradient_df, strain_des): time = 48.0 location = "center" strain_map, des_strain_map = strainmap.load() print(des_strain_map) # stp, width = 5, 1 # wt_sigby jlb021 # delru_sigby jlb088 # delqp_sigby jlb039 # 2xqp_sigby jlb095 # delsigb_sigby jlb098 # fig.figimage(skimage.io.imread("10x_delqp_48_image_crop.jpg")) for c, (strain) in enumerate(strain_des): # , ,"delsigb_sigby"] fids = file_df[(file_df["time"] == time) & (file_df["location"] == location) & (file_df["strain"] == des_strain_map[strain])].index print(strain, " has ", len(fids)) df = gradient_df[gradient_df["file_id"].isin(fids)] print(file_df.loc[fids, "name"]) df = df[df["cdist"] > 2.0] # ignore top 2um for consistency df[["cdist", "ratio", "file_id"]].to_csv(f"source_data/figure8_b_{strain}.tsv", sep="\t") df_mean = df.groupby("cdist").mean() df_sem = df.groupby("cdist").sem() # df_mean[df] print(len(df)) color = figure_util.strain_color[des_strain_map[strain].upper()] label = figure_util.strain_label[des_strain_map[strain].upper()] ax.plot(df_mean.index, df_mean["ratio"], color=color, label=label) # /df["mean_red"]) ax.fill_between( df_mean.index, df_mean["ratio"] - df_sem["ratio"], df_mean["ratio"] + df_sem["ratio"], color=color, alpha=0.4, ) # /df["mean_red"]) # ax[c].plot(df_mean.index, df_mean["ratio"], color="purple")#/df["mean_red"]) # ax[c].fill_between(df_mean.index, df_mean["ratio"]-df_sem["ratio"],df_mean["ratio"]+df_sem["ratio"],color="purple", alpha=0.4 )#/df["mean_red"]) # ax[c].set_xlim(left=0, right=200) # leg = ax.legend(loc="upper right") # leg.get_frame().set_alpha(1.0) # ax.set_ylim(0, 0.2700) ax.set_ylim(0, 0.4500) ax.set_xlim(left=0, right=150) # ax.set_xlabel("Distance from air interface (μm)") ax.set_ylabel("Ratio of P$_{sigB}$-YFP to P$_{sigA}$-RFP") # ax.text(-0.05, letter_lab[1], "D", transform=ax.transAxes, fontsize=8) return ax
import matplotlib.pyplot as plt import matplotlib.gridspec as gs import pandas as pd import skimage.io import sys print(sys.path) import lib.strainmap as strainmap #from figure_util import dpi import lib.figure_util as figure_util figure_util.apply_style() strain_map, des_strain_map = strainmap.load() letter_lab = (-0.08, 1.0) fig = plt.figure() grid = gs.GridSpec(2, 3, height_ratios=[3, 1]) grid.update(left=0.1, right=0.98, bottom=0.1, top=0.99, hspace=0.04) #grid.update(hspace=0.05) this_dir = os.path.dirname(os.path.realpath(__file__)) strains = [figure_util.strain_label[s] for s in ["JLB021", "JLB088", "JLB039"]] biofilm_images = [ "SigB_48hrs_center_1_1_100615_sect.jpg", "delRU_48hrs_3_6_100615sect.jpg", "delQP_48hrs_2_5_100615_sect.jpg" ]
def main(): basedir = os.path.join(this_dir, "../../datasets/LSM700_63x_sigb") if not USE_CACHE_PLOTS: cell_df = pd.read_hdf(os.path.join(basedir, "single_cell_data.h5"), "cells") file_df = filedb.get_filedb(os.path.join(basedir, "file_list.tsv")) else: file_df = None cell_df = None time = 48 location = "center" slice_srt, slice_end = 5, 7 #10, 15 #slice_srt, slice_end = 5, 6 #10, 15 # # There is no major difference between 5-6 and 7-8, just the QP skew is bigger in 5-6 #slice_srt, slice_end = 7, 8 #10, 15 # Moving to 2um because it makes the plots look nicer. # fig, ax = plt.subplots(4, 2) # axhisto = ax[:, 1] # aximage = ax[:, 0] fig, ax = plt.subplots(2, 4) axhisto = ax[1, :] aximage = ax[0, :] for i, (name, path, roi, chans) in enumerate(image_list): impath = os.path.join(image_base_dir, path) aximage[i] = subfig_draw_bin.get_figure(aximage[i], name, impath, roi, chans, FP_max_min, (slice_srt, slice_end), add_scale_bar=i == 0) aximage[i].set_title("") aximage[i].text(imgletter_lab[0], imgletter_lab[1], topletters[i], transform=aximage[i].transAxes, **letter_settings, color="white") text_x = 0.40 text_top = 0.85 line_sep = 0.15 title_loc, cv_loc, samp_loc, cell_loc = [ (text_x, text_top - (line_sep * i)) for i in range(4) ] strain_map, des_strain_map = strainmap.load() gchan = "green_raw_bg_meannorm" rchan = "red_raw_bg_meannorm" if not USE_CACHE_PLOTS: cell_df = cell_df[cell_df[rchan] > 0].copy() #max_val = 30000 #max_val = 1.0 #6.0 #20000 #gmax_val = 1.0 #7.5 max_val = 6.5 #2.5 gmax_val = 6.5 #0.75 nbins = 150 rbins = (0, max_val, nbins) gbins = (0, gmax_val, nbins) percentile = 0 #99 list_of_histos = [("wt_sigar_sigby", rchan, "WT P$_{sigA}$-RFP", figure_util.strain_color["JLB021"]), ("wt_sigar_sigby", gchan, "WT P$_{sigB}$-YFP", figure_util.strain_color["JLB021"]), ("delqp_sigar_sigby", gchan, "ΔrsbQP P$_{sigB}$-YFP", figure_util.strain_color["JLB039"]), ("delru_sigar_sigby", gchan, "ΔrsbRU P$_{sigB}$-YFP", figure_util.strain_color["JLB088"])] print("-----------") for i, (strain, chan, label, color) in enumerate(list_of_histos): print(label) strain_df = None if not USE_CACHE_PLOTS: fids = file_df[(file_df["time"] == time) & (file_df["location"] == location) & (file_df["strain"] == des_strain_map[strain])].index strain_df = cell_df[cell_df["global_file_id"].isin(fids)] dset = time, location, strain plot_args = {"color": color, "max_min": "std", "mode_mean": False} tbins = gbins if "red" in chan: tbins = rbins args = (axhisto[i], strain_df, chan, tbins, (slice_srt, slice_end), dset, percentile, USE_CACHE_PLOTS, this_dir, plot_args) axhisto[i], _, meandmed = subfig_indivfile_histo.get_figure(*args) axhisto[i].text(1.0, hisletter_lab[1], label, horizontalalignment='right', verticalalignment='top', color="black", fontsize=plt.rcParams["axes.titlesize"], transform=axhisto[i].transAxes) axhisto[i].text(hisletter_lab[0], hisletter_lab[1], letters[i], transform=axhisto[i].transAxes, **letter_settings) #leg = axhisto[0].legend(loc="center right") #axhisto[-1].set_xlabel("Mean normalised cell fluorecence") axhisto[0].set_ylabel("Percentage of cells") axhisto[0].set_xlim(0, max_val) for a in np.ravel(axhisto): #a.set_ylabel("Percentage of cells") a.set_xlabel("Mean normalised cell fluorecence") a.set_ylim(0, 5) a.set_xlim(0, gmax_val) a.tick_params(axis='x', which='both', direction='out') #, length=2, pad=0) a.tick_params(axis='y', which='both', direction='out') #, length=2, pad=0) # for a in axhisto[:-1]: # a.set_xticklabels([]) for a in axhisto[1:]: a.set_yticklabels([]) filename = "demo_longtail" #fig.subplots_adjust(left=000, ri0ht=0.98, top = 1.0, bottom=0.06, hspace=0.08, wspace=0.2) #width, height = figure_util.get_figsize(figure_util.fig_width_small_pt, wf=1.0, hf=1.7) fig.subplots_adjust(left=0.05, right=0.99, top=1.0, bottom=0.10, hspace=0.08, wspace=0.15) width, height = figure_util.get_figsize(figure_util.fig_width_big_pt, wf=1.0, hf=0.5) fig.set_size_inches(width, height) figure_util.save_figures(fig, filename, ["png", "pdf"], this_dir)
def main(): curve_score_methods = { "std": ("Standard Deviation", 2.5, lambda d, h, b: np.std(d)), "mean": ("Mean", 4.0, lambda d, h, b: np.mean(d)), "cv": ("Coefficient of variation", 1.2, lambda d, h, b: scipy.stats.variation(d)), "skew": ("modern skew", 3.5, lambda d, h, b: scipy.stats.skew(d)), "skew_normed": ("Skew", 4.0, lambda d, h, b: scipy.stats.skew(d, bias=False)), "mode": ("Mode", 3.5, lambda d, h, b: b[h.argmax()]), "num": ("# cells", 2000, lambda d, h, b: len(d)), "pearson_mode_mean": ("pearson Mode mean", 1.2, pearson_mode_mean_skew), "non_parameteric_skew": ("Non parameteric", 0.4, non_parametric_skew), "kurtosis": ("Kurtosis", 8.0, lambda d, h, b: scipy.stats.kurtosis(d)) } plot_colors = [ #"mean", "std", #"cv", #"skew", #"num", "skew_normed", #"pearson_mode_mean", #"non_parameteric_skew", #"kurtosis", ] basedir = "../../datasets/biofilm_cryoslice/LSM700_63x_sigb" #cell_df = pd.read_hdf(os.path.join(basedir, "new_edge_bgsubv2_maxnorm_lh1segment.h5"), "cells") #cell_df = pd.read_hdf(os.path.join(basedir, "new_edge_bgsubv2_maxnorm_lh1segment.h5"), "cells") #cell_df = pd.read_hdf(os.path.join(basedir, "mini_bgsubv2_maxnorm_comp5.h5"), "cells") cell_df = pd.read_hdf(os.path.join(basedir, "bgsubv2_maxnorm_comp5.h5"), "cells") cell_df = cell_df[cell_df["red_bg_maxnorm"] > 0] cell_df = cell_df[cell_df["distance"] > 2] time = 48 #.0 location = "center" file_df = filedb.get_filedb(os.path.join(basedir, "file_list.tsv")) strain_map, des_strain_map = strainmap.load() percentile = 0 #99# gmax = None rmax = None gmax = 0.7 rmax = 3.0 strains = [("wt_sigar_sigby", "red_bg_maxnorm", rmax), ("wt_sigar_sigby", "green_bg_maxnorm", gmax), ("delqp_sigar_sigby", "green_bg_maxnorm", gmax), ("delru_sigar_sigby", "green_bg_maxnorm", gmax), ("2xqp_sigar_sigby", "green_bg_maxnorm", gmax)] fig, ax = plt.subplots(len(plot_colors), len(strains), sharex=True, sharey=True) for c, (strain, chan, maxv) in enumerate(strains): strain_num = des_strain_map[strain] distances, sbins, histograms, stats = get_strain_result( file_df, cell_df, time, location, strain_num, chan, maxv, percentile, curve_score_methods) for r, k in enumerate(plot_colors): color = figure_util.strain_color[strain_num.upper()] ax[r, c], mx, mv = plot_curves(ax[r, c], color, distances, sbins, histograms, stats, k) if c == len(strains) - 1: posn = ax[r, c].get_position() cbax = fig.add_axes( [posn.x0 + posn.width + 0.01, posn.y0, 0.02, posn.height]) max_val = curve_score_methods[k][1] label = curve_score_methods[k][0] sm = plt.cm.ScalarMappable(cmap=plt.cm.plasma, norm=plt.Normalize(vmin=0, vmax=max_val)) sm._A = [] plt.colorbar(sm, cax=cbax) #, fig=fig) cbax.set_ylabel(label, rotation=-90, labelpad=8) #max_val = m #metric_name = n # ax[0].set_title("WT P$_{sigA}$-RFP") # ax[1].set_title("WT P$_{sigB}$-YFP") # ax[2].set_title("ΔrsbQP P$_{sigB}$-YFP") # ax[3].set_title("ΔrsbRU P$_{sigB}$-YFP") # for a in ax[1:]: # a.set_ylabel("") # ax[0].set_ylabel("Distance from air interface (μm)") plt.show()
#dataset_dir = "datasets/LSM780_10x_sigb/" dataset_dir = "/media/nmurphy/BF_Data_Orange/datasets/lsm700_live20x_newstrain1" #gradient_df = pd.read_hdf(dataset_dir + "gradient_data.h5", "data") gradient_df = pd.read_hdf( os.path.join(dataset_dir, "gradient_data_distmap.h5"), "data") #gradient_df["ratio"] = gradient_df["green_bg_mean"]/gradient_df["red_bg_mean"] gradient_df[ "ratio"] = gradient_df["green_raw_mean"] / gradient_df["red_raw_mean"] output_dir = os.path.join(dataset_dir, "gradient_summary") file_df = filedb.get_filedb(os.path.join(dataset_dir, "file_list.tsv")) time = 48.0 #strain_map, des_strain_map = strainmap.load() strain_to_type, type_to_strain = strainmap.load() cell_types = np.unique([t[0] for t in strain_to_type.values()]) strain_to_type = {s: t[0] for s, t in strain_to_type.items()} type_to_strain = dict(zip(cell_types, [[]] * len(cell_types))) for strain, typel in strain_to_type.items(): type_to_strain[typel] = type_to_strain[typel] + [strain] def get_strain(name): fdf = file_df[(file_df["time"] == time) & (file_df["strain"].isin(type_to_strain[name]))] fids = fdf.index #print(fdf.columns) e = len((fdf["strain"] + fdf["dirname"]).unique()) print(name, " has ", len(fids), "images from ", e, "experiments") print(fdf[["dirname", "name"]])
def main(): curve_score_methods = { "std": ("Standard deviation", (0.0, 1.0), lambda d, h, b: np.std(d)), # 1.5, "mean": ("Mean", (0.0, 4.0), lambda d, h, b: np.mean(d)), "cv": ( "Coefficient of variation", (0.3, 0.8), lambda d, h, b: scipy.stats.variation(d), ), # "skew": ("modern skew", # 0.0, 3.0, # lambda d, h, b: scipy.stats.skew(d)), "skew_normed": ( "Skew", (0.0, 2.9), lambda d, h, b: scipy.stats.skew(d, bias=False), ), # "mode": ("Mode", # 0.0, 3.5, # lambda d, h, b: b[h.argmax()]), # "num": ("# cells", # 0.0, 2000, # lambda d, h, b: len(d)), # "pearson_mode_mean": ("pearson Mode mean", # 0.0, 1.2, # joy_plots_of_gradients.pearson_mode_mean_skew), # "non_parameteric_skew": ("Non parameteric", # 0.0, 0.4, # joy_plots_of_gradients.non_parametric_skew), "kurtosis": ("Kurtosis", (0.0, 8.0), lambda d, h, b: scipy.stats.kurtosis(d)), } plot_colors = [ # "mean", # "std", "cv", # "skew", # "num", # "skew_normed", "skew_normed", # same as pandas # "pearson_mode_mean", # "non_parameteric_skew", # "kurtosis", ] # basedir = "../../data/bio_film_data/63xdatasets" #this_dir = os.path.dirname(__file__) this_dir = "/media/nmurphy/BF_Data_Orange/" #basedir = os.path.join(this_dir, "../../datasets/LSM700_63x_sigb") basedir = os.path.join(this_dir, "datasets/LSM700_63x_sigb") # cell_df = pd.read_hdf(os.path.join(basedir, "edge_redo_lh1segment_data_bg_back_bleed.h5"), "cells") # cell_df = pd.read_hdf(os.path.join(basedir, "new_edge_bgsubv2_maxnorm_lh1segment.h5"), "cells") cell_df = pd.read_hdf(os.path.join(basedir, "single_cell_data.h5"), "cells") # cell_df = pd.read_hdf(os.path.join(basedir, "edge_redo_lh1segment_data.h5"), "cells") # cell_df = pd.read_hdf(os.path.join(basedir, "lh1segment_bgsub_data.h5"), "cells") # cell_df = cell_df[cell_df["area"] > 140] cell_df = cell_df[cell_df["distance"] > 2] time = 48 # .0 location = "center" file_df = filedb.get_filedb(os.path.join(basedir, "file_list.tsv")) strain_map, des_strain_map = strainmap.load() # cbar_mins = {0: 0.5, 1:0.0} percentile = 0 # 99# # green_chan = "meannorm_green" # red_chan = "meannorm_red" rmax = 6.5 gmax = 6.5 # 0.4 green_chan = "green_raw_bg_mean" red_chan = "red_raw_bg_mean" rmax = 50000 gmax = 10000 strains = [ ("wt_sigar_sigby", red_chan, rmax, "WT\n P$_{sigA}$-RFP"), ("wt_sigar_sigby", green_chan, gmax, "WT\n P$_{\mathit{sigB}}$-YFP"), ( "delru_sigar_sigby", green_chan, gmax, "Δ$\mathit{rsbRU}$\n P$_{\mathit{sigB}}$-YFP", ), ( "delqp_sigar_sigby", green_chan, gmax, "Δ$\mathit{rsbQP}$\n P$_{\mathit{sigB}}$-YFP", ), ] # ("2xqp_sigar_sigby", green_chan, gmax, "2$\\times$rsbQP\n P$_{sigB}$-YFP")] fig, ax = plt.subplots(len(plot_colors), len(strains), sharey=True) for c, (strain, chan, max_val, name) in enumerate(strains): strain_num = des_strain_map[strain] distances, sbins, histograms, stats = joy_plots_of_gradients.get_strain_result( file_df, cell_df, time, location, strain_num, chan, max_val, percentile, curve_score_methods, ) for r, k in enumerate(plot_colors): color = figure_util.strain_color[strain_num.upper()] ax[r, c], mv, leglist = joy_plots_of_gradients.plot_curves( ax[r, c], color, distances, sbins, histograms, stats, k) if c == len(strains) - 1: posn = ax[r, c].get_position() cbax = fig.add_axes([ posn.x0 + posn.width + 0.0005, posn.y0, 0.015, posn.height ]) label = curve_score_methods[k][0] min_zval = curve_score_methods[k][1][0] max_zval = curve_score_methods[k][1][1] sm = plt.cm.ScalarMappable( cmap=plt.get_cmap("viridis"), norm=plt.Normalize(vmin=min_zval, vmax=max_zval), ) sm._A = [] _ = plt.colorbar(sm, cax=cbax) # , fig=fig) cbax.set_ylabel(label, rotation=-90, labelpad=8) cbax.tick_params(direction="out") if r == 0: ax[r, c].set_title(name, fontsize=6) ax[r, c].get_xaxis().set_ticklabels([]) ax[r, c].set_xlim(0, max_val) # this didnt return the right mode for some reason # leg = ax[0, -1].legend(leglist) leg = ax[0, -1].legend(leglist, ["Mode", "Mean"], loc="lower left", bbox_to_anchor=(0.84, 0.97)) leg.set_zorder(400) for a in ax.flatten(): a.tick_params(direction="out") ax[0, 0].annotate( "Distance from top of biofilm (μm)", xy=(0, 0), xytext=(0.02, 0.5), textcoords="figure fraction", # arrowprops=dict(facecolor='black', shrink=0.05), horizontalalignment="center", verticalalignment="center", fontsize="medium", color=mpl.rcParams["axes.labelcolor"], rotation=90, ) ax[1, 2].annotate( "Normalized fluoresence", xy=(0, 0), xytext=(0.5, 0.04), textcoords="figure fraction", # arrowprops=dict(facecolor='black', shrink=0.05), horizontalalignment="center", verticalalignment="center", fontsize="medium", color=mpl.rcParams["axes.labelcolor"], ) # for a in ax[:, 0].flatten(): # ticklabs = a.yaxis.get_ticklabels() # ticklabs = a.get_yticks()#.tolist() # ticklabs[-1] = '' letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] # letter_lab = (-0.13, 0.98) for a, l in zip(ax.flatten(), letters): a.annotate( l, xy=(0, 0), xytext=(-0.13, 0.95), textcoords="axes fraction", # arrowprops=dict(facecolor='black', shrink=0.05), horizontalalignment="center", verticalalignment="center", fontsize=figure_util.letter_font_size, color="black", ) # a.text(letter_lab[0], letter_lab[1], l, transform=a.transAxes, fontsize=8) filename = "sup_meta_histo" width, height = figure_util.get_figsize(figure_util.fig_width_medium_pt, wf=1.0, hf=0.6) fig.subplots_adjust(left=0.085, right=0.89, top=0.89, bottom=0.13, hspace=0.20, wspace=0.25) fig.set_size_inches(width, height) # common.cm2inch(width, height)) figure_util.save_figures(fig, filename, ["png", "pdf"], this_dir)
def main(): basedir = os.path.join(this_dir, "../../datasets/LSM700_63x_sigb") time = 48 location = "center" # slice_srt, slice_end = 5, 7 #10, 15 slice_srt_end = (5, 7) fig, ax = plt.subplots(2, 2) axhisto = ax[1, 1] aximage = [ax[0, 0], ax[0, 1], ax[1, 0]] for i, (name, path, roi, chans) in enumerate(image_list): impath = os.path.join(image_base_dir, path) aximage[i] = subfig_draw_bin.get_figure( aximage[i], name, impath, roi, chans, FP_max_min, slice_srt_end, add_scale_bar=i == 0, ) aximage[i].set_title("") aximage[i].text(imgletter_lab[0], imgletter_lab[1], topletters[i], transform=aximage[i].transAxes, **letter_settings) # , color="white") aximage[i].text(0.05, 0.05, name, transform=aximage[i].transAxes, **label_settings, color="white") ##################### ## Histograms generate_data_subset = False strain_map, des_strain_map = strainmap.load() file_df = filedb.get_filedb(os.path.join(basedir, "file_list.tsv")) cachedpath = os.path.join(basedir, "histo_tops_normed.h5") gchan = "green_raw_bg_mean" rchan = "red_raw_bg_mean" nbins = 150 gmax = 1 gbins = np.linspace(0, gmax, nbins) list_of_histos = [ # ("2xqp_sigar_sigby", gchan, rchan, gbins, slice_srt_end, "2xQP", strain_color["JLB095"]), ( "wt_sigar_sigby", gchan, rchan, gbins, slice_srt_end, r"WT P$_{\mathit{sigB}}$-YFP", strain_color["JLB021"], ), ( "delru_sigar_sigby", gchan, rchan, gbins, slice_srt_end, r"Δ$\mathit{rsbRU}$ P$_{\mathit{sigB}}$-YFP", strain_color["JLB088"], ), ( "delqp_sigar_sigby", gchan, rchan, gbins, slice_srt_end, r"Δ$\mathit{rsbQP}$ P$_{\mathit{sigB}}$-YFP", strain_color["JLB039"], ), ] axes = [axhisto] * len(list_of_histos) if generate_data_subset: df = pd.read_hdf(os.path.join(basedir, "single_cell_data.h5"), "cells") cellsdf = subfig_normalised_histos.get_data_subset( df, file_df, list_of_histos, time, location, cachedpath) else: cellsdf = pd.read_hdf(cachedpath, "cells") axes = subfig_normalised_histos.get_figure(cellsdf, file_df, axes, time, location, list_of_histos) axes[0].legend() axhisto.text(hisletter_lab[0], hisletter_lab[1], letters[0], transform=axhisto.transAxes, **letter_settings) axhisto.set_ylabel("Percentage of cells") axhisto.set_xlim(0, gmax) axhisto.set_ylim(0, 8.5) axhisto.tick_params(axis="x", which="both", direction="out") # , length=2, pad=0) axhisto.tick_params(axis="y", which="both", direction="out") # , length=2, pad=0) axhisto.yaxis.set_major_locator(mticker.MaxNLocator(nbins=3, integer=True)) axhisto.set_xlabel("Normalised cell fluorecence") filename = "demo_longtail" fig.subplots_adjust(left=0.05, right=0.95, top=0.99, bottom=0.1, hspace=0.08, wspace=0.20) width, height = figure_util.get_figsize(figure_util.fig_width_small_pt, wf=1.0, hf=0.9) fig.set_size_inches(width, height) figure_util.save_figures(fig, filename, ["png", "pdf"], this_dir)
def main(): this_dir = os.path.dirname(__file__) basedir = os.path.join(this_dir, "../../datasets/LSM700_63x_sigb") #cell_df = pd.read_hdf(os.path.join(basedir, "edge_redo_lh1segment_data_bg_back_bleed.h5"), "cells") cell_df = pd.read_hdf(os.path.join(basedir, "single_cell_data.h5"), "cells") print(cell_df.columns) file_df = filedb.get_filedb(os.path.join(basedir, "file_list.tsv")) file_df.loc[file_df["time"] == 26.0, ['time']] = 24.0 file_df.loc[file_df["time"] == 38.0, ['time']] = 36.0 USE_CACHE_PLOTS = False time = 48 location = "center" slice_srt, slice_end = 5, 7 fig, axhisto = plt.subplots(1, 1) strain_map, des_strain_map = strainmap.load() gchan = "green_raw_bg_autofluor_bleedthrough_meannorm" gmax_val = 20 nbins=150 gbins = (0, gmax_val, nbins) percentile = 0 list_of_histos = [ ("wt_sigar_sigby", gchan, "WT P$_{sigB}$-YFP", strain_color["JLB021"]), ("delqp_sigar_sigby", gchan, "ΔrsbQP P$_{sigB}$-YFP", strain_color["JLB039"]), ("delru_sigar_sigby", gchan, "ΔrsbRU P$_{sigB}$-YFP", strain_color["JLB088"]), ("2xqp_sigar_sigby", gchan, "2$\\times$rsbQP P$_{sigB}$-YFP", strain_color["JLB095"]), ] print("-----------") lelines = [] lelabs = [] for i, (strain, chan, label, color) in enumerate(list_of_histos): print(label) fids = file_df[(file_df["time"] == time) & (file_df["location"] == location) & (file_df["strain"] == des_strain_map[strain])].index strain_df = cell_df[cell_df["global_file_id"].isin(fids)] #strain_df = get_strain(file_df, cell_df, strain) plot_args = {"color":color, "max_min":"none", "mode_mean":False} tbins = gbins dset = time, location, strain args = (axhisto, strain_df, chan, tbins, (slice_srt, slice_end), dset, percentile, USE_CACHE_PLOTS, this_dir, plot_args) axhisto, line, _ = subfig_indivfile_histo.get_figure(*args) lelines += [line] lelabs += [label] axhisto.legend(lelines, lelabs) axhisto.set_xlabel("Normalised cell fluorecence (bleed through subtracted)") axhisto.set_ylabel("Percentage of cells") axhisto.set_ylim(0, 7) axhisto.set_xlim(0, gmax_val) filename = "sup_bleed_histo" fig.subplots_adjust(left=0.1, right=0.9, top = 0.98, bottom=0.2)#, hspace=0.35, wspace=0.2) width, height = figure_util.get_figsize(figure_util.fig_width_small_pt, wf=1.0, hf=0.5) fig.set_size_inches(width, height)# common.cm2inch(width, height)) figure_util.save_figures(fig, filename, ["png", "pdf"], this_dir)