graphvelo.gam.fit_response
- graphvelo.gam.fit_response(adata, pairs_mat, xkey='M_sc', ykey='jacobian', norm=True, log=False, grid_num=200, **kwargs)[source]
Fit response curves for gene pairs and generate a grid of GAM predictions.
- For each gene pair provided in pairs_mat, this function:
Retrieves the response values (x) from the specified layer (xkey) for the source gene.
Computes the Jacobian (y) for the target gene using dynamo’s get_jacobian function.
Filters out invalid data points (non-finite or zero sums).
Optionally applies log transformation and normalization.
Fits a Generalized Additive Model (GAM) to predict the response over a grid.
Stores the predicted response curve into a grid (data).
- The function returns an AnnData object where:
The .X matrix contains the grid data for each gene pair.
The .obs_names are set to the target gene names from each pair.