patient_intercepts

patient_intercepts(obj, gene=None, index=None)

Each patient’s intercept per gene and index type, in long form (R patientIntercepts).

Every index type’s shared fit has an intercept per patient and gene: the patient’s expression level of the gene in that type, at zero niche density and a reference depth (the index type’s mean log library size under depth = "loglib" or "nonlinear", each patient’s own mean under "spatial_spline"). The intercepts absorb every difference between patients, which is why the niche slopes are within-patient slopes.

Parameters

Name Type Description Default
obj SpiDEFit or SpiDEResults A fit, or the results of one. 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

Returns

Name Type Description
pandas.DataFrame gene, index, patient, intercept (log scale), ncells (the patient’s cells of the index type) plus the patient-level columns recorded by fit_spide; ordered by index, gene, patient.

See Also

patient_slopes : The patients’ niche slopes.

Examples

from spidepy import build_niches, fit_spide, patient_intercepts
from spidepy.datasets import toy_spide
fit = fit_spide(build_niches(toy_spide(), sigma=30), condition="condition", verbose=False)
ic = patient_intercepts(fit, gene="G1")
ic.shape
(48, 8)
ic.columns.tolist()[:4]
['gene', 'index', 'patient', 'intercept']