ctrappy.gui_figures

Functions for calculating and plotting useful quantities from Experiments.

ctrappy.gui_figures.get_bleaching_traces(experiment, time_s=False)

Get all bleaching traces within the Experiment. By default, use frames as time unit - set time_s=True to use seconds as time unit. Result is returned in a dictionary.

ctrappy.gui_figures.get_diffusion(experiment, config, loc_kbp=False)

Get diffusion coefficients from traces in the experiment. We also need the config dictionary for diffusion calculations. Switch from microns to kbp with loc_kbp=True.

ctrappy.gui_figures.get_diffusion_hist(experiment, config, lims=None, n_bins=30, loc_kbp=False)

Make diffusion coefficient histogram for the experiment. We also need the config dictionary for diffusion calculations. You can provide x-limits for log(D) as a 2-tuple of floats using the lims argument, and set the number of histogram bins with n_bins. Switch from microns to kbp with loc_kbp=True.

ctrappy.gui_figures.get_diffusion_hist_bootstrap(experiment, config, lims=None, n_bins=30, n_samples=100, init_vals=None, loc_kbp=False)

Get diffusion coefficients from traces in a list of scans. Take n_samples number of bootstrap samples from the distribution and fit each bootstrap sample separately. Plot the mean D distribution with confidence intervals and average fit.

ctrappy.gui_figures.get_lifetime(experiment, time_s=False, single_step=True)

Get and fit trace lifetimes from the experiment; switch the time unit from frames to seconds with time_s=True. Set single_step to False if you input an experiment containing multistep bleaching data. For single step, multi- color data, the lifetime is taken on the Trace level by averaging over Track lifetimes. For multistep, multicolor data every step of every color is added to the lifetime histogram.

ctrappy.gui_figures.get_location_histogram(experiment, n_bins=24, loc_kbp=False, from_center=False, norm_per_scan=False, cf_res=0.05)

Plot starting location of all Traces. You can set the number of bins in n_bins. By default, location units are microns (switch to kbp with loc_kbp=True). Plot the location from the DNA center with from_center=True. You can normalize the results by scan with norm_per_scan=True; by default results are normalized by the total number of traces. Provide the confocal pixel resolution in cf_res, 0.05 micron by default.

ctrappy.gui_figures.get_location_traces(experiment, time_s=False, loc_kbp=False, show_single_spots=False)

Get all location traces in the Experiment. By default, time units are frames (switch to seconds with time_s=True) and location units are microns (switch to kbp with loc_kbp=True); disconnected spots are not shown (show them with show_single_spots=True). Data is returned in a dictionary.

ctrappy.gui_figures.get_processivity(experiment)

Get processivities, put in data dictionary.

ctrappy.gui_figures.get_spots_per_DNA(experiment)

Calculate the number of spots per DNA for an experiment; returns a dictionary.

ctrappy.gui_figures.get_step_sizes(experiment, lims=None, n_bins=30)

Get distribution of step sizes from experiment. You can manually set the step size plotting limits with lims (a 2-tuple of floats), and choose the number of bins with n_bins.

ctrappy.gui_figures.get_stoichiometry(experiment, color_names=None, norm_per_scan=False)

Get stoichiometries of all Traces in the Experiment. You can set the names of the tagged proteins for each color by setting color_names to a list with three strings for (r, g, b), respectively. You can normalize the results by scan with norm_per_scan=True; by default results are normalized by the total number of traces.

ctrappy.gui_figures.plot_bead_detection(intensity, bead_fit, offset_values, image)

Plot detected beads on an intensity profile.

Parameters:
  • intensity (numpy array of floats) – Projected intensity profile.

  • bead_fit (numpy array of floats) – Fitted bead profile.

  • offset_values (2-tuple of floats) – Offset values for marking the start and end of the DNA.

  • image (ctrappy.image.Image object) – Image object.

Returns:

fig

Return type:

matplotlib.figure.Figure

ctrappy.gui_figures.plot_bleaching_traces(data)

Plot bleaching traces from data dictionary, generated with get_bleaching_traces().

ctrappy.gui_figures.plot_diffusion_hist(data, fit_function=None, fit_params=None, show_wilson_confint=True)

Plot diffusion coefficient histogram using the dictionary generated with get_diffusion_hist().

ctrappy.gui_figures.plot_diffusion_hist_bootstrap(data)

Plot diffusion histogram with bootstrapping from dictionary generated with get_diffusion_hist_bootstrap().

ctrappy.gui_figures.plot_fdcurves(h5file, marker=True)

Plot all fd-curves in an h5file, within fd-curve markers. If marker=False, simply plot all fd-data in the h5file. Returns a figure and a DataFrame.

ctrappy.gui_figures.plot_force_over_time(h5file)

Plot force data in an h5file; returns a figure and a DataFrame.

ctrappy.gui_figures.plot_lifetime(data)

Plot the lifetime data generated with get_lifetime().

ctrappy.gui_figures.plot_location_histogram(data)

Plot location histogram using the dictionary generated by get_location_histogram().

ctrappy.gui_figures.plot_location_traces(data, plot_id=False, lines=None)

Plot all traces from data dictionary, generated with get_location_traces(). You can show the track ids on the resulting figure with plot_id=True; you can add horizontal lines by setting lines to a list of floats.

ctrappy.gui_figures.plot_processivity(data)

Plot result of get_processivity().

ctrappy.gui_figures.plot_scan_spots(image, frame, display_max, offset_values, spots, radius)

Plot spots in an Image object.

Parameters:
  • image (ctrappy.image.Image) – Image object.

  • frame (int) – Frame to plot.

  • display_max (int) – Maximum pixel value.

  • offset_values (2-tuple of floats) – Offset values for marking the start and end of the DNA

  • spots (pandas DataFrame) – Dataframe containing spots.

  • radius (int or list of 3 ints) – Detection radius (or radii per color).

Returns:

fig

Return type:

matplotlib.figure.Figure

ctrappy.gui_figures.plot_spots_per_DNA(data)

Plot the number of spots per DNA in a histogram from a dictionary generated with get_spots_per_DNA().

ctrappy.gui_figures.plot_step_sizes(data, vlines=None)

Plot step size histogram data generated by get_step_sizes(); you can plot vertical lines using float values in a list passed to the argument vlines.

ctrappy.gui_figures.plot_stoichiometry(data)

Plot all stoichiometries in an experiment, using the data dictionary generated by get_stoichiometry().