Skip to content

Track Class

Track

Track(name: str, r_lim: tuple[float, float], r_pad_ratio: float, parent_sector: Sector)

Circos Track Class

PARAMETER DESCRIPTION
name

Track name

TYPE: str

r_lim

Track radius limit region

TYPE: tuple[float, float]

r_pad_ratio

Track padding ratio for plot data

TYPE: float

parent_sector

Parent sector of track

TYPE: Sector

name property

name: str

Track name

size property

size: float

Track size (x coordinate)

start property

start: float

Track start position (x coordinate)

end property

end: float

Track end position (x coordinate)

center property

center: float

Track center position (x coordinate)

r_size property

r_size: float

Track radius size

r_lim property

r_lim: tuple[float, float]

Track radius limit

r_center property

r_center: float

Track center radius

r_plot_size property

r_plot_size: float

Track radius size for plot data (r_size with padding)

r_plot_lim property

r_plot_lim: tuple[float, float]

Track radius limit for plot data (r_lim with padding)

rad_size property

rad_size: float

Track radian size

rad_lim property

rad_lim: tuple[float, float]

Track radian limit

deg_size property

deg_size: float

Track degree size

deg_lim property

deg_lim: tuple[float, float]

Track degree limit

parent_sector property

parent_sector: Sector

Parent sector

clockwise property

clockwise: bool

Track coordinate direction

patches property

patches: list[Patch]

Plot patches

plot_funcs property

plot_funcs: list[Callable[[PolarAxes], None]]

Plot functions

x_to_rad

x_to_rad(x: float, ignore_range_error: bool = False) -> float

Convert x coordinate to radian in track start-end range

PARAMETER DESCRIPTION
x

X coordinate

TYPE: float

ignore_range_error

Ignore x coordinate range error

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
rad

Radian coordinate

TYPE: float

axis

axis(**kwargs) -> None

Plot axis

By default, simple black axis params(fc="none", ec="black", lw=0.5) are set.

PARAMETER DESCRIPTION
**kwargs

Patch properties (e.g. fc="tomato", ec="blue", hatch="//") https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict DEFAULT: {}

text

text(
    text: str,
    x: float | None = None,
    r: float | None = None,
    *,
    adjust_rotation: bool = True,
    orientation: str = "horizontal",
    ignore_range_error: bool = False,
    **kwargs
) -> None

Plot text

PARAMETER DESCRIPTION
text

Text content

TYPE: str

x

X position. If None, track center x position is set.

TYPE: float | None DEFAULT: None

r

Radius position. If None, track center radius position is set.

TYPE: float | None DEFAULT: None

adjust_rotation

If True, text rotation is auto set based on x and orientation params.

TYPE: bool DEFAULT: True

orientation

Text orientation (horizontal or vertical) If adjust_rotation=True, orientation is used for rotation calculation.

TYPE: str DEFAULT: 'horizontal'

ignore_range_error

If True, ignore x position range error (ErrorCase: not track.start <= x <= track.end)

TYPE: bool DEFAULT: False

**kwargs

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

TYPE: dict DEFAULT: {}

rect

rect(
    start: float,
    end: float,
    *,
    r_lim: tuple[float, float] | None = None,
    ignore_pad: bool = False,
    **kwargs
) -> None

Plot rectangle

PARAMETER DESCRIPTION
start

Start position (x coordinate)

TYPE: float

end

End position (x coordinate)

TYPE: float

r_lim

Radius limit range. If None, track.r_lim (ignore_pad=False) or track.r_plot_lim (ignore_pad=True) is set.

TYPE: tuple[float, float] | None DEFAULT: None

ignore_pad

If True, ignore track padding setting. If r_lim param is set by user, this option not works.

TYPE: bool DEFAULT: False

**kwargs

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

TYPE: dict DEFAULT: {}

arrow

arrow(
    start: float,
    end: float,
    *,
    r_lim: tuple[float, float] | None = None,
    head_length: float = 2,
    shaft_ratio: float = 0.5,
    **kwargs
) -> None

Plot arrow

