Nested TAD Detection from .mcool Using OnTAD
Overview
This skill performs nested TAD (hierarchical TAD/subTAD) detection from Hi-C data using OnTAD, starting from a .mcool, .cool or .hic file.
Main steps include:
- Refer to the Inputs & Outputs section to verify required files and output structure.
- Inspect the
.mcool file to list available resolutions and alway remember to confirm the chromosome name and analysis resolution with the user.
- Extract a balanced or raw dense Hi-C matrix for a selected chromosome and resolution from the
.mcool file.
- Ensure matrix quality (symmetry, no all-zero rows/columns, reasonable contact decay).
- Run OnTAD to call TADs and nested TAD structures.
- Parse and standardize OnTAD output into BED-like tables and hierarchical annotation files.
When to use this skill
Use this skill when you want to identify TADs and nested sub-TADs from high- or mid-resolution Hi-C data, especially when your contact maps are stored as Cooler multi-resolution files (.mcool) and you need chromosome- and resolution-specific OnTAD calls.
Typical biological questions / use-cases:
- Comparing TAD hierarchy between cell types (e.g., GM12878 vs K562) or conditions (control vs treated).
- Investigating whether inner subTADs are enriched for active regulatory elements, specific histone marks, or gene expression.
- Studying boundary usage, boundary sharing, or hierarchical TAD levels around key loci (e.g., HOX clusters, oncogenes).
- Integrating nested TAD structure with ChIP-seq, ATAC-seq, or WGBS to understand spatial regulatory architecture.
Data quality & replication assumptions:
- Hi-C experiments should have sufficient depth for the target resolution (e.g., ≥5–10 kb typically requires deep sequencing).
- Preferably, use biological replicates per condition and call TADs on either:
- individual replicate matrices (and then merge/consensus), or
- replicate-merged matrices (if justified).
- The
.mcool should be properly normalized or at least QC’d (ICE/balanced weights available if using --balanced).
Inputs & Outputs
Inputs
Required core inputs:
- Hi-C matrix file
- Multi-resolution Cooler file (
.mcool), e.g.:
- Or one-resolution Cooler file (
.cool), e.g.:
- Or Hi-C file (
.hic), e.g.:
- User-supplied parameters (must come from user feedback)
- Chromosome name: e.g.,
chr1, chr2, chrX
- Resolution of interest: e.g.,
10000, 25000, 40000 (in bp)
- Chromosome length: e.g., 133275309
- Software and environment
cooler command-line utilities (or Python cooler module) available in $PATH or environment.
OnTAD installed and callable (e.g., OnTAD or OnTAD_linux command).
python (3.x) and basic scientific Python stack if using Python-based extraction.
Optional entry point:
- Precomputed dense Hi-C matrix (OnTAD-ready)
- Plain text dense square matrix (no header), e.g.
proj_dir/matrices/chr17_25kb_dense.matrix.
- If this is already present, you may skip the
.mcool → dense matrix conversion and jump directly to OnTAD.
Operational rules for missing inputs:
- If
.mcool or .cool or .hic file is missing:
"sample.mcool not available, provide required files or skip and proceed ?"
- If chromosome list not specified:
Ask the user explicitly rather than assuming default.
- If OnTAD executable is not found:
Ask user to install/locate OnTAD before proceeding.
Outputs
Default output directory structure:
${sample}_nested_TAD_detection/
matrices/
${chromosome}_${resolution}_dense.txt
${chromosome}_${resolution}_dense.log
nested_TADs/
${chromosome}_${resolution}_OnTAD.tad
${chromosome}_${resolution}_OnTAD.bed
${chromosome}_${resolution}_OnTAD.log
Allowed Tools
When using this skill, you should restrict yourself to the following MCP tools from server cooler-tools, cooltools-tools, plot-hic-tools, project-init-tools:
mcp__project-init-tools__project_init
mcp__cooler-tools__list_mcool_resolutions
mcp__cooler-tools__harmonize_chrom_names
mcp__cooler-tools__dump_chroms
mcp__cooler-tools__dump_dense_matrix
mcp__OnTAD-tools__run_ontad
Do NOT fall back to:
- raw shell commands (
OnTAD, etc.)
- ad-hoc Python snippets (e.g. importing
cooler, bioframe, matplotlib manually in the reply).
Decision Tree
Step 0 — Gather Required Information from the User
Before calling any tool, ask the user:
Sample name (sample): used as prefix and for the output directory ${sample}_nested_TAD_detection.
Genome assembly (genome): e.g. hg38, mm10, danRer11.
- Never guess or auto-detect.
Hi-C matrix path/URI (mcool_uri):
path/to/sample.mcool::/resolutions/25000 (.mcool file with resolution specified)
- or
.cool file path
- or
.hic file path
Resolution (resolution): default 25000 (100 kb).
- If user does not specify, use
25000 as default.
- Must be the same as the resolution used for
${mcool_uri}
Step 1 — Initialize Project
- Make director for this project:
Call:
mcp__project-init-tools__project_init
with:
sample: the user-provided sample name
task: hic_matrix_qc
The tool will:
- Create
${sample}_nested_TAD_detection directory.
- Return the full path of the
${sample}_nested_TAD_detection directory, which will be used as ${proj_dir}.
- If the user provides a
.hic file, convert it to .mcool file using mcp__HiCExplorer-tools__hic_to_mcool tool:
Call:
mcp__HiCExplorer-tools__hic_to_mcool
with:
input_hic: the user-provided path (e.g. input.hic)
sample: the user-provided sample name
proj_dir: directory to save the view file. In this skill, it is the full path of the ${sample}_nested_TAD_detection directory returned by mcp__project-init-tools__project_init.
The tool will:
- Convert the
.hic file to .mcool file.
- Return the path of the
.mcool file.
If the conversion is successful, update ${mcool_uri} to the path of the .mcool file.
Step 2: List Available Resolutions in the .mcool file & Modify the Chromosome Names if Necessary
- Check the resolutions in
mcool_uri:
Call:
mcp__cooler-tools__list_mcool_resolutions
with:
mcool_path: the user-provided path (e.g. input.mcool) without resolution specified.
The tool will:
- List all resolutions in the .mcool file.
- Return the resolutions as a list.
If the user defined or default ${resolution} is not found in the list, ask the user to specify the resolution again.
Else, use ${resolution} for the following steps.
- Check if the chromosome names in the .mcool file are started with "chr", and if not, modify them to start with "chr":
Call:
mcp__cooler-tools__harmonize_chrom_names
with:
sample: the user-provided sample name
proj_dir: directory to save the expected-cis and eigs-cis files. In this skill, it is the full path of the ${sample}_Compartments_calling directory returned by mcp__project-init-tools__project_init
mcool_uri: cooler URI with resolution specified, e.g. input.mcool::/resolutions/${resolution}
resolution: ${resolution} must be the same as the resolution used for ${mcool_uri} and must be an integer
The tool will:
- Check if the chromosome names in the .mcool file.
- If not, harmonize the chromosome names in the .mcool file.
- If the chromosome names are modified, return the path of the modified .mcool file under
${proj_dir}/ directory
Step 3: Check chromosome length
Call:
mcp__cooler-tools__dump_chroms
with:
mcool_uri: cooler URI with resolution specified, e.g. input.mcool::/resolutions/${resolution}
resolution: ${resolution} must be the same as the resolution used for ${mcool_uri} and must be an integer
The tool will:
- Return the chromosome name and length as a table.
Step 4: Extract dense matrix from .mcool
Call:
mcp__cooler-tools__dump_dense_matrix
with:
sample: the user-provided sample name
proj_dir: directory to save the view file. In this skill, it is the full path of the ${sample}_nested_TAD_detection directory returned by mcp__project-init-tools__project_init.
mcool_uri: cooler URI with resolution specified, e.g. input.mcool::/resolutions/${resolution}
resolution: ${resolution} must be the same as the resolution used for ${mcool_uri} and must be an integer
chrom: the user-provided chromosome name (e.g. chr17)
balanced: whether to use balanced matrix (default: True)
The tool will:
- Extract the dense matrix from the .mcool file.
- Return the path of the dense matrix file.
Step 5: Run OnTAD
Call:
mcp__OnTAD-tools__run_ontad
with:
sample: the user-provided sample name
proj_dir: directory to save the view file. In this skill, it is the full path of the ${sample}_nested_TAD_detection directory returned by mcp__project-init-tools__project_init.
dense_matrix: the path to the dense matrix file (e.g. ${proj_dir}/matrices/chr17_25kb_dense.matrix)
chrom: the user-provided chromosome name (e.g. chr17)
chrom_length: the corresponding chromosome length (e.g. 83257441) returned by mcp__cooler-tools__dump_chroms tool.
resolution: the user-provided resolution (e.g. 25000)
penalty: the penalty parameter for OnTAD (e.g. 0.1)
maxsz: the maximum TAD size (in bins) (e.g. 200)
The tool will:
- Run OnTAD to call TADs and nested TAD structures.
- Return the path of the OnTAD output file (.tad, .bed, .log).
1---2name: nested-tad-detection3description: This skill detects hierarchical (nested) TAD structures from Hi-C contact maps (in .cool or mcool format) using OnTAD, starting from multi-resolution .mcool files. It extracts a user-specified chromosome and resolution, converts the data to a dense matrix, runs OnTAD, and organizes TAD calls and logs for downstream 3D genome analysis.4---56# Nested TAD Detection from .mcool Using OnTAD78## Overview910This skill performs nested TAD (hierarchical TAD/subTAD) detection from Hi-C data using **OnTAD**, starting from a .mcool, .cool or .hic file.1112Main steps include:1314- Refer to the **Inputs & Outputs** section to verify required files and output structure.15- Inspect the `.mcool` file to list available resolutions and alway remember to confirm the chromosome name and analysis resolution with the user.16- Extract a **balanced or raw dense Hi-C matrix** for a selected chromosome and resolution from the `.mcool` file.17- Ensure matrix quality (symmetry, no all-zero rows/columns, reasonable contact decay).18- Run **OnTAD** to call TADs and nested TAD structures.19- Parse and standardize OnTAD output into BED-like tables and hierarchical annotation files.2021---2223## When to use this skill2425Use this skill when you want to **identify TADs and nested sub-TADs** from high- or mid-resolution Hi-C data, especially when your contact maps are stored as **Cooler multi-resolution files (.mcool)** and you need **chromosome- and resolution-specific** OnTAD calls.2627Typical biological questions / use-cases:2829- Comparing **TAD hierarchy** between cell types (e.g., GM12878 vs K562) or conditions (control vs treated).30- Investigating whether **inner subTADs** are enriched for active regulatory elements, specific histone marks, or gene expression.31- Studying **boundary usage**, **boundary sharing**, or **hierarchical TAD levels** around key loci (e.g., HOX clusters, oncogenes).32- Integrating nested TAD structure with **ChIP-seq**, **ATAC-seq**, or **WGBS** to understand spatial regulatory architecture.3334Data quality & replication assumptions:3536- Hi-C experiments should have **sufficient depth** for the target resolution (e.g., ≥5–10 kb typically requires deep sequencing).37- Preferably, use **biological replicates** per condition and call TADs on either:38 - individual replicate matrices (and then merge/consensus), or 39 - replicate-merged matrices (if justified).40- The `.mcool` should be **properly normalized or at least QC’d** (ICE/balanced weights available if using `--balanced`).4142---4344## Inputs & Outputs4546### Inputs4748Required core inputs:4950- **Hi-C matrix file**51 - Multi-resolution Cooler file (`.mcool`), e.g.:52 - `sample.mcool`53 - Or one-resolution Cooler file (`.cool`), e.g.:54 - `sample.cool`55 - Or Hi-C file (`.hic`), e.g.:56 - `sample.hic`57- **User-supplied parameters (must come from user feedback)**58 - Chromosome name: e.g., `chr1`, `chr2`, `chrX`59 - Resolution of interest: e.g., `10000`, `25000`, `40000` (in bp)60 - Chromosome length: e.g., 13327530961- **Software and environment**62 - `cooler` command-line utilities (or Python `cooler` module) available in `$PATH` or environment.63 - `OnTAD` installed and callable (e.g., `OnTAD` or `OnTAD_linux` command).64 - `python` (3.x) and basic scientific Python stack if using Python-based extraction.6566Optional entry point:6768- **Precomputed dense Hi-C matrix (OnTAD-ready)**69 - Plain text dense square matrix (no header), e.g. `proj_dir/matrices/chr17_25kb_dense.matrix`. 70 - If this is already present, you may **skip the `.mcool` → dense matrix conversion** and jump directly to OnTAD.7172Operational rules for missing inputs:7374- If `.mcool` or `.cool` or `.hic` file is missing: 75 `"sample.mcool not available, provide required files or skip and proceed ?"`76- If chromosome list not specified: 77 Ask the user explicitly rather than assuming default.78- If OnTAD executable is not found: 79 Ask user to install/locate OnTAD before proceeding.8081---8283### Outputs8485Default output directory structure:8687```bash88${sample}_nested_TAD_detection/89 matrices/90 ${chromosome}_${resolution}_dense.txt91 ${chromosome}_${resolution}_dense.log92 nested_TADs/93 ${chromosome}_${resolution}_OnTAD.tad94 ${chromosome}_${resolution}_OnTAD.bed95 ${chromosome}_${resolution}_OnTAD.log96```9798---99100101## Allowed Tools102103When using this skill, you should restrict yourself to the following MCP tools from server `cooler-tools`, `cooltools-tools`, `plot-hic-tools`, `project-init-tools`:104- `mcp__project-init-tools__project_init`105- `mcp__cooler-tools__list_mcool_resolutions`106- `mcp__cooler-tools__harmonize_chrom_names`107- `mcp__cooler-tools__dump_chroms`108- `mcp__cooler-tools__dump_dense_matrix`109- `mcp__OnTAD-tools__run_ontad`110111112Do NOT fall back to:113114- raw shell commands (`OnTAD`, etc.)115- ad-hoc Python snippets (e.g. importing `cooler`, `bioframe`, `matplotlib` manually in the reply).116117---118119120## Decision Tree121122### Step 0 — Gather Required Information from the User123124Before calling any tool, ask the user:1251261. Sample name (`sample`): used as prefix and for the output directory `${sample}_nested_TAD_detection`.1271282. Genome assembly (`genome`): e.g. `hg38`, `mm10`, `danRer11`. 129 - **Never** guess or auto-detect.1301313. Hi-C matrix path/URI (`mcool_uri`):132 - `path/to/sample.mcool::/resolutions/25000` (.mcool file with resolution specified)133 - or `.cool` file path134 - or `.hic` file path1351364. Resolution (`resolution`): default `25000` (100 kb). 137 - If user does not specify, use `25000` as default.138 - Must be the same as the resolution used for `${mcool_uri}`139140---141142143### Step 1 — Initialize Project1441451. Make director for this project:146147Call:148149- `mcp__project-init-tools__project_init`150151with:152153- `sample`: the user-provided sample name154- `task`: hic_matrix_qc155156The tool will:157158- Create `${sample}_nested_TAD_detection` directory.159- Return the full path of the `${sample}_nested_TAD_detection` directory, which will be used as `${proj_dir}`.160161---1621632. If the user provides a `.hic` file, convert it to `.mcool` file using `mcp__HiCExplorer-tools__hic_to_mcool` tool:164165Call:166- `mcp__HiCExplorer-tools__hic_to_mcool`167168with:169- `input_hic`: the user-provided path (e.g. `input.hic`)170- `sample`: the user-provided sample name171- `proj_dir`: directory to save the view file. In this skill, it is the full path of the `${sample}_nested_TAD_detection` directory returned by `mcp__project-init-tools__project_init`.172173The tool will:174- Convert the `.hic` file to `.mcool` file.175- Return the path of the `.mcool` file.176177If the conversion is successful, update `${mcool_uri}` to the path of the `.mcool` file.178179---180181182### Step 2: List Available Resolutions in the .mcool file & Modify the Chromosome Names if Necessary1831841. Check the resolutions in `mcool_uri`:185186Call:187188- `mcp__cooler-tools__list_mcool_resolutions`189190with:191192- `mcool_path`: the user-provided path (e.g. `input.mcool`) without resolution specified.193194The tool will:195196- List all resolutions in the .mcool file.197- Return the resolutions as a list.198199If the user defined or default `${resolution}` is not found in the list, ask the user to specify the resolution again.200Else, use `${resolution}` for the following steps.201202---2032042. Check if the chromosome names in the .mcool file are started with "chr", and if not, modify them to start with "chr":205206Call:207208- `mcp__cooler-tools__harmonize_chrom_names`209210with:211- `sample`: the user-provided sample name212- `proj_dir`: directory to save the expected-cis and eigs-cis files. In this skill, it is the full path of the `${sample}_Compartments_calling` directory returned by `mcp__project-init-tools__project_init`213- `mcool_uri`: cooler URI with resolution specified, e.g. `input.mcool::/resolutions/${resolution}`214- `resolution`: `${resolution}` must be the same as the resolution used for `${mcool_uri}` and must be an integer215216The tool will:217- Check if the chromosome names in the .mcool file.218- If not, harmonize the chromosome names in the .mcool file.219- If the chromosome names are modified, return the path of the modified .mcool file under `${proj_dir}/` directory220221---222223224### Step 3: Check chromosome length225226Call:227228- `mcp__cooler-tools__dump_chroms`229230with:231232- `mcool_uri`: cooler URI with resolution specified, e.g. `input.mcool::/resolutions/${resolution}`233- `resolution`: `${resolution}` must be the same as the resolution used for `${mcool_uri}` and must be an integer234235The tool will:236237- Return the chromosome name and length as a table.238239---240241242### Step 4: Extract dense matrix from `.mcool`243244Call:245246- `mcp__cooler-tools__dump_dense_matrix`247248with:249250- `sample`: the user-provided sample name251- `proj_dir`: directory to save the view file. In this skill, it is the full path of the `${sample}_nested_TAD_detection` directory returned by `mcp__project-init-tools__project_init`.252- `mcool_uri`: cooler URI with resolution specified, e.g. `input.mcool::/resolutions/${resolution}`253- `resolution`: `${resolution}` must be the same as the resolution used for `${mcool_uri}` and must be an integer254- `chrom`: the user-provided chromosome name (e.g. `chr17`)255- `balanced`: whether to use balanced matrix (default: True)256257The tool will:258259- Extract the dense matrix from the .mcool file.260- Return the path of the dense matrix file.261262---263264### Step 5: Run OnTAD265266Call:267268- `mcp__OnTAD-tools__run_ontad`269270with:271272- `sample`: the user-provided sample name273- `proj_dir`: directory to save the view file. In this skill, it is the full path of the `${sample}_nested_TAD_detection` directory returned by `mcp__project-init-tools__project_init`.274- `dense_matrix`: the path to the dense matrix file (e.g. `${proj_dir}/matrices/chr17_25kb_dense.matrix`)275- `chrom`: the user-provided chromosome name (e.g. `chr17`)276- `chrom_length`: the corresponding chromosome length (e.g. 83257441) returned by `mcp__cooler-tools__dump_chroms` tool.277- `resolution`: the user-provided resolution (e.g. 25000)278- `penalty`: the penalty parameter for OnTAD (e.g. 0.1)279- `maxsz`: the maximum TAD size (in bins) (e.g. 200)280281The tool will:282- Run OnTAD to call TADs and nested TAD structures.283- Return the path of the OnTAD output file (.tad, .bed, .log).284