slitflow.trj.wfastspt module

Caution

This module consists of brief wrapper classes of fastspt package.

Wrapper classes do not cover all functionality of fastspt functions. Please create your custom class to use fastspt functions that are not provided in this module.

Do not ask the fastspt developers any questions about the wrapper part that is not directly related to the fastspt package.

Please cite the following publication of the original package if you use this module.

Hansen, Anders S., Maxime Woringer, Jonathan B. Grimm, Luke D. Lavis,
Robert Tjian, and Xavier Darzacq. "Robust model-based analysis of
single-particle tracking experiments with Spot-On." Elife 7 (2018): e33125.

Reference: Spot-On web site

class JumpLenDist(info_path=None)[source]

Bases: Table

Calculate jump length distribution using fastspt package.

See also the documentation of compute_jump_length_distribution.

Caution

The distribution is calculated from all trajectories entered into the process(). You have to split the required data into appropriate depths.

Parameters:
  • reqs[0] (Table) – Trajectory Table. Required param; length_unit, interval. Required columns; frm_no, x_um, y_um.

  • param["trj_depth"] (int) – The depth number of the “trj_no” column.

  • param["CDF"] (bool, optional) – Whether to use CDF. Default=False.

  • param["useEntireTraj"] (bool, optional) – Whether to use entire trajectory. Defaults to False.

  • param["TimePoints"] (int, optional) – Maximum step number + 1 to make histograms. Defaults to 8.

  • param["GapsAllowed"] (int, optional) – Allowed gap frames in a trajectory. See original document.

  • param["JumpsToConsider"] (int) – Jumps to Consider. See original document.

  • param["MaxJump"] (float, optional) – Maximal displacement for PDF in micrometer. Defaults to 1.25.

  • param["BinWidth"] (float, optional) – Binning size for PDF in micrometer. Defaults to 0.010.

  • param["split_depth"] (int) – File split depth number.

Returns:

Jump length distribution histogram

Return type:

Table

set_info(param)[source]

Copy params from reqs[0] and add columns and params.

static process(reqs, param)[source]

Calculate jump length distribution using fastspt package.

Parameters:
  • reqs[0] (pandas.DataFrame) – Trajectory table. Required params; length_unit. Required columns; frm_no, x_um and y_um.

  • param["index_cols"] (list of str) – Trajectory grouping column names. Required columns; frm_no.

  • param["calc_cols"] (list of str) – Column names of X,Y-coordinate.

  • param["CDF"] (bool) – Whether to use CDF. Defaults to False.

  • param["useEntireTraj"] (bool) – Whether to use entire trajectory. Defaults to False.

  • param["TimePoints"] (int) – Maximum step number + 1 to make histograms. Defaults to 8.

  • param["GapsAllowed"] (int) – Allowed gap frames in a trajectory. See original document.

  • param["JumpsToConsider"] (int) – Jumps to Consider. See original document.

  • param["MaxJump"] (float) – Maximal displacement for PDF in micrometer.

  • param["BinWidth"] (float) – Binning size for PDF in micrometer.

Returns:

Jump length distribution table

Return type:

pandas.DataFrame

to_fastspt_cell(df, param)[source]

Convert trajectory table to fastspt compatible list.

Parameters:
  • df (pandas.DataFrame) – Trajectory table containing X,Y-coordinate.

  • param["index_cols"] (list of str) – Column names for grouping trajectories. Required columns; frm_no.

  • param["calc_cols"] (list of str) – Column names of X,Y-coordinate.

  • param["interval"] (float) – Time interval in second.

Returns:

fastspt compatible (xy, time, frame number) list

Return type:

list

to_hist_df(HistVecJumps, JumpProb, HistVecJumpsCDF, JumpProbCDF)[source]

Convert fastspt compatible list to pandas.DataFrame.

Parameters:
Returns:

Jump length distribution histogram table

Return type:

pandas.DataFrame

class FitJumpLenDist2comp(info_path=None)[source]

Bases: Table

Fit jump length distribution to two-states model using fastspt.

Wrapping class of fit_jump_length_distribution.

Parameters:
  • reqs[0] (JumpLenDist) – Jump length distribution Table. Required param; length_unit, interval, CDF.

  • param["lower_bound"] (list of float) – Lower bound of fit parameters. The list should be [D_free, D_bound, F_bound].

  • param["upper_bound"] (list of float) – Upper bound of fit parameters. The list should be [D_free, D_bound, F_bound].

  • param["LocError"] (float or list of float) – Explicit localization error if you do not want to fit it. Otherwise [lower bound, upper bound] of the LocError value for fitting.

  • param["iterations"] (int) – Fitting iteration number.

  • param["dZ"] (int) – Axial illumination slice length.

  • param["useZcorr"] (bool) – Whether to use Z correction.

  • param["a"] (float, optional) – Zcorr constant a if Zcorr is used.

  • param["b"] (float, optional) – Zcorr constant b if Zcorr is used.

  • param["init"] (list of float, optional) – Initial values of fit parameters for [D_free, D_bound, F_bound, sigma(optional)].

  • param["split_depth"] (int) – File split depth number.

Returns:

Fitting result of jump length distribution histogram

Return type:

Table

set_info(param)[source]

Copy params from reqs[0] and add columns.

static process(reqs, param)[source]

Fit jump length distribution to the model using fastspt.

