FeatureTrack Class
FeatureTrack
FeatureTrack(
name: str,
seg_name2range: Mapping[str, tuple[int, int]],
*,
ratio: float = 1.0,
space: float | list[float] = 0.01,
offset: int | TrackAlignType = "left",
labelsize: float = 20,
labelmargin: float = 0.01,
align_label: bool = True,
label_kws: dict[str, Any] | None = None,
line_kws: dict[str, Any] | None = None
)
Bases: Track
Feature Track Class
PARAMETER | DESCRIPTION |
---|---|
name |
Track name
TYPE:
|
seg_name2range |
Segment name & range dict
TYPE:
|
ratio |
Track size ratio
TYPE:
|
space |
Space ratio between segments
TYPE:
|
offset |
Offset int value or TrackAlignType (
TYPE:
|
labelsize |
Track label size
TYPE:
|
labelmargin |
Track label margin
TYPE:
|
align_label |
If True, align track label to the most left position. If False, set track label to first segment start position.
TYPE:
|
label_kws |
Text properties (e.g.
TYPE:
|
line_kws |
Axes.plot properties (e.g.
TYPE:
|
max_track_total_seg_size
property
Max track total segment size (Use space calculation)
set_max_track_total_seg_size
Set max track total segment size
This method is expected to be called within the GenomeViz instance to update track status. General users should not use this method.
PARAMETER | DESCRIPTION |
---|---|
max_track_total_seg_size |
Max track total segment size
TYPE:
|
set_label
Set track label (By default, track.label
= track.name
)
PARAMETER | DESCRIPTION |
---|---|
label |
Track label
TYPE:
|
set_segment_sep
set_segment_sep(
sep: bool | list[bool] = True,
*,
symbol: str = "//",
size: float = 20,
color: str = "grey",
**kwargs
) -> None
Set segment separator symbol text
PARAMETER | DESCRIPTION |
---|---|
sep |
If True, insert separator text between all segments. If list[bool], insert separator text between segments where True.
TYPE:
|
symbol |
Separator symbol text
TYPE:
|
size |
Separator symbol size
TYPE:
|
color |
Separator symbol color
TYPE:
|
**kwargs |
TYPE:
|
add_subtrack
add_subtrack(
name: str | None = None, *, ratio: float = 1.0, ylim: tuple[int, int] = (0, 100)
) -> FeatureSubTrack
Add subtrack for user-defined plot axes
PARAMETER | DESCRIPTION |
---|---|
name |
Track name
TYPE:
|
ratio |
Subtrack size ratio to feature track
TYPE:
|
ylim |
Axes ylim
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
subtrack
|
Subtrack
TYPE:
|
get_subtrack
Get subtrack by name
If no subtrack found, raise error.
PARAMETER | DESCRIPTION |
---|---|
name |
Target subtrack name. If None, first subtrack is returned.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
subtrack
|
Target subtrack
TYPE:
|
get_segment
Get segment by name
PARAMETER | DESCRIPTION |
---|---|
name |
Target segment name. If None, first segment is returned.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
segment
|
Target segment
TYPE:
|
add_text
add_text(
x: float,
text: str,
*,
target_seg: str | None = None,
size: float = 15,
vpos: VPos = "top",
hpos: HPos = "left",
ymargin: float = 0.2,
rotation: float = 45,
**kwargs
) -> None
Add text to track segment
PARAMETER | DESCRIPTION |
---|---|
x |
Text x coordinate
TYPE:
|
text |
Text content
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
size |
Text size
TYPE:
|
vpos |
Vertical position (
TYPE:
|
hpos |
Horizontal position (
TYPE:
|
ymargin |
Y margin
TYPE:
|
rotation |
Text rotation
TYPE:
|
**kwargs |
TYPE:
|
add_sublabel
add_sublabel(
text: str | None = None,
*,
target_seg: str | None = None,
size: float = 12,
pos: str = "bottom-left",
ymargin: float = 0.2,
rotation: float = 0,
**kwargs
) -> None
Add sublabel to corners of the track segment
PARAMETER | DESCRIPTION |
---|---|
text |
Text content
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
size |
Text size
TYPE:
|
pos |
Label position ([
TYPE:
|
ymargin |
Y margin
TYPE:
|
rotation |
Text rotation
TYPE:
|
**kwargs |
TYPE:
|
add_feature
add_feature(
start: int,
end: int,
strand: int = 1,
*,
target_seg: str | None = None,
plotstyle: PlotStyle = "arrow",
arrow_shaft_ratio: float = 0.5,
extra_tooltip: dict[str, str] | None = None,
label: str = "",
text_kws: dict[str, Any] | None = None,
**kwargs
) -> None
Add feature
PARAMETER | DESCRIPTION |
---|---|
start |
Start position
TYPE:
|
end |
End position
TYPE:
|
strand |
Feature strand
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
plotstyle |
Feature plot style (
TYPE:
|
arrow_shaft_ratio |
Arrow shaft size ratio
TYPE:
|
extra_tooltip |
Extra tooltip dict for html figure
TYPE:
|
label |
Feature label
TYPE:
|
text_kws |
TYPE:
|
**kwargs |
Patch properties (e.g.
TYPE:
|
add_features
add_features(
features: SeqFeature | list[SeqFeature],
*,
target_seg: str | None = None,
plotstyle: PlotStyle = "arrow",
arrow_shaft_ratio: float = 0.5,
label_type: str | None = None,
label_handler: Callable[[str], str] | None = None,
extra_tooltip: dict[str, str] | None = None,
ignore_outside_range: bool = False,
text_kws: dict[str, Any] | None = None,
**kwargs
) -> None
Add features (BioPython SeqFeature)
PARAMETER | DESCRIPTION |
---|---|
features |
BioPython SeqFeature or SeqFeature list
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
plotstyle |
Feature plot style (
TYPE:
|
arrow_shaft_ratio |
Arrow shaft size ratio
TYPE:
|
label_type |
Label type (e.g.
TYPE:
|
label_handler |
Label handler function to customize label display.
If None, set label handler to exclude labels containing
TYPE:
|
extra_tooltip |
Extra tooltip dict for html figure
TYPE:
|
ignore_outside_range |
If True and the feature position is outside the range of the track segment, ignore it without raising an error.
TYPE:
|
text_kws |
TYPE:
|
**kwargs |
Patch properties (e.g.
TYPE:
|
add_exon_feature
add_exon_feature(
locs: list[tuple[int, int]],
strand: int = 1,
*,
target_seg: str | None = None,
plotstyle: PlotStyle = "arrow",
arrow_shaft_ratio: float = 0.5,
label: str = "",
patch_kws: dict[str, Any] | None = None,
intron_patch_kws: dict[str, Any] | None = None,
text_kws: dict[str, Any] | None = None
) -> None
Add exon feature
PARAMETER | DESCRIPTION |
---|---|
locs |
Exon locations (e.g.
TYPE:
|
strand |
Feature strand
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
plotstyle |
Feature plot style (
TYPE:
|
arrow_shaft_ratio |
Arrow shaft size ratio
TYPE:
|
label |
Feature label
TYPE:
|
patch_kws |
Exon patch properties (e.g.
TYPE:
|
intron_patch_kws |
Intron patch properties (e.g.
TYPE:
|
text_kws |
TYPE:
|
add_exon_features
add_exon_features(
features: SeqFeature | list[SeqFeature],
*,
target_seg: str | None = None,
plotstyle: PlotStyle = "arrow",
arrow_shaft_ratio: float = 0.5,
label_type: str | None = None,
label_handler: Callable[[str], str] | None = None,
extra_tooltip: dict[str, str] | None = None,
ignore_outside_range: bool = False,
patch_kws: dict[str, Any] | None = None,
intron_patch_kws: dict[str, Any] | None = None,
text_kws: dict[str, Any] | None = None
) -> None
Add exon features
PARAMETER | DESCRIPTION |
---|---|
features |
BioPython SeqFeature or SeqFeature list
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
plotstyle |
Feature plot style (
TYPE:
|
arrow_shaft_ratio |
Arrow shaft size ratio
TYPE:
|
label_type |
Label type (e.g.
TYPE:
|
label_handler |
Label handler function to customize label display.
If None, set label handler to exclude labels containing
TYPE:
|
extra_tooltip |
Extra tooltip dict for html figure
TYPE:
|
ignore_outside_range |
If True and the feature position is outside the range of the track segment, ignore it without raising an error.
TYPE:
|
patch_kws |
Exon patch properties (e.g.
TYPE:
|
intron_patch_kws |
Intron patch properties (e.g.
TYPE:
|
text_kws |
TYPE:
|
transform_coord
transform_coord(
x: int | float | NDArray, *, target_seg: str | None = None
) -> int | float | NDArray[np.float64]
Transform segment-level coordinate to track-level coordinate
PARAMETER | DESCRIPTION |
---|---|
x |
Segment-level coordinate(s)
TYPE:
|
target_seg |
Target segment name. If None, first segment is selected.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
transform_x
|
Track-level coordinate(s)
TYPE:
|
plot_all
Plot all objects (Expected to be called in gv.plotfig()
)
- Plot track label
- Plot segment lines
- Plot segment separator
- Plot features
- Plot texts
PARAMETER | DESCRIPTION |
---|---|
fast_render |
Enable fast rendering using PatchCollection plot style.
TYPE:
|