cellrank.ul.models.GAM

class cellrank.ul.models.GAM(adata, n_knots=6, spline_order=3, distribution='gamma', link='log', max_iter=2000, expectile=None, grid=None, spline_kwargs=mappingproxy({}), **kwargs)[source]

Fit Generalized Additive Models (GAMs) using pygam.

Parameters
  • adata (anndata.AnnData) – Annotated data object.

  • n_knots (Optional[int]) – Number of knots.

  • spline_order (int) – Order of the splines, i.e. 3 for cubic splines.

  • distribution (str) – Name of the distribution. Available distributions can be found here.

  • link (str) – Name of the link function. Available link functions can be found here.

  • max_iter (int) – Maximum number of iterations for optimization.

  • expectile (Optional[float]) – Expectile for pygam.pygam.ExpectileGAM. This forces the distribution to be ‘normal’ and link function to ‘identity’. Must be in interval (0, 1).

  • grid (Union[str, Mapping, None]) – Whether to perform a grid search. Keys correspond to a parameter names and values to range to be searched. If ‘default’, use the default grid. If None, don’t perform a grid search.

  • spline_kwargs (Mapping) – Keyword arguments for pygam.s.

  • **kwargs – Keyword arguments for pygam.pygam.GAM.

Attributes

adata

Annotated data object.

conf_int

Array of shape (n_samples, 2) containing the lower and upper bounds of the confidence interval.

model

The underlying model.

prepared

Whether the model is prepared for fitting.

w

Filtered weights of shape (n_filtered_cells,) used for fitting.

w_all

Unfiltered weights of shape (n_cells,).

x

Filtered independent variables of shape (n_filtered_cells, 1) used for fitting.

x_all

Unfiltered independent variables of shape (n_cells, 1).

x_hat

Filtered independent variables used when calculating default confidence interval, usually same as x.

x_test

Independent variables of shape (n_samples, 1) used for prediction.

y

Filtered dependent variables of shape (n_filtered_cells, 1) used for fitting.

y_all

Unfiltered dependent variables of shape (n_cells, 1).

y_hat

Filtered dependent variables used when calculating default confidence interval, usually same as y.

y_test

Prediction values of shape (n_samples,) for x_test.

Methods

confidence_interval([x_test])

Calculate the confidence interval.

copy()

Return a copy of self.

default_confidence_interval([x_test])

Calculate the confidence interval, if the underlying model has no method for it.

fit([x, y, w])

Fit the model.

plot([figsize, same_plot, hide_cells, perc, …])

Plot the smoothed gene expression.

predict([x_test, key_added])

Run the prediction.

prepare(gene, lineage[, backward, …])

Prepare the model to be ready for fitting.

read(fname)

Deserialize self from a file.

write(fname[, ext])

Serialize self to a file.