graphvelo.gam.fit_velo_peak
- graphvelo.gam.fit_velo_peak(adata, genes, tkey, layer='Ms', log_norm=True, max_iter=2000, **kwargs)[source]
Identify the peak velocity (i.e. maximum predicted value) for each gene using GAM.
For each gene in genes, a GAM is fit using the independent variable stored in adata.obs[tkey] and the expression values from adata[:, gene].layers[layer]. Then the time (or phase) corresponding to the maximum predicted expression is found by minimizing the negative of the GAM prediction.
- Parameters:
adata (anndata.AnnData): AnnData object containing the data. genes (str or list of str): One or more gene names. tkey (str): Key in adata.obs for the independent variable (e.g., pseudotime). layer (str): Name of the layer to use for expression values (default ‘Ms’). log_norm (bool): Whether to apply log1p normalization to the magnitude. max_iter (int): Maximum iterations for GAM fitting. **kwargs: Additional keyword arguments for GAM (e.g., n_splines, spline_order).
- Returns:
- pd.DataFrame: A DataFrame with gene names as the index and two columns:
‘phase’ for the peak time (or phase) and ‘magnitude’ for the predicted expression at the peak (optionally log-normalized).