Circos Class
Circos
Circos(
sectors: Mapping[str, int | float | tuple[float, float]],
start: float = 0,
end: float = 360,
*,
space: float | list[float] = 0,
endspace: bool = True,
sector2clockwise: dict[str, bool] | None = None,
show_axis_for_debug: bool = False
)
Circos Visualization Class
PARAMETER | DESCRIPTION |
---|---|
sectors |
Sector name & size (or range) dict
TYPE:
|
start |
Plot start degree (
TYPE:
|
end |
Plot end degree (
TYPE:
|
space |
Space degree(s) between sector
TYPE:
|
endspace |
If True, insert space after the end sector
TYPE:
|
sector2clockwise |
Sector name & clockwise bool dict. By default,
TYPE:
|
show_axis_for_debug |
Show axis for position check debugging (Developer option)
TYPE:
|
ax
property
Plot polar axes
Can't access ax
property before calling circos.plotfig()
method
radar_chart
staticmethod
radar_chart(
table: str | Path | pd.DataFrame | RadarTable,
*,
r_lim: tuple[float, float] = (0, 100),
vmin: float = 0,
vmax: float = 100,
fill: bool = True,
marker_size: int = 0,
bg_color: str | None = "#eeeeee80",
circular: bool = False,
cmap: str | dict[str, str] = "Set2",
show_grid_label: bool = True,
grid_interval_ratio: float | None = 0.2,
grid_line_kws: dict[str, Any] | None = None,
grid_label_kws: dict[str, Any] | None = None,
grid_label_formatter: Callable[[float], str] | None = None,
label_kws_handler: Callable[[str], dict[str, Any]] | None = None,
line_kws_handler: Callable[[str], dict[str, Any]] | None = None,
marker_kws_handler: Callable[[str], dict[str, Any]] | None = None
) -> Circos
Plot radar chart
PARAMETER | DESCRIPTION |
---|---|
table |
Table file or Table dataframe or RadarTable instance
TYPE:
|
r_lim |
Radar chart radius limit region (0 - 100)
TYPE:
|
vmin |
Min value
TYPE:
|
vmax |
Max value
TYPE:
|
fill |
If True, fill color of radar chart.
TYPE:
|
marker_size |
Marker size
TYPE:
|
bg_color |
Background color
TYPE:
|
circular |
If True, plot with circular style.
TYPE:
|
cmap |
Colormap assigned to each target row(index) in table.
User can set matplotlib's colormap (e.g.
TYPE:
|
show_grid_label |
If True, show grid label.
TYPE:
|
grid_interval_ratio |
Grid interval ratio (0.0 - 1.0)
TYPE:
|
grid_line_kws |
Keyword arguments passed to
TYPE:
|
grid_label_kws |
Keyword arguments passed to
TYPE:
|
grid_label_formatter |
User-defined function to format grid label (e.g.
TYPE:
|
label_kws_handler |
Handler function for keyword arguments passed to
TYPE:
|
line_kws_handler |
Handler function for keyword arguments passed to
TYPE:
|
marker_kws_handler |
Handler function for keyword arguments passed to
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
circos
|
Circos instance initialized for radar chart
TYPE:
|
initialize_from_matrix
staticmethod
initialize_from_matrix(
matrix: str | Path | pd.DataFrame | Matrix,
*,
start: float = 0,
end: float = 360,
space: float | list[float] = 0,
endspace: bool = True,
r_lim: tuple[float, float] = (97, 100),
cmap: str | dict[str, str] = "viridis",
link_cmap: list[tuple[str, str, str]] | None = None,
ticks_interval: int | None = None,
order: str | list[str] | None = None,
label_kws: dict[str, Any] | None = None,
ticks_kws: dict[str, Any] | None = None,
link_kws: dict[str, Any] | None = None,
link_kws_handler: Callable[[str, str], dict[str, Any] | None] | None = None
) -> Circos
Initialize Circos instance from Matrix
Circos tracks and links are auto-defined by Matrix (For plotting Chord Diagram)
PARAMETER | DESCRIPTION |
---|---|
matrix |
Matrix file or Matrix dataframe or Matrix instance
TYPE:
|
start |
Plot start degree (-360 <= start < end <= 360)
TYPE:
|
end |
Plot end degree (-360 <= start < end <= 360)
TYPE:
|
space |
Space degree(s) between sector
TYPE:
|
endspace |
If True, insert space after the end sector
TYPE:
|
r_lim |
Outer track radius limit region (0 - 100)
TYPE:
|
cmap |
Colormap assigned to each outer track and link.
User can set matplotlib's colormap (e.g.
TYPE:
|
link_cmap |
Link colormap to overwrite link colors automatically set by cmap.
User can set list of
TYPE:
|
ticks_interval |
Ticks interval. If None, ticks are not plotted.
TYPE:
|
order |
Sort order of matrix for plotting Chord Diagram. If
TYPE:
|
label_kws |
Keyword arguments passed to
TYPE:
|
ticks_kws |
Keyword arguments passed to
TYPE:
|
link_kws |
Keyword arguments passed to
TYPE:
|
link_kws_handler |
User-defined function to handle keyword arguments for each link.
This option allows user to set or override properties such as
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
circos
|
Circos instance initialized from Matrix
TYPE:
|
initialize_from_tree
staticmethod
initialize_from_tree(
tree_data: str | Path | Tree,
*,
start: float = 0,
end: float = 360,
r_lim: tuple[float, float] = (50, 100),
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,
label_formatter: Callable[[str], str] | None = None,
align_line_kws: dict[str, Any] | None = None
) -> tuple[Circos, TreeViz]
Initialize Circos instance from phylogenetic tree
Circos sector and track are auto-defined by phylogenetic tree
PARAMETER | DESCRIPTION |
---|---|
tree_data |
Tree data (
TYPE:
|
start |
Plot start degree (-360 <= start < end <= 360)
TYPE:
|
end |
Plot end degree (-360 <= start < end <= 360)
TYPE:
|
r_lim |
Tree track radius limit region (0 - 100)
TYPE:
|
format |
Tree format (
TYPE:
|
outer |
If True, plot tree on outer side. If False, plot tree on inner side.
TYPE:
|
align_leaf_label |
If True, align leaf label.
TYPE:
|
ignore_branch_length |
If True, ignore branch length for plotting tree.
TYPE:
|
leaf_label_size |
Leaf label size
TYPE:
|
leaf_label_rmargin |
Leaf label radius margin
TYPE:
|
reverse |
If True, reverse tree
TYPE:
|
ladderize |
If True, ladderize tree
TYPE:
|
line_kws |
Patch properties (e.g.
TYPE:
|
align_line_kws |
Patch properties (e.g.
TYPE:
|
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
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
circos
|
Circos instance
TYPE:
|
tv
|
TreeViz instance
TYPE:
|
initialize_from_bed
staticmethod
initialize_from_bed(
bed_file: str | Path,
start: float = 0,
end: float = 360,
*,
space: float | list[float] = 0,
endspace: bool = True,
sector2clockwise: dict[str, bool] | None = None
) -> Circos
Initialize Circos instance from BED file
Circos sectors are auto-defined by BED chromosomes
PARAMETER | DESCRIPTION |
---|---|
bed_file |
Chromosome BED format file (zero-based coordinate)
TYPE:
|
start |
Plot start degree (-360 <= start < end <= 360)
TYPE:
|
end |
Plot end degree (-360 <= start < end <= 360)
TYPE:
|
space |
Space degree(s) between sector
TYPE:
|
endspace |
If True, insert space after the end sector
TYPE:
|
sector2clockwise |
Sector name & clockwise bool dict. By default,
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
circos
|
Circos instance initialized from BED file
TYPE:
|
add_cytoband_tracks
add_cytoband_tracks(
r_lim: tuple[float, float],
cytoband_file: str | Path,
*,
track_name: str = "cytoband",
cytoband_cmap: dict[str, str] | None = None
) -> None
Add track & plot chromosome cytoband on each sector
PARAMETER | DESCRIPTION |
---|---|
r_lim |
Radius limit region (0 - 100)
TYPE:
|
cytoband_file |
Cytoband tsv file (UCSC format)
TYPE:
|
track_name |
Cytoband track name. By default,
TYPE:
|
cytoband_cmap |
User-defined cytoband colormap. If None, use Circos style colormap.
(e.g.
TYPE:
|
get_sector
Get sector by name
PARAMETER | DESCRIPTION |
---|---|
name |
Sector name
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
sector
|
Sector
TYPE:
|
get_group_sectors_deg_lim
Get degree min-max limit in target group sectors
PARAMETER | DESCRIPTION |
---|---|
group_sector_names |
Group sector names
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
group_sectors_deg_lim
|
Degree limit in group sectors
TYPE:
|
axis
Plot axis
By default, simple black axis params(fc="none", ec="black", lw=0.5
) are set.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
Patch properties (e.g.
TYPE:
|
text
text(
text: str,
*,
r: float = 0,
deg: float = 0,
adjust_rotation: bool = False,
orientation: str = "horizontal",
**kwargs
) -> None
Plot text
PARAMETER | DESCRIPTION |
---|---|
text |
Text content
TYPE:
|
r |
Radius position
TYPE:
|
deg |
Degree position (0 - 360)
TYPE:
|
adjust_rotation |
If True, text rotation is auto set based on
TYPE:
|
orientation |
Text orientation (
TYPE:
|
**kwargs |
Text properties (e.g.
TYPE:
|
line
line(
*,
r: float | tuple[float, float],
deg_lim: tuple[float, float] | None = None,
arc: bool = True,
**kwargs
) -> None
Plot line
PARAMETER | DESCRIPTION |
---|---|
r |
Line radius position (0 - 100). If r is float, (r, r) is set.
TYPE:
|
deg_lim |
Degree limit region (-360 - 360). If None,
TYPE:
|
arc |
If True, plot arc style line for polar projection. If False, simply plot linear style line.
TYPE:
|
**kwargs |
Patch properties (e.g.
TYPE:
|
rect
rect(
r_lim: tuple[float, float] = (0, 100),
deg_lim: tuple[float, float] | None = None,
**kwargs
) -> None
Plot rectangle
PARAMETER | DESCRIPTION |
---|---|
r_lim |
Radius limit region (0 - 100)
TYPE:
|
deg_lim |
Degree limit region (-360 - 360). If None,
TYPE:
|
**kwargs |
Patch properties (e.g.
TYPE:
|
link
link(
sector_region1: tuple[str, float, float],
sector_region2: tuple[str, float, float],
r1: float | None = None,
r2: float | None = None,
*,
color: str = "grey",
alpha: float = 0.5,
height_ratio: float = 0.5,
direction: int = 0,
arrow_length_ratio: float = 0.05,
allow_twist: bool = True,
**kwargs
) -> None
Plot link to specified region within or between sectors
PARAMETER | DESCRIPTION |
---|---|
sector_region1 |
Link sector region1 (name, start, end)
TYPE:
|
sector_region2 |
Link sector region2 (name, start, end)
TYPE:
|
r1 |
Link radius end position for sector_region1. If None, lowest radius position of track in target sector is set.
TYPE:
|
r2 |
Link radius end position for sector_region2. If None, lowest radius position of track in target sector is set.
TYPE:
|
color |
Link color
TYPE:
|
alpha |
Link color alpha (transparency) value
TYPE:
|
height_ratio |
Bezier curve height ratio
TYPE:
|
direction |
TYPE:
|
arrow_length_ratio |
Direction arrow length ratio
TYPE:
|
allow_twist |
If False, twisted link is automatically resolved. http://circos.ca/documentation/tutorials/links/twists/images
TYPE:
|
**kwargs |
Patch properties (e.g.
TYPE:
|
link_line
link_line(
sector_pos1: tuple[str, float],
sector_pos2: tuple[str, float],
r1: float | None = None,
r2: float | None = None,
*,
color: str = "black",
height_ratio: float = 0.5,
direction: int = 0,
arrow_height: float = 3.0,
arrow_width: float = 2.0,
**kwargs
) -> None
Plot link line to specified position within or between sectors
PARAMETER | DESCRIPTION |
---|---|
sector_pos1 |
Link line sector position1 (name, position)
TYPE:
|
sector_pos2 |
Link line sector position2 (name, position)
TYPE:
|
r1 |
Link line radius end position for sector_pos1. If None, lowest radius position of track in target sector is set.
TYPE:
|
r2 |
Link line radius end position for sector_pos2. If None, lowest radius position of track in target sector is set.
TYPE:
|
color |
Link line color
TYPE:
|
height_ratio |
Bezier curve height ratio
TYPE:
|
direction |
TYPE:
|
arrow_height |
Arrow height size (Radius unit)
TYPE:
|
arrow_width |
Arrow width size (Degree unit)
TYPE:
|
**kwargs |
Patch properties (e.g.
TYPE:
|
colorbar
colorbar(
bounds: tuple[float, float, float, float] = (1.02, 0.3, 0.02, 0.4),
*,
vmin: float = 0,
vmax: float = 1,
cmap: str | Colormap = "bwr",
orientation: str = "vertical",
label: str | None = None,
colorbar_kws: dict[str, Any] | None = None,
label_kws: dict[str, Any] | None = None,
tick_kws: dict[str, Any] | None = None
) -> None
Plot colorbar
PARAMETER | DESCRIPTION |
---|---|
bounds |
Colorbar bounds tuple (
TYPE:
|
vmin |
Colorbar min value
TYPE:
|
vmax |
Colorbar max value
TYPE:
|
cmap |
Colormap (e.g.
TYPE:
|
orientation |
Colorbar orientation (
TYPE:
|
label |
Colorbar label. If None, no label shown.
TYPE:
|
colorbar_kws |
Colorbar properties (e.g.
TYPE:
|
label_kws |
Text properties (e.g.
TYPE:
|
tick_kws |
Axes.tick_params properties (e.g.
TYPE:
|
plotfig
plotfig(
dpi: int = 100, *, ax: PolarAxes | None = None, figsize: tuple[float, float] = (8, 8)
) -> Figure
Plot figure
PARAMETER | DESCRIPTION |
---|---|
dpi |
Figure DPI
TYPE:
|
ax |
If None, figure and axes are newly created.
TYPE:
|
figsize |
Figure size
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
figure
|
Circos matplotlib figure
TYPE:
|
savefig
savefig(
savefile: str | Path,
*,
dpi: int = 100,
figsize: tuple[float, float] = (8, 8),
pad_inches: float = 0.5
) -> None
Save figure to file
PARAMETER | DESCRIPTION |
---|---|
savefile |
Save file (
TYPE:
|
dpi |
DPI
TYPE:
|
figsize |
Figure size
TYPE:
|
pad_inches |
Padding inches
TYPE:
|
Warnings
To plot a figure that settings a user-defined legend, subtracks, or annotations,
call fig.savefig()
instead of gv.savefig()
.