graphvelo.gam.fit_gene_trend

graphvelo.gam.fit_gene_trend(adata, genes, tkey, layer='Ms', max_iter=2000, grid_num=200, **kwargs)[source]

Fit gene expression trends over a given time or pseudotime variable using Generalized Additive Models (GAMs) and return the predictions in an AnnData object.

Parameters:

adataAnnData

An AnnData object containing the expression data in adata.layers and the time/pseudotime information in adata.obs.

genesstr or list of str

Gene name (or list of gene names) for which to fit the trend.

tkeystr

Key in adata.obs that contains the time or pseudotime variable.

layerstr, default ‘Ms’

The layer in adata.layers to extract expression values from.

max_iterint, default 2000

Maximum iterations for fitting the GAM.

grid_numint, default 200

Number of points in the grid over which the trend is predicted.

**kwargsdict

Additional keyword arguments to pass to the GAM fitting routine (e.g., n_splines, spline_order).

Returns:

: gdata : AnnData

An AnnData object where .X is a matrix of shape (number of genes, grid_num) containing the predicted trend for each gene, and the .obs_names are set to the corresponding gene names.