Skip to content

v0.2.2

Choose a tag to compare

@psychemistz psychemistz released this 08 Feb 21:59
· 97 commits to main since this release

Bug Fix

  • Fix ImportError when using batch_size: secact_activity_inference() and
    secact_activity_inference_st() crashed with ImportError: cannot import name 'ridge_batch' from 'secactpy.ridge' when batch_size was set. The import was pointing to the wrong module.

New Features

Sparse mode (sparse_mode=True)

Opt-in parameter for memory-efficient processing of sparse Y matrices. Avoids densifying Y during matrix
multiplication by using the identity (Y.T @ T.T).T == T @ Y, with column z-scoring applied as lightweight
corrections on the small output matrix.

Supported in ridge(), ridge_batch(), and all high-level inference functions.

# scRNA-seq: Y stays sparse end-to-end
result = secact_activity_inference_scrnaseq(
    adata, cell_type_col="cell_type",
    is_single_cell_level=True,
    batch_size=5000,
    sparse_mode=True
)

# Spatial transcriptomics
result = secact_activity_inference_st(
    adata, batch_size=5000, sparse_mode=True
)
┌───────────────────────┬──────────────┬──────────────────┐
│                       │   Default    │ sparse_mode=True │
├───────────────────────┼──────────────┼──────────────────┤
│ Memory                │ Full dense Y │ Y stays sparse   │
├───────────────────────┼──────────────┼──────────────────┤
│ Speed (<5% density)   │ Baseline     │ ~1.8x faster     │
├───────────────────────┼──────────────┼──────────────────┤
│ Speed (5–10% density) │ Baseline     │ ~25% slower      │
├───────────────────────┼──────────────┼──────────────────┤
│ Results               │ Identical    │ Identical        │
└───────────────────────┴──────────────┴──────────────────┘
In-flight row-mean centering (row_center=True)

New parameter in ridge_batch() for applying row-mean centering without densifying Y. Computes row-centered column
statistics analytically from sparse Y.