PARAMETER DESCRIPTION
start

Start position (x coordinate)

TYPE: float

end

End position (x coordinate)

TYPE: float

r_lim

Radius limit range. If None, track.r_lim is set.

TYPE: tuple[float, float] | None DEFAULT: None

head_length

Arrow head length (Degree unit)

TYPE: float DEFAULT: 2

shaft_ratio

Arrow shaft ratio (0 - 1.0)

TYPE: float DEFAULT: 0.5

**kwargs

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

TYPE: dict DEFAULT: {}

xticks

xticks(
    x: list[int] | list[float] | np.ndarray,
    labels: list[str] | None = None,
    *,
    tick_length: float = 2,
    outer: bool = True,
    show_bottom_line: bool = False,
    label_size: float = 8,
    label_margin: float = 0.5,
    label_orientation: str = "horizontal",
    line_kws: dict[str, Any] | None = None,
    text_kws: dict[str, Any] | None = None
) -> None

Plot xticks & labels on user-specified position

If you want to plot xticks and their position labels at regular intervals, it is recommended to use track.xticks_by_interval() instead.

PARAMETER DESCRIPTION
x

X coordinates

TYPE: list[int] | list[float] | ndarray

labels

Labels on xticks. If None, only plot ticks line.

TYPE: list[str] | None DEFAULT: None

tick_length

Tick length (Radius unit)

TYPE: float DEFAULT: 2

outer

If True, show ticks on outer. If False, show ticks on inner.

TYPE: bool DEFAULT: True

show_bottom_line

If True, show bottom line.

TYPE: bool DEFAULT: False

label_size

Label size

TYPE: float DEFAULT: 8

label_margin

Label margin size

TYPE: float DEFAULT: 0.5

label_orientation

Label orientation (horizontal or vertical)

TYPE: str DEFAULT: 'horizontal'

line_kws

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

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

text_kws

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

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

xticks_by_interval

xticks_by_interval(
    interval: int | float,
    *,
    tick_length: float = 2,
    outer: bool = True,
    show_bottom_line: bool = False,
    show_label: bool = True,
    show_endlabel: bool = True,
    label_size: float = 8,
    label_margin: float = 0.5,
    label_orientation: str = "horizontal",
    label_formatter: Callable[[float], str] | None = None,
    line_kws: dict[str, Any] | None = None,
    text_kws: dict[str, Any] | None = None
) -> None

Plot xticks & position labels by user-specified interval

track.xticks_by_interval() is high-level API function of track.xticks(). If you want to plot xticks and their labels in any position you like, use track.xticks() instead.

PARAMETER DESCRIPTION
interval

Xticks interval

TYPE: int | float

tick_length

Tick length (Radius unit)

TYPE: float DEFAULT: 2

outer

If True, show ticks on outer. If False, show ticks on inner.

TYPE: bool DEFAULT: True

show_bottom_line

If True, show bottom line.

TYPE: bool DEFAULT: False

show_label

If True, show label of xticks interval position.

TYPE: bool DEFAULT: True

show_endlabel

If False, no display end xtick label. Used to prevent overlap of start-end xtick labels.

TYPE: bool DEFAULT: True

label_size

Label size

TYPE: float DEFAULT: 8

label_margin

Label margin size

TYPE: float DEFAULT: 0.5

label_orientation

Label orientation (horizontal or vertical)

TYPE: str DEFAULT: 'horizontal'

label_formatter

User-defined function for label format. (e.g. 1000 -> '1.0 Kb')

TYPE: Callable[[float], str] | None DEFAULT: None

line_kws

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

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

text_kws

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

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

yticks

yticks(
    y: list[int] | list[float] | np.ndarray,
    labels: list[str] | None = None,
    *,
    vmin: float = 0,
    vmax: float | None = None,
    side: str = "right",
    tick_length: float = 1,
    label_size: float = 8,
    label_margin: float = 0.5,
    line_kws: dict[str, Any] | None = None,
    text_kws: dict[str, Any] | None = None
) -> None

Plot yticks & labels on user-specified position

PARAMETER DESCRIPTION
y

Y coordinates

TYPE: list[int] | list[float] | ndarray

labels

Labels on yticks. If None, only plot ticks line.

TYPE: list[str] | None DEFAULT: None

vmin

Y min value

TYPE: float DEFAULT: 0

vmax

Y max value. If None, max(y) is set.

TYPE: float | None DEFAULT: None

side

Ticks side position (right or left)

TYPE: str DEFAULT: 'right'

tick_length

Tick length (Degree unit)

TYPE: float DEFAULT: 1

label_size

Label size

TYPE: float DEFAULT: 8

label_margin

Label margin size

TYPE: float DEFAULT: 0.5

line_kws

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

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

text_kws

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

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

grid

grid(y_grid_num: int | None = 6, x_grid_interval: float | None = None, **kwargs) -> None

Plot grid

By default, color="grey", alpha=0.5, zorder=0 line params are set.

PARAMETER DESCRIPTION
y_grid_num

Y-axis grid line number. If None, y-axis grid line is not shown.

TYPE: int | None DEFAULT: 6

x_grid_interval

X-axis grid line interval. If None, x-axis grid line is not shown.

TYPE: float | None DEFAULT: None

**kwargs

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

TYPE: dict DEFAULT: {}

line

line(
    x: list[float] | np.ndarray,
    y: list[float] | np.ndarray,
    *,
    vmin: float = 0,
    vmax: float | None = None,
    arc: bool = True,
    **kwargs
) -> None

Plot line

PARAMETER DESCRIPTION
x

X coordinates

TYPE: list[float] | ndarray

y

Y coordinates

TYPE: list[float] | ndarray

vmin

Y min value

TYPE: float DEFAULT: 0

vmax

Y max value. If None, max(y) is set.

TYPE: float | None DEFAULT: None

arc

If True, plot arc style line for polar projection. If False, simply plot linear style line.

TYPE: bool DEFAULT: True

**kwargs

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

TYPE: dict DEFAULT: {}

scatter

scatter(
    x: list[float] | np.ndarray,
    y: list[float] | np.ndarray,
    *,
    vmin: float = 0,
    vmax: float | None = None,
    **kwargs
) -> None

Plot scatter

PARAMETER DESCRIPTION
x

X position list

TYPE: list[float] | ndarray

y

Y position list

TYPE: list[float] | ndarray

vmin

Y min value

TYPE: float DEFAULT: 0

vmax

Y max value. If None, max(y) is set.

TYPE: float | None DEFAULT: None

**kwargs

Axes.scatter properties (e.g. ec="black", lw=1.0, ...) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.scatter.html

TYPE: dict DEFAULT: {}

bar

bar(
    x: list[float] | np.ndarray,
    height: list[float] | np.ndarray,
    width: float = 0.8,
    bottom: float | list[float] | np.ndarray = 0,
    align: str = "center",
    *,
    vmin: float = 0,
    vmax: float | None = None,
    **kwargs
) -> None

Plot bar

PARAMETER DESCRIPTION
x

Bar x coordinates

TYPE: list[float] | ndarray

height

Bar heights

TYPE: list[float] | ndarray

width

Bar width

TYPE: float DEFAULT: 0.8

bottom

Bar bottom(s)

TYPE: float | ndarray DEFAULT: 0

align

Bar alignment type (center or edge)

TYPE: str DEFAULT: 'center'

vmin

Y min value

TYPE: float DEFAULT: 0

vmax

Y max value. If None, np.max(height + bottom) is set.

TYPE: float | None DEFAULT: None

**kwargs

Axes.bar properties (e.g. color="tomato", ec="black", lw=0.5, hatch="//") https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.bar.html

TYPE: dict DEFAULT: {}

stacked_bar

stacked_bar(
    table_data: str | Path | pd.DataFrame | StackedBarTable,
    *,
    delimiter: str = "\t",
    width: float = 0.6,
    cmap: str | dict[str, str] = "tab10",
    vmax: float | None = None,
    show_label: bool = True,
    label_pos: str = "bottom",
    label_margin: float = 2,
    bar_kws: dict[str, Any] | None = None,
    label_kws: dict[str, Any] | None = None
) -> StackedBarTable

