loops_to_beddb
chr3d.utils.loops_to_beddb(
loops_csv: str,
peaks_path: str,
output_bedpe: str,
output_bedpedb: str,
assembly: str = "hg38",
p_value_col: str = "p_adj_fdr_bh",
significant_col: str = "significant_fdr_bh",
canonical_chroms_only: bool = True,
max_score: float = 300.0,
chromsizes_path: str = None,
skip_verify: bool = False,
) -> Dict[str, Any]Convert significant-loops CSV + narrowPeak → BEDPE → bedpedb (HiGlass).
One-call wrapper that chains csv_to_bedpe, bedpe_to_bedpedb, and optionally verify_positions.
Parameters
| Parameter | Type | Description |
|---|---|---|
| loops_csv | str | Path to significant loops CSV file |
| peaks_path | str | Path to narrowPeak file |
| output_bedpe | str | Path for intermediate BEDPE output |
| output_bedpedb | str | Path for final bedpedb (HiGlass SQLite) output |
| assembly | str | Genome assembly name (default: "hg38") |
| p_value_col | str | Column name for p-values in loops CSV (default: "p_adj_fdr_bh") |
| significant_col | str | Column name for significance flag in loops CSV (default: "significant_fdr_bh") |
| canonical_chroms_only | bool | Keep only canonical chromosomes (default: True) |
| max_score | float | Maximum -log10(p) score (default: 300) |
| chromsizes_path | str | Path to chromosome sizes file (needed for verification) |
| skip_verify | bool | Skip position verification step (default: False) |
Returns:
Dict[str, Any] — Combined statistics from all conversion steps, plus "verification_passed" key if verification was run.
Example:
from chr3d.utils import loops_to_beddb
stats = loops_to_beddb(
loops_csv="significant_loops.csv",
peaks_path="peaks.narrowPeak",
output_bedpe="loops.bedpe",
output_bedpedb="loops.bedpedb",
chromsizes_path="hg38.chrom.sizes",
)
print(f"Final loops: {stats['n_final']}")
print(f"Verification: {stats['verification_passed']}")Last updated on