diffsvg.pp.BinnedData#
- class diffsvg.pp.BinnedData(genes, Y, intercept_initvals, anchor, condition, condition_categories, n_bsplines, degree, n_bins, B, B_masked, condition_fit, bin_centers, bin_assignment, B_pred, B_pred_masked_0, B_pred_masked_1, condition_pred_0, condition_pred_1, design_matrix='design_matrix', layer=None, n_obs=None, n_obs_grid=None, ss_within=None, sample=None, sample_labels=None, sample_index=None)#
Output of
bin_obs, consumed bydiffsvg.tl.setup_model.Everything a per-gene GAM needs that does not depend on the gene, plus the binned targets
Y.- Variables:
- genes
list Gene order matching
Y/intercept_initvals.- Y
dict Per-gene binned expression.
- intercept_initvals
dict Per-gene initial value of
intercept(mean binned expression atanchor == 0).- condition anchor,
Columns of the design matrix the data was binned on.
conditionisNonewhen binned without one; every condition-dependent field is thenNonetoo.- condition_categories
dict|None {"0": <label>, "1": <label>}, howconditionwas encoded (string keys for h5ad).- n_bins n_bsplines, degree,
Binning/basis hyperparameters.
- condition_fit B, B_masked,
Spline design matrices and encoded condition of the fitted rows.
- bin_centers
ndarray Grid (
n_bins+ 1 points on[0, 1]), also the prediction grid.- bin_assignment
ndarray Per cell, the index of its nearest bin center,
-1without an anchor value.- layer design_matrix,
Where the unbinned data lives, for
use_binned=False.- condition_pred_1 B_pred, B_pred_masked_0, B_pred_masked_1, condition_pred_0,
Design matrices for the prediction grid.
- sample_index sample, sample_labels,
Only when binned with
sample: the column, the samples that have rows, and per row its sample’s index. Rows are then one per (sample, bin).- n_obs
ndarray|None Cells per row. The fitters weight rows by it.
- ss_within n_obs_grid,
Only for contiguous bins (
window_radius=None): cells per grid point (n_categories x (n_bins + 1)) and per gene the within-bin sum of squares, so a binned fit matches a fit on the cells.
- genes
Attributes table#
Whether this was binned with a
condition, i.e. whether the two-condition models can be fit.Number of samples that have rows, or
Nonewhen binned withoutsample.Whether the bins are contiguous and record the within-bin spread.
Attributes#
- property has_condition#
Whether this was binned with a
condition, i.e. whether the two-condition models can be fit.
- property n_samples#
Number of samples that have rows, or
Nonewhen binned withoutsample.
- property weighted#
Whether the bins are contiguous and record the within-bin spread.
Then a binned fit carries the same information as a fit on the cells. (Overlapping bins record
n_obstoo, and fits weight rows by it, but their rows share cells.)