Bin¶
Summarize a track into fixed-size genomic bins. This is the bridge
from SignalTrack (which doesn't support map_scores) to IntervalTrack
(which supports all transforms).
The mean method works on any Track. The max, min, and sum methods
require raw_signal() (SignalTrack only).
bin
¶
Bin-based transforms for signal tracks.
Converts continuous signal data into discrete intervals by summarizing signal values within fixed-size genomic bins.
Examples:
>>> from seqchain.transform.bin import bin_summarize
>>> intervals = bin_summarize(signal_track, 200, {"chr1": 10000})
bin_summarize
¶
bin_summarize(track: 'Track', bin_size: int, chrom_sizes: dict[str, int], method: str = 'mean') -> IntervalTrack
Summarize a track's signal into fixed-size genomic bins.
"mean" uses signal_at() and works on any track type.
"max", "min", and "sum" require per-base resolution
via raw_signal() (only available on SignalTrack).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
'Track'
|
Input track. |
required |
bin_size
|
int
|
Bin size in base pairs. |
required |
chrom_sizes
|
dict[str, int]
|
Chromosome name to length mapping. |
required |
method
|
str
|
Summarization method. One of |
'mean'
|
Returns:
| Type | Description |
|---|---|
IntervalTrack
|
An IntervalTrack with one Region per bin. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If method is not recognized, or if a per-base
method is requested on a track without |
Examples: