Skip to content

FeatureTrack Class

FeatureTrack

FeatureTrack(
    name: str,
    seg_name2range: Mapping[str, tuple[int, int]],
    *,
    gv: GenomeViz,
    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: str

seg_name2range

Segment name & range dict

TYPE: Mapping[str, tuple[int, int]]

gv

Parent GenomeViz instance

TYPE: GenomeViz

ratio

Track size ratio

TYPE: float DEFAULT: 1.0

space

Space ratio between segments

TYPE: float | list[float] DEFAULT: 0.01

offset

Offset int value or TrackAlignType (left|center|right)

TYPE: int | TrackAlignType DEFAULT: 'left'

labelsize

Track label size

TYPE: float DEFAULT: 20

labelmargin

Track label margin

TYPE: float DEFAULT: 0.01

align_label

If True, align track label to the most left position. If False, set track label to first segment start position.

TYPE: bool DEFAULT: True

label_kws

Text properties (e.g. dict(size=25, color="red", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.text.html

TYPE: dict[str, Any] | None DEFAULT: None

line_kws

Axes.plot properties (e.g. dict(color="grey", lw=0.5, ls="--", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.plot.html

TYPE: dict[str, Any] | None DEFAULT: None

gv property

gv: GenomeViz

Parent GenomeViz

label property

label: str

Track label (By default, track.label = track.name)

raw_offset property

raw_offset: int | TrackAlignType

Raw offset value

offset property

offset: int

Track offset

segments property

segments: list[FeatureSegment]

Segments

subtracks property

subtracks: list[FeatureSubTrack]

Subtracks

size property

size: int

Total segment size

spaces property

spaces: list[int]

Spaces between segments

plot_size property

plot_size: int

Plot size (track size + sum(spaces))

set_label

set_label(label: str) -> None

Set track label (By default, track.label = track.name)

PARAMETER DESCRIPTION
label

Track label

TYPE: str

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: bool | list[bool] DEFAULT: True

symbol

Separator symbol text

TYPE: str DEFAULT: '//'

size

Separator symbol size

TYPE: float DEFAULT: 20

color

Separator symbol color

TYPE: str DEFAULT: 'grey'

**kwargs

TYPE: dict DEFAULT: {}

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: str DEFAULT: None

ratio

Subtrack size ratio to feature track

TYPE: float DEFAULT: 1.0

ylim

Axes ylim

TYPE: tuple[int, int] DEFAULT: (0, 100)

RETURNS DESCRIPTION
subtrack

Subtrack

TYPE: FeatureSubTrack

get_subtrack

get_subtrack(name: str | None = None) -> FeatureSubTrack

Get subtrack by name

If no subtrack found, raise error.

PARAMETER DESCRIPTION
name

Target subtrack name. If None, first subtrack is returned.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
subtrack

Target subtrack

TYPE: FeatureSubTrack

get_segment

get_segment(name: str | None = None) -> FeatureSegment

Get segment by name

PARAMETER DESCRIPTION
name

Target segment name. If None, first segment is returned.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
segment

Target segment

TYPE: FeatureSegment

plot_all

plot_all(fast_render: bool = True) -> None

Plot all objects (Expected to be called in gv.plotfig())

  1. Plot track label
  2. Plot segment lines
  3. Plot segment separator
  4. Plot features
  5. Plot texts
PARAMETER DESCRIPTION
fast_render

Enable fast rendering using PatchCollection plot style.

TYPE: bool DEFAULT: True