API#
Trackcell entry point#
- pyglmGamPoi.fit_offset_model(umi, regressor_data, gene_index, *, method='glmGamPoi_offset', allow_inf_theta=True, apply_shrinkage=True)[source]#
Fit glmGamPoi offset models (sctransform
fit_glmGamPoi_offset).- Parameters:
umi (ndarray | spmatrix) – UMI count matrix, genes × cells (CSR sparse or dense).
regressor_data (DataFrame) – Cell-level covariates, one row per cell. Must contain
log_umiin log10 scale, indexed by cell barcodes in the same order as umi columns.gene_index (Index) – Gene identifiers, length
umi.shape[0].method (str) – Must be
"glmGamPoi_offset".allow_inf_theta (bool) – When False, cap theta at
mean(mu)/1e-4(Seurat default).apply_shrinkage (bool) – When True (default), apply
loc_median_fitdispersion trend and refit intercepts (Rglm_gp(overdispersion_shrinkage=TRUE)).
- Return type:
DataFrame with columns
theta,Intercept,log_umi.
Low-level fitting#
- pyglmGamPoi.fit_glmGamPoi_offset(umi, log10_umi, *, gene_names=None, allow_inf_theta=True, apply_shrinkage=True)[source]#
Fit glmGamPoi offset models (low-level API).
For trackcell integration, prefer
pyglmGamPoi.fit_offset_model()which acceptsregressor_datain the same format as trackcellcell_attr.- Parameters:
umi (ndarray | spmatrix) – UMI count matrix, genes × cells.
log10_umi (ndarray) – Per-cell log10 UMI values (length = n_cells).
gene_names (list[str] | ndarray | None) – Optional gene index labels.
allow_inf_theta (bool) – When False, cap theta at mean(mu)/1e-4.
apply_shrinkage (bool) – When True (default, R
glm_gpdefault), apply cross-gene dispersion trend vialoc_median_fitand refit intercepts.
- Return type:
DataFrame with columns
theta,Intercept,log_umi.
Shrinkage utilities#
- pyglmGamPoi.loc_median_fit(x, y, *, fraction=0.1, npoints=None, weighted=True, ignore_zeros=False)[source]#
Local median fit (glmGamPoi::loc_median_fit).
Used to estimate dispersion trend across gene means.
- Parameters:
x (ndarray)
y (ndarray)
fraction (float)
npoints (int | None)
weighted (bool)
ignore_zeros (bool)
- Return type:
ndarray
- pyglmGamPoi.overdispersion_shrinkage(disp_est, gene_means, df, *, disp_trend=True, ql_disp_trend=None, npoints=None)[source]#
Shrink overdispersion estimates (glmGamPoi::overdispersion_shrinkage).
glm_gpusesdispersion_trend(local median of raw MLE) for the second beta fit pass;ql_disp_shrunkenis returned for downstream DE workflows.- Parameters:
disp_est (ndarray)
gene_means (ndarray)
df (float | ndarray)
disp_trend (bool | ndarray | None)
ql_disp_trend (bool | None)
npoints (int | None)
- Return type:
OverdispersionShrinkageResult