Merges spatially proximal chromatin loops into consensus interactions using graph-based clustering.
Loops are considered overlapping if both anchors are within gap bp of each other.
Each resulting cluster is represented by the union genomic range (min start to max end) spanning all its members.
Arguments
- gi
A
GInteractionsobject.- gap
Numeric. Maximum distance (in base pairs) allowed between anchors to consider two loops overlapping. Default: 1000.
Value
A list with two elements:
giReduced
GInteractionsobject, one per cluster.membershipInteger vector indicating cluster assignment for each input loop.
Metadata columns include cluster_id, n_members, n_reps, and averaged score.
Examples
# 1. Load example data (loops that are close to each other)
bedpe_path <- system.file("extdata", "example_loops_1.bedpe", package = "looplook")
# Convert BEDPE to GInteractions object
gi_raw <- bedpe_to_gi(bedpe_path)
# 2. Run clustering
res <- reduce_ginteractions(gi_raw, gap = 1000)
#> --- Gap Diagnosis ---
#> Anchor width: median = 4,970.5 bp (IQR: 3,544.75 - 7,232.5 bp)
#> Adjacent-anchor gap: median = 6,943 bp (42% within current gap = 1,000 bp)
#> Gap / median_anchor_width ratio: 0.2x (effective width expansion: 1.4x)
#> Gap appears appropriate for the anchor width distribution.
#> [i] Super-enhancer-like anchors -- very broad regulatory domains.
#> --- End Gap Diagnosis ---
#> --- Post-Clustering Diagnosis ---
#> Clusters formed: 299 (from 300 loops surviving consensus)
#> Members per cluster: median = 1, IQR = 1-1, max = 2
#> Consensus retention: 300 / 300 input loops (100.0%)
#> Cluster span: median = 6,781 | max = 26,481 | threshold = 5xmed_width(4,970.5) x gap/1000 = 24,852 bp
#> Largest cluster spans:
#> #24: max_span = 26,481 bp, n_members = 1, n_reps = 1
#> #29: max_span = 26,481 bp, n_members = 1, n_reps = 1
#> #128: max_span = 26,481 bp, n_members = 1, n_reps = 1
#> Chaining: 0/299 above threshold -- PASS.
#> --- End Post-Clustering Diagnosis ---
# 3. Inspect results
print(res$gi)
#> StrictGInteractions object with 299 interactions and 4 metadata columns:
#> seqnames1 ranges1 seqnames2 ranges2 |
#> <Rle> <IRanges> <Rle> <IRanges> |
#> [1] chr1 109492653-109495835 --- chr1 110644073-110649627 |
#> [2] chr1 116687217-116689300 --- chr1 116844970-116856809 |
#> [3] chr1 116876466-116881376 --- chr1 117819957-117830132 |
#> [4] chr1 146374139-146379497 --- chr1 146442738-146445345 |
#> [5] chr1 1370035-1377149 --- chr1 1469038-1474411 |
#> ... ... ... ... ... ... .
#> [295] chr1 1011274-1015982 --- chr1 1018257-1022868 |
#> [296] chr1 1342740-1364987 --- chr1 1397120-1403614 |
#> [297] chr1 147271365-147274896 --- chr1 147290757-147294529 |
#> [298] chr1 108639597-108642391 --- chr1 109098570-109102247 |
#> [299] chr1 11011475-11014295 --- chr1 12745039-12747130 |
#> cluster_id n_members score n_reps
#> <character> <integer> <numeric> <integer>
#> [1] 1 1 1 1
#> [2] 2 1 1 1
#> [3] 3 1 2 1
#> [4] 4 1 1 1
#> [5] 5 1 3 1
#> ... ... ... ... ...
#> [295] 295 1 12 1
#> [296] 296 1 7 1
#> [297] 297 1 4 1
#> [298] 298 1 1 1
#> [299] 299 1 1 1
#> -------
#> regions: 384 ranges and 0 metadata columns
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
head(res$membership)
#> [1] 1 2 3 4 5 6
table(res$membership)
#>
#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#> 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
#> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
