Skip to content

Read causality-network dynamics from Parquet via DuckDB#434

Open
jussty wants to merge 3 commits into
CovertLab:masterfrom
jussty:causality-duckdb
Open

Read causality-network dynamics from Parquet via DuckDB#434
jussty wants to merge 3 commits into
CovertLab:masterfrom
jussty:causality-duckdb

Conversation

@jussty

@jussty jussty commented Jul 10, 2026

Copy link
Copy Markdown

What & why

ecoli/analysis/causality_network/read_dynamics.py::convert_dynamics() was a stub:

# TODO: Convert to use DuckDB
raise NotImplementedError("Still need to convert to use DuckDB!")

so buildCausalityNetwork.py could not produce a seriesOut.zip from current vEcoli (Parquet) output. This ports the dynamics reader to the Parquet/DuckDB backend.

Split into two commits so the second is easy to drop:

  1. Core port — the DuckDB dynamics reader + vEcoli-layout CLI options.
  2. Optional downsampling (--max_timepoints) — separable; safe to leave out if you'd rather always read full resolution.

Commit 1 — core port

read_dynamics.py

  • Read the required listener columns + bulk from the Parquet history dataset in one time-ordered pass via dataset_sql(); convert list columns with ndlist_to_ndarray(); build the nested timeseries dict the existing node readers expect.
  • Replace the old config["state"][...]["_properties"]["metadata"] lookups (bulk-molecule ids, unprocessed-RNA ids) with field_metadata(conn, config_sql, ...).
  • Keep the existing reshaping + seriesOut.zip writer unchanged.
  • Remove array_timeseries() and its get_value_from_path import (only used by the removed DB path).

buildCausalityNetwork.py

  • New CLI options for the vEcoli layout: --sim_data_path, --out_dir, --id (experiment id), --seriesout — replacing the hardcoded wcEcoli-era out/kb/simData.cPickle / out/seriesOut.

Commit 2 — optional downsampling

  • Adds --max_timepoints (and a max_timepoints arg to convert_dynamics) to evenly downsample the dynamics read. Some listeners are 2-D per timestep (e.g. TF binding is cistrons × TFs), so full-resolution arrays for a multi-thousand-step run can be large; this keeps memory bounded on constrained machines. Kept as a separate commit so it can be dropped independently.

Testing

Ran a single-generation simulation, then:

python ecoli/analysis/causality_network/buildCausalityNetwork.py \
  --sim_data_path OUT/EXP/parca/kb/simData.cPickle \
  --out_dir OUT --id EXP --seriesout OUT/EXP/causality

Produces a valid seriesOut.zip (nodes.json, edges.json, series.json + per-node series/*.json).

Notes

  • Fixes data generation only; the interactive viewer (CovertLab/causality) is a separate repo.
  • Draft for maintainer review — happy to expose max_timepoints via config or wire this into runscripts/analysis.py if you'd prefer.

jussty and others added 2 commits July 10, 2026 23:21
convert_dynamics() was a NotImplementedError stub (TODO to port off the old in-database emitter). Read the required listener columns from the Parquet history via DuckDB (dataset_sql / field_metadata / ndlist_to_ndarray), build the timeseries the node readers expect, and keep the existing reshaping + seriesOut.zip writer. Generalize buildCausalityNetwork.py to the vEcoli output layout via --sim_data_path / --out_dir / --id / --seriesout instead of hardcoded wcEcoli-era paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add --max_timepoints to buildCausalityNetwork.py (and a max_timepoints arg to convert_dynamics) to evenly downsample the dynamics read. Some listeners are 2-D per timestep (e.g. TF binding is cistrons x TFs), so full-resolution arrays for a multi-thousand-step simulation can be large; downsampling keeps memory bounded on constrained machines. Separable from the core port and safe to drop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jussty jussty force-pushed the causality-duckdb branch from 0476147 to ea58e69 Compare July 10, 2026 21:22
@jussty jussty marked this pull request as ready for review July 10, 2026 22:35
A Causality network is per-cell, but convert_dynamics read the whole experiment's history (fine for a single-cell run, wrong for multi-cell / multi-generation runs where the time-ordered read interleaves cells). Add --variant / --lineage_seed / --generation / --agent_id filters (default: the founder cell) applied to the history and configuration queries. Separable follow-up to the port.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant