calculate_mu(gmean, alpha, W, winsor=DEFAULT_WINSOR, backend='cpu', offset=None)
Fitted means exp(gmean + alpha @ W.T + offset) with optional row winsorisation.
Returns a numpy array when backend resolves to the CPU and a torch tensor on the accelerator otherwise (R’s calculateMu).
Examples
import numpy as np
import spanormpy as sn
rng = np.random.default_rng(1)
Y = rng.poisson(5, size=(20, 50)) # counts, genes x cells
W = np.column_stack([np.ones(50), np.linspace(-1, 1, 50)]) # intercept + one covariate
fit = sn.fit_nb(Y, W, verbose=False, backend="cpu")
mu = sn.calculate_mu(fit["gmean"], fit["alpha"], W)
mu.shape # genes x cells