Skip to content

Add quick-start and full-analysis notebooks, fix fetch_band performance#11

Open
TincaSubic wants to merge 9 commits into
mainfrom
quick-start-example
Open

Add quick-start and full-analysis notebooks, fix fetch_band performance#11
TincaSubic wants to merge 9 commits into
mainfrom
quick-start-example

Conversation

@TincaSubic

Copy link
Copy Markdown
Collaborator

Description:

Summary

  • docs/quick_start.ipynb / docs/quick_start.py: self-contained example that fits dLEM to a bundled H1-hESC Hi-C excerpt (chr10:19–26 Mb) and reproduces the reference locus
    split contact map (chr10:20.5–22.5 Mb). Runnable headlessly via python docs/quick_start.py or jupyter execute docs/quick_start.ipynb.
  • docs/full_analysis.ipynb: end-to-end notebook that downloads 4DNFI9GMP2J8 Micro-C (~13 GB) and ENCFF269OPL CTCF ChIP-seq bigWig (~1.7 GB), fits dLEM on full chr10, and
    compares inferred cohesin speed tracks (L/R) to CTCF signal. CTCF binned via pyBigWig type='max', matching Table 2 of the paper.
  • dlem/api.py: fixed ~100× slowdown in fetch_band on single-resolution .cool files — now reads diagonals directly via cooler + np.diagonal instead of routing through
    hictkpy.
  • dlem/__init__.py: GPU availability hint on import.
  • pyproject.toml: added seaborn dependency; [cuda] optional extra for jax[cuda12].
  • README.md: GPU install instructions and quick-start usage.
  • .gitignore: exclude large downloaded data files (*.mcool, *.bigWig, *.bed.gz) from docs/data/.

Test plan

  • pip install -e . in a clean environment — all deps resolve, import dlem succeeds
  • python docs/quick_start.py runs to completion, produces docs/quick_start_patch.png
  • jupyter execute docs/quick_start.ipynb produces the same PNG
  • full_analysis.ipynb runs end-to-end after data downloads; overview and locus figures save correctly

🤖 Generated with Claude Code

TincaSubic and others added 9 commits May 21, 2026 16:22
- docs/quick_start.ipynb + docs/quick_start.py: end-to-end dLEM example
  on H1-hESC Hi-C (chr10:20.5–22.5 Mb, 10 kb). Trains with correct
  settings (multinomial loss, band rows 1–169, slowdown=0.025) and
  produces a split contact map with L/R cohesin speed tracks.
- docs/data/example_chr10.cool: minimal Hi-C file (308 KB) extracted
  from 4DNFI9GMP2J8, chromosome stored as ref_region with coords
  shifted to 0; docs/data/create_example_data.py regenerates it.
- .gitignore: exempt docs/data/ from the data/ exclusion rule.
- dlem/api.py: TODO comment on early-stopping verbose message — it
  reads "no MSE improvement" even when loss_type='multinomial'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cleaned up corruption from accidental re-run: removed duplicate
section-3 and section-5 markdown headers, restored train_dlem code
cell, fixed _log_eo/combined cell type from markdown back to code,
and added the missing section-4 heading.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…adata

- pyproject.toml: add seaborn>=0.13.0 as runtime dependency (used by
  quick_start for the vlag colormap); remove pytest from runtime deps
  (test-only tool, already in dev dependency-group)
- docs/quick_start.ipynb: fix kernelspec from stale 'dlem' to 'python3'
  so jupyter execute works in any env; strip invalid execution_count/
  outputs from markdown cells; add required execution_count/outputs to
  code cells that were missing them after the corruption repair

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- docs/full_analysis.ipynb: downloads H1-hESC Hi-C (4DNFI9GMP2J8, ~13 GB)
  and CTCF ChIP-seq (ENCFF269OPL) from public sources, fits dLEM on full
  chr10 at 10 kb, and produces three figures:
    full_analysis_chr10.png  — chromosome-wide L/R/CTCF/barrier tracks
    full_analysis_locus.png  — split contact map at chr10:20.5–22.5 Mb
                               with CTCF peak marks below the map
    full_analysis_scatter.png — cohesin activity vs CTCF signal scatter
  Downloads are skipped on re-run if files already exist.
- .gitignore: exclude docs/data/*.mcool and docs/data/*.bed.gz
  (too large to commit; generated by the notebook)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pip install dlem-jax installs CPU-only jax by default (works everywhere).
pip install "dlem-jax[cuda]" adds jax[cuda12] for NVIDIA GPU support.
README now shows both install commands clearly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- dlem/__init__.py: on import, detect NVIDIA GPU + CPU jax and print
  an actionable message with the exact reinstall command; silent when
  GPU is already in use or no GPU is present
- docs/quick_start.py + quick_start.ipynb: print "Loading and
  processing Hi-C data..." before fetch_band so users know the pause
  is expected (adaptive coarse-graining is slow on CPU)
- docs/full_analysis.ipynb: same progress message, with extra note
  that full chr10 may take a few minutes on CPU

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switch matrix fetching from hictkpy to cooler (already a project dep):
- Pre-create bal_mat/raw_mat handles outside the loop (one cooler.matrix()
  call instead of two hictkpy fetches per block iteration)
- Replace jnp.diag(sub, k) with np.diagonal(sub, k) to eliminate JAX
  dispatch overhead inside the width-iteration inner loop

Result: example_chr10.cool fetch drops from ~90s to ~1s (bit-identical
output, max abs diff = 0). mcool and full-chr10 paths also improve.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Switch CTCF data source from narrowPeak to bigWig (ENCFF269OPL) via
  pyBigWig one-call binning (type='max', matches paper Table 2)
- Enable %matplotlib inline for interactive figure display
- Remove redundant Hi-C progress print (fetch_band is fast after fix)
- Fix ctcf_signal .values AttributeError (numpy array, not pandas Series)
- Fix CTCF panel: fill_between continuous signal, height_ratios=[1,5,1]
- Add docs/data/*.bigWig to .gitignore
- Correct notebook overview markdown: bigWig format, ~1.7 GB size

Co-Authored-By: Claude Sonnet 4.6 <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