The coordinate-reinstatement step: run-length-collapses the equal-state runs
within each (name, chr) from call_states() into segments. Point units
(markers) use pos for both boundaries; interval units (bins) carry their
own per-unit start_bp/end_bp (as the binhmm caller emits). This is the
only place genomic coordinates re-enter — the decode itself is coordinate-free.
Arguments
- states
A per-unit state table from
call_states():name, chr, pos, state(+ optionalsource, donor; + optionalstart_bp, end_bpfor interval/bin units).
Examples
st <- data.frame(name = "NIL1", chr = 1L, pos = (1:6) * 1e5L,
state = c(0L, 0L, 2L, 2L, 0L, 0L))
to_segments(st)
#> source donor name chr start_bp end_bp state
#> 1 nilHMM <NA> NIL1 1 100000 200000 0
#> 2 nilHMM <NA> NIL1 1 300000 400000 2
#> 3 nilHMM <NA> NIL1 1 500000 600000 0