Module: utilities

cytomulate.utilities.spline_function(x, y, smoothing_factor=0.5)[source]

Generate a smoothing spline function

This functions generates a spline, which is mainly used for generating temporal effects.

Parameters:
  • x (np.ndarray) – An array of x values

  • y (np.ndarray) – An array of y values

  • smoothing_factor (float) – The smoothing factor used in spline fitting

Returns:

spline_values – A spline function that can be evaluated at point t

Return type:

Callable

cytomulate.utilities.polynomial_function(coefficients, end_value)[source]

Generate a polynomial on [0,1] This can be used to generate temporal effect and generate differentiation path

Parameters:
  • coefficients (list or np.ndarray) – An array of the polynomial coefficients. The resulting polynomial will almost surely not have the same coefficients. They are used to specify the rough “shape” of the polynomial

  • end_value (float) – The desired end value

Returns:

polynomial_values – A polynomial function that can be evaluated at point t

Return type:

Callable

cytomulate.utilities.brownian_bridge_function(end_value, N=5, lb=0, ub=0.1)[source]

Generate a random function that starts at 0 and ends at end_value This can be used to generate temporal effect and generate differentiation path

Parameters:
  • end_value (float) – The desired end value

  • N (int) – Number of steps when simulating a brownian bridge

  • lb (float) – The lower bound of the variance scaling factor

  • ub (float) – The upper bound of the variance scaling factor

Returns:

spline_values – A function that can be evaluated at time t

Return type:

Callable

cytomulate.utilities.trajectories(end_values=None, coefficients=None, x=None, y=None, **kwargs)[source]

Vectorize the spline function or the polynomial function or the brownian bridge function

Parameters:
  • end_values (list or np.ndarray) – An array of the end values

  • coefficients (list or np.ndarray) – If polynomial is desired, an array of the polynomial coefficients

  • x (np.ndarray) – If spline is sought after, the x values

  • y (np.ndarray) – If spline is sought after, the y values

  • kwargs – Other arguments for the brownian bridge method or the spline function

Returns:

trajectories_functions – A list of functions

Return type:

List[Callable]

cytomulate.utilities.univariate_noise_model(noise_distribution=None, **kwargs)[source]

Generate a noise distribution This is mainly used to generate background noise in the cytof_data object.

Changed in version 0.2.0: The default noise_distribution is changed to uniform. If no user-specified value is provided, a warning is given to inform users of the change.

New in version 0.2.0: Added the half_normal option to the noise_distribution parameter.

Parameters:
  • noise_distribution (str) – Either “normal”, “half_normal”, or “uniform”

  • kwargs – extra parameters needed for numpy.random.normal or numpy.random.uniform

Returns:

model – A RV generator that only takes size as its input

Return type:

Callable

cytomulate.utilities.estimate_noise_model(data, noise_distribution='uniform')[source]

Estimate the noise model from data

New in version 0.2.0.

Parameters:
  • data (np.ndarray) – An array of expression matrix

  • noise_distribution (str, optional) – Either “half_normal” or “uniform”, by default “uniform”

Returns:

A RV generator that only takes size as its input

Return type:

Callable