Plotting
Visualization helpers: per-base attribution sequence logos and the IGV-style genome browser for predicted vs. observed tracks.
AttributionPlotter
Plot per-base attribution scores as a sequence logo, with optional motif tracks.
Renders an attribution vector (e.g. from
:class:~bolero.tl.predict.predictor_borzoi.BorzoiInputXGradient) as a
letter-height logo over the underlying DNA sequence, optionally overlaying
called motif hits. Used in the DNA-attribution tutorial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genome
|
str or Genome
|
The genome the regions are drawn from. A string is resolved to a
:class: |
required |
plot
plot(ax, attribution: ndarray, sequence: str | ndarray | None = None, region: str | tuple | None = None, motifs: DataFrame | None = None, motif_mode: str = 'vspan', rectangle_ratio: float = 0.98, rasterize: bool = True, motif_color: str = '#11111111', motif_y: float | None = None, motif_label: bool = True) -> None
Plot attribution scores and motif annotations on an axes object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
The axes object to which the plot will be added. |
required |
attribution
|
ndarray
|
The attribution scores, which will be plotted on 1D, projected to the sequence. |
required |
sequence
|
str or ndarray
|
The sequence of the region. Either sequence or region must be provided. |
None
|
region
|
tuple
|
The region of the sequence. Either sequence or region must be provided. |
None
|
motifs
|
DataFrame
|
The motifs to be plotted. Motif should be pre-filtered to reduce overlap. |
None
|
motif_mode
|
str
|
Plot mode for motifs. Default is "vspan". |
'vspan'
|
rectangle_ratio
|
float
|
The ratio of the weights below which the elements are approximated as rectangles. Default is 0.98. |
0.98
|
rasterize
|
bool
|
Whether to rasterize the patches. Default is True. |
True
|
motif_color
|
str
|
The color of the motif. Default is "#11111111". |
'#11111111'
|
motif_y
|
float
|
The y-coordinate of the motif. Default is None. |
None
|
motif_label
|
bool
|
Whether to label the motifs. Default is True. |
True
|
Browser
dataclass
IGV Browser wrapper with enhanced track management
browser
property
browser: Browser
Get the IGV browser object.
to_dict
to_dict() -> dict[str, Any]
Convert the browser configuration to a dictionary suitable for IGV.
load_track
load_track(**kwargs)
Add a track to the browser
load_track_table
load_track_table(track_table: DataFrame, **other_config: Any)
Load a track table into the browser