bio-expression-matrix-sparse-handling
Work with sparse matrices for memory-efficient storage of count data. Use when dealing with single-cell data or large bulk RNA-seq datasets where most values are zero.
npx skills add BioTender-max/awesome-bio-agent-skills --skill sparse-handling --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
## Version Compatibility Reference examples tested with: numpy 1.26+, pandas 2.2+ Before using code patterns, verify installed versions match. If versions differ: - Python: `pip show <package>` then `help(module.function)` to check signatures If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying. # Sparse Matrix Handling **"Convert counts to sparse matrix"** → Store zero-heavy expression data (especially single-cell) in memory-efficient sparse format. - Python: `scipy.sparse.csr_matrix(dense_array)`, `anndata.X` stores sparse by default - Python: `scipy.io.mmread('matrix.mtx')` for Market Matrix format (10x Genomics) ## Check Sparsity ```python import numpy as np # Calculate sparsity (proportion of zeros) def check_sparsity(counts): zeros = (counts == 0).sum().sum() total = counts.size sparsity = zeros / total print(f'Sparsity: {sparsity:.1%} ({zeros:,} / {total:,} zeros)') return sparsity # Rule of thumb: use sparse if >50% zeros ``` ## Convert Dense to Sparse ```python import scipy.sparse as sp import pandas as pd # From pandas DataFrame dense_df = pd.read_csv('counts.csv', ind
- Version Compatibility
- Check Sparsity
- Convert Dense to Sparse
- Convert Sparse to Dense
- Memory Comparison
- Save/Load Sparse Matrices
- AnnData with Sparse Matrices
- Sparse Operations
- Subsetting Sparse Matrices
- Normalization on Sparse
- 10X Matrix Format
- Backed Mode for Large Datasets
- Sparsity Changes After Transformation
- Sparse-Dense Arithmetic Gotcha
What does the bio-expression-matrix-sparse-handling skill do?
Work with sparse matrices for memory-efficient storage of count data. Use when dealing with single-cell data or large bulk RNA-seq datasets where most values are zero.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill sparse-handling --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