Parameters:
  • reqs[0] (pandas.DataFrame) – Jump length distribution histogram.

  • param["lower_bound"] (list of float) – Lower bound of fit parameters. The list should be [D_free, D_bound, F_bound].

  • param["upper_bound"] (list of float) – Upper bound of fit parameters. The list should be [D_free, D_bound, F_bound].

  • param["LocError"] (float or list of float) – Explicit localization error if you do not want to fit it. Otherwise [lower bound, upper bound] of the LocError value for fitting.

  • param["iterations"] (int) – Fitting iteration number.

  • param["dZ"] (int) – Axial illumination slice length.

  • param["useZcorr"] (bool) – Whether to use Z correction.

  • param["a"] (float, optional) – Zcorr constant a if Zcorr is used.

  • param["b"] (float, optional) – Zcorr constant b if Zcorr is used.

  • param["init"] (list of float, optional) – Initial values of fit parameters for [D_free, D_bound, F_bound, sigma(optional)].

  • param["CDF"] (bool) – Whether to use CDF.

Returns:

Fit parameters

Return type:

pandas.DataFrame

class FitJumpLenDist3comp(info_path=None)[source]

Bases: Table

Fit jump length distribution to three-states model using fastspt.

Wrapping class of fit_jump_length_distribution.

Parameters:
  • reqs[0] (JumpLenDist) – Jump length distribution Table. Required param; length_unit, interval, CDF.

  • param["lower_bound"] (list of float) – Lower bound of fit parameters. The list should be [D_fast, D_med, D_bound, F_bound, F_fast] for three-states.

  • param["upper_bound"] (list of float) – Upper bound of fit parameters. The list should be [D_fast, D_med, D_bound, F_bound, F_fast] for three-states.

  • param["LocError"] (float or list of float) – Explicit localization error if you do not want to fit it. Otherwise [lower bound, upper bound] of the LocError value for fitting.

  • param["iterations"] (int) – Fitting iteration number.

  • param["dZ"] (int) – Axial illumination slice length.

  • param["useZcorr"] (bool) – Whether to use Z correction.

  • param["a"] (float, optional) – Zcorr constant a if Zcorr is used.

  • param["b"] (float, optional) – Zcorr constant b if Zcorr is used.

  • param["init"] (list of float, optional) – Initial values of fit parameters for [D_fast, D_med, D_bound, F_bound, sigma(optional)].

  • param["split_depth"] (int) – File split depth number.

Returns:

Fitting result of jump length distribution histogram

Return type:

Table

set_info(param)[source]

Copy params from reqs[0] and add columns.

static process(reqs, param)[source]

Fit jump length distribution to the three-states model by fastspt.

Parameters:
  • reqs[0] (pandas.DataFrame) – Jump length distribution histogram.

  • param["lower_bound"] (list of float) – Lower bound of fit parameters. The list should be [D_fast, D_med, D_bound, F_bound, F_fast] for three-states.

  • param["upper_bound"] (list of float) – Upper bound of fit parameters. The list should be [D_fast, D_med, D_bound, F_bound, F_fast] for three-states.

  • param["LocError"] (float or list of float) – Explicit localization error if you do not want to fit it. Otherwise [lower bound, upper bound] of the LocError value for fitting.

  • param["iterations"] (int) – Fitting iteration number.

  • param["dZ"] (int) – Axial illumination slice length.

  • param["useZcorr"] (bool) – Whether to use Z correction or not.

  • param["a"] (float, optional) – Zcorr constant a if Zcorr is used.

  • param["b"] (float, optional) – Zcorr constant b if Zcorr is used.

  • param["CDF"] (bool) – Whether to use CDF.

  • param["init"] (list of float, optional) – Initial values of fit parameters for [D_fast, D_med, D_bound, F_bound, sigma(optional)].

Returns:

Fit parameters

Return type:

pandas.DataFrame

from_hist_df(df)[source]

Convert pandas.DataFrame to jump length distribution.

Parameters:

df (pandas.DataFrame) – Table of jump length distribution.

Returns:

Histograms for fitting (HistVecJumps, JumpProb, HistVecJumpsCDF, JumpProbCDF)

Return type:

tuple

class ModelJumpLenDist(info_path=None)[source]

Bases: Table

Create model curve of jump length distribution from fit parameters.

Wrapping class of generate_jump_length_distribution.

Parameters:
  • reqs[0] (JumpLenDist) – Histogram of jump length distribution. Required params; length_unit.

  • reqs[1] (FitJumpLenDist2comp or FitJumpLenDist3comp) – Fitting parameters of two or three-states model.

  • param["show_pdf"] (bool) – Whether to use the PDF model.

  • param["split_depth"] (int) – File split depth number.

Returns:

Jump length distribution histogram model

Return type:

Table

set_info(param)[source]

Copy params from reqs[0] and reqs[1] then add columns.

static process(reqs, param)[source]

Create model curve of jump length distribution from fit params.

Parameters:
  • reqs[0] (JumpLenDist) – Histogram of jump length distribution. Required params; length_unit.

  • reqs[1] (FitJumpLenDist2comp or FitJumpLenDist3comp) – Fitting parameters of two or three-states model.

  • param["show_pdf"] (bool) – Whether to use the PDF model.

  • param["CDF"] (bool) – Whether to use CDF.

  • param["dZ"] (int) – Axial illumination slice length.

  • param["useZcorr"] (bool) – Whether to use Z correction.

  • param["a"] (float, optional) – Zcorr constant a if Zcorr is used.

  • param["b"] (float, optional) – Zcorr constant b if Zcorr is used.

  • param["interval"] (float) – Time interval.

Returns:

Jump length distribution histogram model

Return type:

pandas.DataFrame

to_model_hist_df(HistVec, y)[source]

Convert jump length distribution histogram model to pandas.DataFrame.

Parameters:
Returns:

Jump length distribution histogram model

Return type:

pandas.DataFrame