Skip to content

GenomeViz Class

GenomeViz

GenomeViz(
    fig_width: float = 15,
    fig_track_height: float = 1.0,
    align_type: LiteralTypes.ALIGN_TYPE = "left",
    feature_track_ratio: float = 1.0,
    link_track_ratio: float = 1.0,
    tick_track_ratio: float = 1.0,
    track_spines: bool = False,
    tick_style: LiteralTypes.TICK_STYLE = None,
    plot_size_thr: float = 0,
    tick_labelsize: int = 15,
)

GenomeViz Class

PARAMETER DESCRIPTION
fig_width

Figure width

TYPE: float DEFAULT: 15

fig_track_height

Figure track height (Figure height = track number * fig track height)

TYPE: float DEFAULT: 1.0

align_type

Track align type (left|center|right)

TYPE: str DEFAULT: 'left'

feature_track_ratio

Feature track ratio

TYPE: float DEFAULT: 1.0

link_track_ratio

Link track ratio

TYPE: float DEFAULT: 1.0

tick_track_ratio

Tick track ratio

TYPE: float DEFAULT: 1.0

track_spines

If True, display track spines

TYPE: bool DEFAULT: False

tick_style

Tick style (axis|bar)

TYPE: str | None DEFAULT: None

plot_size_thr

Plot feature, link size threshold. If plot_size_thr=0.0005 and max_track_size=4.0Mb, feature, link smaller than max_track_size * plot_size_thr=2.0Kb are not plotted.

TYPE: float DEFAULT: 0

tick_labelsize

Tick label size

TYPE: int DEFAULT: 15

top_track property

top_track: FeatureTrack

Top feature track

bottom_track property

bottom_track: FeatureTrack

Bottom feature track

max_track_size property

max_track_size: int

Max track size

get_track

get_track(track_name: str) -> Track

Get track by name

PARAMETER DESCRIPTION
track_name

Target track name

TYPE: str

RETURNS DESCRIPTION
track

Target track

TYPE: Track

get_tracks

get_tracks(subtrack: bool = False) -> list[Track]

Get tracks

PARAMETER DESCRIPTION
subtrack

If True, include feature subtracks

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
tracks

Track list

TYPE: list[Track]

get_feature_tracks

get_feature_tracks() -> list[FeatureTrack]

Get feature tracks

RETURNS DESCRIPTION
feature_tracks

Feature track list

TYPE: list[FeatureTrack]

get_link_tracks() -> list[LinkTrack]

Get link tracks

RETURNS DESCRIPTION
link_tracks

Link track list

TYPE: list[LinkTrack]

add_feature_track

add_feature_track(
    name: str,
    size: int,
    start_pos: int = 0,
    labelsize: int = 20,
    labelcolor: str = "black",
    labelmargin: float = 0.01,
    linewidth: int = 1,
    linecolor: str = "grey",
    link_track_ratio: float | None = None,
) -> FeatureTrack

Add feature track

Add feature track, and also add link track between feature tracks if other feature tracks already exist.

PARAMETER DESCRIPTION
name

Track name

TYPE: str

size

Track size

TYPE: int

start_pos

Track start position. Track start-end range is defined as (start_pos, start_pos + size).

TYPE: int DEFAULT: 0

labelsize

Track label size

TYPE: int DEFAULT: 20

labelcolor

Track label color

TYPE: str DEFAULT: 'black'

labelmargin

Track label margin

TYPE: float DEFAULT: 0.01

linewidth

Track line width

TYPE: int DEFAULT: 1

linecolor

Track line color

TYPE: str DEFAULT: 'grey'

link_track_ratio

Link track ratio. By default, the link_track_ratio value set when GenomeViz was instantiated is used.

TYPE: float | None DEFAULT: None

RETURNS DESCRIPTION
feature_track

Feature track

TYPE: FeatureTrack

add_link(
    track_link1: tuple[str, int, int],
    track_link2: tuple[str, int, int],
    normal_color: str = "grey",
    inverted_color: str = "red",
    alpha: float = 0.8,
    v: float | None = None,
    vmin: float = 0,
    vmax: float = 100,
    curve: bool = False,
    size_ratio: float = 1.0,
    patch_kws: dict[str, Any] | None = None,
) -> None

Add link data to link track between adjacent feature tracks

PARAMETER DESCRIPTION
track_link1

Track link1 (track_name, start, end)

TYPE: tuple[str, int, int]

track_link2

Track link2 (track_name, start, end)

TYPE: tuple[str, int, int]

normal_color

Normal link color

TYPE: str DEFAULT: 'grey'

inverted_color

Inverted link color

TYPE: str DEFAULT: 'red'

alpha

Color transparency

TYPE: float DEFAULT: 0.8

v

Value for color interpolation

TYPE: float | None DEFAULT: None

vmin

Min value for color interpolation

TYPE: float DEFAULT: 0

vmax

Max value for color interpolation

TYPE: float DEFAULT: 100

curve

If True, bezier curve link is plotted

TYPE: bool DEFAULT: False

size_ratio

Link size ratio to track

TYPE: float DEFAULT: 1.0

patch_kws

Patch properties (e.g. dict(fc="red", ec="black", lw=0.5, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

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

set_colorbar

set_colorbar(
    figure: Figure,
    bar_colors: list[str] | None = None,
    alpha: float = 0.8,
    vmin: float = 0,
    vmax: float = 100,
    bar_height: float = 0.2,
    bar_width: float = 0.01,
    bar_left: float = 1.02,
    bar_bottom: float = 0,
    bar_label: str = "",
    bar_labelsize: float = 15,
    tick_labelsize: float = 10,
) -> None

Set colorbars to figure

Set colorbars for similarity links between genome tracks

PARAMETER DESCRIPTION
figure

Matplotlib figure

TYPE: Figure

bar_colors

Bar color list

TYPE: list[str] | None DEFAULT: None

alpha

Color transparency

TYPE: float DEFAULT: 0.8

vmin

Colorbar min value

TYPE: float DEFAULT: 0

vmax

Colorbar max value

TYPE: float DEFAULT: 100

bar_height

Colorbar height

TYPE: float DEFAULT: 0.2

bar_width

Colorbar width

TYPE: float DEFAULT: 0.01

bar_left

Colorbar left position

TYPE: float DEFAULT: 1.02

bar_bottom

Colorbar bottom position

TYPE: float DEFAULT: 0

bar_label

Colorbar label name

TYPE: str DEFAULT: ''

bar_labelsize

Colorbar label size

TYPE: float DEFAULT: 15

tick_labelsize

Colorbar tick label size

TYPE: float DEFAULT: 10

plotfig

plotfig(dpi: int = 100) -> Figure

Plot figure

PARAMETER DESCRIPTION
dpi

DPI

TYPE: int DEFAULT: 100

RETURNS DESCRIPTION
figure

Plot figure result

TYPE: Figure

savefig

savefig(savefile: str | Path, dpi: int = 100, pad_inches: float = 0.5) -> None

Save figure to file

PARAMETER DESCRIPTION
savefile

Save file

TYPE: str | Path

dpi

DPI

TYPE: int DEFAULT: 100

pad_inches

Padding inches

TYPE: float DEFAULT: 0.5

savefig_html

savefig_html(
    html_outfile: str | Path | io.StringIO | io.BytesIO, fig: Figure | None = None
) -> None

Save figure in html format

PARAMETER DESCRIPTION
html_outfile

Output HTML file (*.html)

TYPE: str | Path | StringIO | BytesIO

fig

If Figure set, plot html viewer using user customized fig

TYPE: Figure | None DEFAULT: None