Alignment¶
Pair regions across two tracks for comparison. Two modes:
- exact — match by region name (e.g., gene names, barcode IDs)
- overlap — bin the genome and compare signal in each bin
Returns AlignedPair objects that record which track each region came from
and its value in each condition.
AlignedPair
dataclass
¶
A single paired observation from two Tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
Region
|
The coordinate or key this pair refers to. |
required |
value_a
|
float
|
Observation from track a. |
required |
value_b
|
float
|
Observation from track b. |
required |
in_a
|
bool
|
Whether the region was present in track a. |
True
|
in_b
|
bool
|
Whether the region was present in track b. |
True
|
Examples:
>>> AlignedPair(Region("chr1", 100, 200), 5.0, 10.0, True, True)
AlignedPair(region=Region(...), value_a=5.0, value_b=10.0, in_a=True, in_b=True)
align_tracks
¶
align_tracks(a: Track, b: Track, *, missing: float = float('nan'), mode: Literal['exact', 'overlap'] = 'exact', bin_size: int = 200, chrom_sizes: dict[str, int] | None = None) -> Iterator[AlignedPair]
Align two Tracks and yield paired observations.
Auto-detects the track types and dispatches to the appropriate alignment mode. Both tracks must be the same type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Track
|
First track. |
required |
b
|
Track
|
Second track. |
required |
missing
|
float
|
Value to use when a region exists in one track
but not the other. Defaults to |
float('nan')
|
mode
|
Literal['exact', 'overlap']
|
IntervalTrack alignment mode. |
'exact'
|
bin_size
|
int
|
Window size for SignalTrack alignment.
Defaults to |
200
|
chrom_sizes
|
dict[str, int] | None
|
Chromosome sizes for SignalTrack alignment. Required when aligning SignalTracks. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[AlignedPair]
|
Iterator of |
Raises:
| Type | Description |
|---|---|
TypeError
|
If track types don't match or aren't supported. |
ValueError
|
If chrom_sizes is missing for SignalTrack alignment
or if mode is not |
Examples: