analysis

Analysis and plotting functions

This modules contains functions for trajectory analysis and plotting.

analysis.calculate_fold_180_0(angle_list)

Calculates the fold anisotropy for a given list of angles. ref doi:10.1038/s41589-019-0422-3

Parameters:

angle_list (dict) – Numpy array containing the calculated angles for a given tracklet group.

Returns:

(measure fold anisopropy, total number of 180 +/-30° angles, total number of 0 +/-30° angles)

Return type:

(float, int, int)

analysis.compute_all_msd(tracklet_lists, parms)

Computes the MSD for each given track.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

Returns:

Dictionary containing lists of measured motion parameters for each track with keys: alpha, diffusion and track_id.

Return type:

dict

analysis.compute_angles(tracklet_lists, parms, dtime=1)

Computes the angles for each tracklet state.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

  • dtime (int) – Time interval between two data points [Default: 1]

Returns:

Dictionary of numpy arrays for each tracklet group containing the calculated angles.

Return type:

dict

analysis.compute_displ(tracklet_lists, parms, dtime=1)

Computes the displacements for each tracklet state.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

  • dtime (int) – Time interval between two data points [Default: 1]

Returns:

List of calculated displacements for each tracklet group.

Return type:

list

analysis.compute_msd(track, size, dim=2)

Computes the mean square displacement (MSD) for a given track in order to estimate D and alpha using the formula: log(MSD(dt)) ~ alpha.log(dt) + log(C), with C = 2nD.

Parameters:
  • track (pd.DataFrame) – Dataframe containing a trajectory’s coordinates.

  • size (int) – Number of delta time points to use for the MSD curve fit.

  • dim (int) – Dimentionality of the track [Defaults: 2].

Returns:

(msd values, time axis, measured alpha (slope), measured log_C (intercept), resulting diffusion)

Return type:

(np.array, np.array, float, float, float)

analysis.compute_ptm(track_df, parms)

Computes the probability transition matrix (PTM).

Parameters:
  • track_df (pd.DataFrame) – Dataframe containing all extracted trajectories.

  • parms (dict) – Stored parameters containing global variables and instructions.

Returns:

probabilities to transition between states

Return type:

pd.DataFrame

analysis.compute_vac(tracklet_lists, parms, dtime=1, thr=1000)

Computes the velocity autocorrelation (VAC) curves for each tracklet state.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

  • dtime (int) – Time interval between two data points [Default: 1]

  • thr (int) – Threshold for the vac limiting the number of points calculated [Default: 1000].

Returns:

List of calculated VAC for each tracklet group.

Return type:

list

analysis.convert_diffusion(sigma, parms)

Converts sigma to diffusion value.

Parameters:
  • sigma (float) – Sigma value to convert.

  • parms (dict) – Stored parameters containing global variables and instructions.

Returns:

Diffusion value [um**2/s].

Return type:

float

analysis.convert_sigma(diffusion, parms)

Converts diffusion to sigma value.

Parameters:
  • diffusion (float) – Diffusion value [um**2/s] to convert.

  • parms (dict) – Stored parameters containing global variables and instructions.

Returns:

sigma value.

Return type:

float

analysis.make_tracklet_lists(track_df, parms)

Segments the trajectories into tracklet (based on the state group) and regroup them within the same list.

Parameters:
  • track_df (pd.DataFrame) – Dataframe containing all extracted trajectories.

  • parms (dict) – Stored parameters containing global variables and instructions.

Returns:

List of tracklet groups. Each group consists of a dataframe of tracklets.

Return type:

list

analysis.plot_angles(tracklet_lists, parms, dtime=1)

Plots the angular distribution per tracklet state.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

  • dtime (int) – Time interval between two data points [Default: 1]

analysis.plot_displ(tracklet_lists, parms, dtime=1)

Plots the distribution of displacements per tracklet state.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

  • dtime (int) – Time interval between two data points [Default: 1]

analysis.plot_proportion(tracklet_lists, parms)

Plots the proportion of tracklets in each diffusive state as a pie chart.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

analysis.plot_scatter_alpha_diffusion(motion_parms, parms)

Makes a scatterplot of the alpha and diffusion distributions.

Parameters:
  • motion_parms (dict) – Dictionary containing lists of measured motion parameters for each track with keys: alpha, diffusion and track_id.

  • parms (dict) – Stored parameters containing global variables and instructions.

analysis.plot_vac(tracklet_lists, parms, dtime=1)

Plots the velocity autocorrelation curves per tracklet state.

Parameters:
  • tracklet_lists (list) – List of tracklet groups. Each group consists of a dataframe of tracklets.

  • parms (dict) – Stored parameters containing global variables and instructions.

  • dtime (int) – Time interval between two data points [Default: 1]