Plot stacked bar from table data

PARAMETER DESCRIPTION
table_data

Table file or Table DataFrame or StackedBarTable

TYPE: str | Path | DataFrame | StackedBarTable

delimiter

Table file delimiter

TYPE: str DEFAULT: '\t'

width

Bar width ratio (0.0 - 1.0)

TYPE: float DEFAULT: 0.6

cmap

Colormap assigned to each stacked bar. User can set matplotlib's colormap (e.g. tab10, Set3) or col_name -> color dict (e.g. dict(A="red", B="blue", C="green", ...))

TYPE: str | dict[str, str] DEFAULT: 'tab10'

vmax

Stacked bar max value. If None, max value in each row values sum is set.

TYPE: float | None DEFAULT: None

show_label

Show table row names as labels

TYPE: bool DEFAULT: True

label_pos

Label position (bottom|top)

TYPE: str DEFAULT: 'bottom'

label_margin

Label margin size

TYPE: float DEFAULT: 2

bar_kws

Axes.bar properties (e.g. dict(ec="black", lw=0.5, hatch="//", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.bar.html

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

label_kws

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

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

RETURNS DESCRIPTION
sb_table

Stacked bar table

TYPE: StackedBarTable

stacked_barh

stacked_barh(
    table_data: str | Path | pd.DataFrame | StackedBarTable,
    *,
    delimiter: str = "\t",
    width: float = 0.6,
    cmap: str | dict[str, str] = "tab10",
    bar_kws: dict[str, Any] | None = None
) -> StackedBarTable

Plot horizontal stacked bar from table data

PARAMETER DESCRIPTION
table_data

Table file or Table DataFrame or StackedBarTable

TYPE: str | Path | DataFrame | StackedBarTable

delimiter

Table file delimiter

TYPE: str DEFAULT: '\t'

width

Bar width ratio (0.0 - 1.0)

TYPE: float DEFAULT: 0.6

cmap

Colormap assigned to each stacked bar. User can set matplotlib's colormap (e.g. tab10, Set3) or col_name -> color dict (e.g. dict(A="red", B="blue", C="green", ...))

TYPE: str | dict[str, str] DEFAULT: 'tab10'

bar_kws

Patch properties for bar plot (e.g. dict(ec="black, lw=0.2, ...))

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

RETURNS DESCRIPTION
sb_table

Stacked bar table

TYPE: StackedBarTable

fill_between

fill_between(
    x: list[float] | np.ndarray,
    y1: list[float] | np.ndarray,
    y2: float | list[float] | np.ndarray = 0,
    *,
    vmin: float = 0,
    vmax: float | None = None,
    arc: bool = True,
    **kwargs
) -> None

Fill the area between two horizontal(y1, y2) curves

PARAMETER DESCRIPTION
x

X coordinates

TYPE: list[float] | ndarray

y1

Y coordinates (first curve definition)

TYPE: list[float] | ndarray

y2

Y coordinate[s] (second curve definition)

TYPE: float | list[float] | ndarray DEFAULT: 0

vmin

Y min value

TYPE: float DEFAULT: 0

vmax

Y max value. If None, max(y1 + y2) is set.

TYPE: float | None DEFAULT: None

arc

If True, plot arc style line for polar projection. If False, simply plot linear style line.

TYPE: bool DEFAULT: True

**kwargs

Axes.fill_between properties (e.g. fc="red", ec="black", lw=0.1, ...) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.fill_between.html

TYPE: dict DEFAULT: {}

heatmap

heatmap(
    data: list | np.ndarray,
    *,
    vmin: float | None = None,
    vmax: float | None = None,
    start: float | None = None,
    end: float | None = None,
    width: float | None = None,
    cmap: str | Colormap = "bwr",
    show_value: bool = False,
    rect_kws: dict[str, Any] | None = None,
    text_kws: dict[str, Any] | None = None
) -> None

Plot heatmap

PARAMETER DESCRIPTION
data

Numerical list, numpy 1d or 2d array

TYPE: list | ndarray

vmin

Min value for heatmap plot. If None, np.min(data) is set.

TYPE: float | None DEFAULT: None

vmax

Max value for heatmap plot. If None, np.max(data) is set.

TYPE: float | None DEFAULT: None

start

Start position for heatmap plot (x coordinate). If None, track.start is set.

TYPE: float | None DEFAULT: None

end

End position for heatmap plot (x coordinate). If None, track.end is set.

TYPE: float | None DEFAULT: None

width

Heatmap rectangle x width size. Normally heatmap plots squares of equal width. In some cases, it is necessary to reduce the width of only the last column data square. At that time, width can be set under the following conditions. (col_num - 1) * width < end - start < col_num * width

TYPE: float | None DEFAULT: None

cmap

Colormap (e.g. viridis, Spectral, Reds, Greys) https://matplotlib.org/stable/tutorials/colors/colormaps.html

TYPE: str | Colormap DEFAULT: 'bwr'

show_value

If True, show data value on heatmap rectangle

TYPE: bool DEFAULT: False

rect_kws

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

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

text_kws

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

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

tree

tree(
    tree_data: str | Path | Tree,
    *,
    format: str = "newick",
    outer: bool = True,
    align_leaf_label: bool = True,
    ignore_branch_length: bool = False,
    leaf_label_size: float = 12,
    leaf_label_rmargin: float = 2.0,
    reverse: bool = False,
    ladderize: bool = False,
    line_kws: dict[str, Any] | None = None,
    align_line_kws: dict[str, Any] | None = None,
    label_formatter: Callable[[str], str] | None = None
) -> TreeViz

Plot tree

It is recommended that the track(sector) size be the same as the number of leaf nodes in the tree, to make it easier to combine with bar and heatmap.

PARAMETER DESCRIPTION
tree_data

Tree data (File|File URL|Tree Object|Tree String)

TYPE: str | Path | Tree

format

Tree format (newick|phyloxml|nexus|nexml|cdao)

TYPE: str DEFAULT: 'newick'

outer

If True, plot tree on outer side. If False, plot tree on inner side.

TYPE: bool DEFAULT: True

align_leaf_label

If True, align leaf label.

TYPE: bool DEFAULT: True

ignore_branch_length

If True, ignore branch length for plotting tree.

TYPE: bool DEFAULT: False

leaf_label_size

Leaf label size

TYPE: float DEFAULT: 12

leaf_label_rmargin

Leaf label radius margin

TYPE: float DEFAULT: 2.0

reverse

If True, reverse tree

TYPE: bool DEFAULT: False

ladderize

If True, ladderize tree

TYPE: bool DEFAULT: False

line_kws

Patch properties (e.g. dict(color="red", lw=1, ls="dashed", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

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

align_line_kws

Patch properties (e.g. dict(lw=1, ls="dotted", alpha=1.0, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

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

label_formatter

User-defined label text format function to change plot label text content. For example, if you want to change underscore of the label to space, set lambda t: t.replace("_", " ").

TYPE: Callable[[str], str] | None DEFAULT: None

RETURNS DESCRIPTION
tv

TreeViz instance

TYPE: TreeViz

genomic_features

genomic_features(
    features: SeqFeature | list[SeqFeature],
    *,
    plotstyle: str = "box",
    r_lim: tuple[float, float] | None = None,
    facecolor_handler: Callable[[SeqFeature], str] | None = None,
    **kwargs
) -> None

Plot genomic features

PARAMETER DESCRIPTION
features

Biopython's SeqFeature or SeqFeature list

TYPE: SeqFeature | list[SeqFeature]

plotstyle

Plot style (box or arrow)

TYPE: str DEFAULT: 'box'

r_lim

Radius limit range. If None, track.r_plot_lim is set.

TYPE: tuple[float, float] | None DEFAULT: None

facecolor_handler

User-defined function to handle facecolor

TYPE: Callable[[SeqFeature], str] | None DEFAULT: None

**kwargs

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

TYPE: dict DEFAULT: {}