patient_slopes

patient_slopes(obj, gene=None, index=None, niche=None)

Each patient’s niche slopes in long form (R patientSlopes).

The slopes engine estimates every patient’s own niche slopes (a one-step negative binomial estimate from the shared fit); this returns them with their variances, e.g. to plot how a gene’s slope varies between patients and conditions.

Parameters

Name Type Description Default
obj SpiDEFit or SpiDEResults A fit (or the results of one) from the slopes engine. required
gene str or sequence of str Keep only these genes. None
index str or sequence of str Keep only these index cell types. None
niche str or sequence of str Keep only these niche cell types. None

Returns

Name Type Description
pandas.DataFrame gene, index, niche, patient, slope, var_spatial (the within-patient spatial sandwich variance), var_model, ncells plus the patient-level columns recorded by fit_spide; ordered by index, gene, niche, patient.

See Also

patient_intercepts : The patients’ intercepts. fit_spide : Estimates the slopes.

Examples

from spidepy import build_niches, fit_spide, patient_slopes
from spidepy.datasets import toy_spide
fit = fit_spide(build_niches(toy_spide(), sigma=30), condition="condition", verbose=False)
sl = patient_slopes(fit, gene="G1", index="A")
sl.shape
(32, 11)
sl.columns.tolist()[:5]
['gene', 'index', 'niche', 'patient', 'slope']