This skill calls A/B chromatin compartments from balanced Hi-C contact matrices using cooltools eigenvector decomposition. The active (A) and inactive (B) compartments are read from an eigenvector of the distance-normalized, Pearson-correlated cis matrix -- but two decisions make or break the result: which eigenvector is actually the compartment track (E1 often captures a centromere arm gradient instead), and the eigenvector's sign, which is arbitrary until phased against a GC or gene-density track. The skill covers per-arm eigendecomposition, GC phasing with bioframe, resolution choice, saddle plots and saddle_strength for compartmentalization strength, the counterintuitive cohesin-loss-strengthens-compartments result, subcompartment tooling (SNIPER/Calder/dcHiC), and cross-condition switching.
pip install cooler cooltools bioframe matplotlib
The cooler must already be balanced (a stored weight column) before compartment analysis -- balance it in matrix-operations first. A genome FASTA with a .fai index is needed for the GC phasing track. For .mcool files, use a single-resolution URI such as matrix.mcool::/resolutions/100000.
Tell your AI agent what you want to do: - "Call A/B compartments from my balanced Hi-C cooler at 100kb" - "Phase the compartment eigenvector by GC content from hg38" - "Run the eigenvector per chromosome arm so the centromere gradient does not dominate" - "Build a saddle plot and report compartment strength" - "Compare compartmentalization between treatment and control"
"I have a balanced .mcool. Call A/B compartments at 100kb, run eigs_cis per chromosome arm, phase E1 by GC content from hg38, and save the eigenvector and A/B calls as a BED file."
"My compartment track is monotonic across chr1 with no sign flips -- I think I captured the arm gradient. Split the view at centromeres, request 3 eigenvectors, and pick the one with the strongest correlation to GC."
"Compute a saddle plot from my balanced cooler and report the compartment strength as the (AA+BB)/(AB+BA) corner ratio at a fixed extent."
"I knocked out Nipbl and the compartments look stronger -- is that expected? Quantify strength in both samples with matched saddle settings."
"Compare A/B compartments between two conditions and flag bins that switch -- use dcHiC so the signs are coherent across samples rather than hand-diffing two eigenvectors."
"I want A1/A2/B1/B2/B3 subcompartments, not just A/B -- which tool should I use given my coverage?"
view_df by fetching centromeres and calling bioframe.make_chromarms, subset to the cooler's chromosomes.bioframe.frac_gc on the cooler's bins at the matched resolution.cooltools.eigs_cis with the GC track, n_eigs=3, and sort_metric='pearsonr', then confirm E1 correlates with GC (else pick E2/E3).expected_cis, build the saddle with cooltools.saddle, and read saddle_strength at a fixed extent.sort_metric='pearsonr' so eigenvectors are ordered by GC correlation, not eigenvalue.n_eigs; use SNIPER, Calder, or dcHiC.n_bins, qrange, resolution, and the corner extent identical across all compared samples for strength.