pythonforbio.
[WASM idle]
Core Concepts03/06

Ecosystem Map

Starting sandbox…
Beginnerlesson

Ecosystem Map

How the five libraries relate, and what sits above and below them.

The layer diagram

                 ┌─────────────────────────────────────┐
   Domain        │  biocommons/hgvs      Biopython     │
                 └──────────┬──────────────────┬───────┘
                            │                  │
                 ┌──────────┴──────────────────┴───────┐
   Presentation  │      seaborn  →  Matplotlib         │
                 └──────────────────┬──────────────────┘
                                    │
                 ┌──────────────────┴──────────────────┐
   Tabular       │              pandas                 │
                 └──────────────────┬──────────────────┘
                                    │
                 ┌──────────────────┴──────────────────┐
   Numeric       │               NumPy                 │
                 └─────────────────────────────────────┘

The arrows are real dependencies, not metaphor. Pandas stores its columns as NumPy arrays (or PyArrow arrays since 3.0), Seaborn is a layer that emits Matplotlib Artists, and Biopython returns NumPy arrays from several of its modules (Bio.Align, Bio.PDB coordinates, Bio.motifs PWMs).

biocommons hgvs is the odd one out: it depends on none of the others. It is a parsing-and-coordinate-mathematics library with a database behind it, and you glue it to pandas yourself.

What each library is actually for

Library The one-sentence job The thing it is not
NumPy Homogeneous n-dimensional numeric arrays with fast elementwise math Not for labelled or mixed-type data
Pandas Heterogeneous tables with labelled rows and columns Not for >memory data, not for n-d arrays
Matplotlib Precise, low-level control over every mark on a figure Not fast to write for common statistical plots
Seaborn Statistical plots from tidy dataframes in one line Not for arbitrary custom layouts
Biopython Parsing bio file formats and manipulating sequences/structures Not an aligner, not a variant caller; it wraps or parses those
biocommons hgvs Correct parsing, normalization and projection of sequence variants Not a variant annotator; it does not tell you pathogenicity

Where the boundaries actually get blurry

pandas vs NumPy. If your data is a homogeneous matrix with meaningful row/column positions (an expression matrix, a distance matrix), NumPy is the right tool and pandas adds overhead. If you need labels, mixed dtypes, or joins, use pandas. Many pipelines carry a pandas frame for metadata alongside a NumPy array for the numbers — that is exactly what AnnData/scanpy formalises.

Matplotlib vs seaborn. Not a choice. seaborn is matplotlib. You use seaborn to get 90% of a plot in one call, then reach through to the underlying Axes for the last 10%. See Figure-level vs Axes-level.

Biopython vs hgvs. Biopython handles sequence content; hgvs handles variant nomenclature and coordinates. If you need the reference base at a position, that is SeqRepo (through hgvs) or a FASTA index (through Biopython/pysam). If you need to know whether NM_000546.6:c.215C>G and NC_000017.11:g.7676154G>C are the same event, that is hgvs and only hgvs.

The neighbours you will meet next

Worth knowing these exist, even though this vault does not cover them:

  • pysam — the actual workhorse for BAM/CRAM/VCF/tabix. Biopython does not read BAM. For anything alignment-file-shaped, reach for pysam.
  • scikit-bio, pyranges — interval arithmetic and ecology/diversity stats
  • scanpy / AnnData — single-cell, and the canonical example of "pandas for metadata + NumPy/sparse for the matrix"
  • scipy — statistics (scipy.stats), clustering, sparse matrices. Every real analysis reaches for it.
  • statsmodels — regression and multiple-testing correction (multipletests for FDR)
  • polars / DuckDB — where you go when pandas runs out of memory
  • cyvcf2 — fast VCF parsing when pandas-based parsing is too slow

See also

Versions and Compatibility · Learning Path · Tidy Data · Map of Content

scratch

No output yet — run the code to populate this drawer.