Tutorials#

Step-by-step Jupyter-notebook-style tutorials covering the gunz-cm processing pipeline: load → convert → visualize → random downsample.

The tutorials live as Jupyter notebooks in notebooks/tutorials/ at the root of the gunz-cm repository. The pages below are generated from those notebooks at build time (via nbconvert --to markdown --execute) so the rendered HTML always shows fresh outputs.

To run the tutorials locally with fresh outputs:

.. code-block:: bash

git clone https://github.com/sXperfect/gunz-cm.git cd gunz-cm mamba activate gunz_cm jupyter lab notebooks/

What you need#

  1. Python 3.11+ (gunz-cm does not support earlier versions)

  2. gunz-cm installed in a virtual environment — see :doc:installation for setup instructions

  3. The 18 tutorial notebooks in notebooks/tutorials/ (cloned from the repository)

  4. (Optional) Sample data — every tutorial generates synthetic data inline, so you can run them without real Hi-C files

Core Operations (Getting Started)#

Read data from diverse formats, convert between formats, and inspect/visualize Hi-C contact maps.

Preprocessing & Normalization#

Clean, balance, and downsample contact matrices for biologically accurate analyses.

3D Genome Reconstruction & Spatial Metrics#

Reconstruct 3D chromosome models, assess reconstruction quality, and inspect standard datasets.

Advanced GZCM Format & Deep Learning#

Dive into custom codecs, adaptive picker metrics, and high-concurrency PyTorch training.

Why the tutorials are pre-rendered#

The MyST Notebook ecosystem (myst_parser + myst_nb) has a known collision documented in commit da827f6: both extensions try to register the same config value, and no version combination resolves it. We work around this by:

  1. Executing the tutorials locally with jupyter nbconvert --execute (which captures current cell outputs)

  2. Converting to MyST Markdown via nbconvert --to markdown

  3. Rendering the static .md in Sphinx via the standard myst_parser

This guarantees the tutorials show on the website with the right code and the right outputs, even without myst_nb.

Pre-existing bugs documented in the tutorials#

The tutorials work around the following pre-existing gunz-cm bugs (per the CHANGELOG):

  • get_resolutions raises LoaderError for single-resolution .cool files

  • get_balancing facade has an AttributeError for COOLER format

  • Balancing.VC enum value exists but no vc_normalize function ships

  • scipy.spatial.distance.mdscale was removed in SciPy 1.16 (use sklearn.manifold.MDS instead)

  • GZCM v2: padded to block_size; original_shape not stored

  • GZCM v3 + CMC: upper-triangular only (lossy in lower)

  • NPY loader returns raw ndarray (not ContactMatrix)

  • CSV loader expects base-pair coordinates (not bin IDs)

  • display_contact_map and display_compartment_map are dead stubs in __init__.py

Where to go next#

  • :doc:installation — full installation guide

  • :doc:quickstart — minimal 5-minute working example

  • :doc:concepts — mental model behind the library

  • :doc:modules — full API reference