-
Notifications
You must be signed in to change notification settings - Fork 4
Radarplot API
Ilia Popov edited this page May 7, 2025
·
5 revisions
This API provides a function to create a radar plot from KEGGaNOG multi-sample output. It visualizes completeness values of selected pathways across multiple samples in a circular (radial) format.
radarplot(df, pathways, ...)
| PARAMETER | DESCRIPTION |
|---|---|
df |
Input data as a pandas DataFrame TYPE: pd.DataFrame
|
pathways |
List of pathway names to include in the radar plot TYPE: List[str]
|
figsize |
Size of the figure (width, height) TYPE: Tuple[int, int]DEFAULT: (8, 8)
|
colors |
List of colors for the samples TYPE: List[str] or NoneDEFAULT: None
|
sample_order |
Custom order of sample names TYPE: List[str] or NoneDEFAULT: None
|
title |
Plot title TYPE: str or NoneDEFAULT: None
|
title_fontsize |
Font size of title TYPE: floatDEFAULT: 14.0
|
title_color |
Font color of title TYPE: strDEFAULT: "black"
|
title_weight |
Font weight of title TYPE: strDEFAULT: "normal"
|
title_style |
Font style of title TYPE: strDEFAULT: "normal"
|
title_y |
Vertical alignment of the title TYPE: floatDEFAULT: 1.1
|
label_fontsize |
Font size of axis labels (pathways) TYPE: floatDEFAULT: 10.0
|
label_color |
Font color of axis labels TYPE: strDEFAULT: "black"
|
label_weight |
Font weight of axis labels TYPE: strDEFAULT: "normal"
|
label_style |
Font style of axis labels TYPE: strDEFAULT: "normal"
|
label_background |
Background color of axis labels TYPE: str or NoneDEFAULT: None
|
label_edgecolor |
Edge color of axis label boxes TYPE: str or NoneDEFAULT: None
|
label_pad |
Padding for labels TYPE: floatDEFAULT: 1.05
|
ytick_fontsize |
Font size of radial axis ticks TYPE: floatDEFAULT: 8.0
|
ytick_color |
Font color of radial axis ticks TYPE: strDEFAULT: "black"
|
ytick_weight |
Font weight of radial axis ticks TYPE: strDEFAULT: "normal"
|
ytick_alpha |
Alpha (opacity) of radial ticks TYPE: floatDEFAULT: 0.5
|
yticklabels |
Custom labels for radial axis ticks TYPE: List[str] or NoneDEFAULT: None
|
fill_alpha |
Transparency of the filled area TYPE: floatDEFAULT: 0.2
|
line_width |
Line width of radar plot borders TYPE: floatDEFAULT: 2.0
|
line_style |
Line style TYPE: strDEFAULT: "-"
|
legend_loc |
Legend position keyword TYPE: strDEFAULT: "upper right"
|
legend_bbox |
Manual legend box anchor TYPE: Tuple[float, float] or NoneDEFAULT: None
|
show_legend |
Whether to display legend TYPE: boolDEFAULT: True
|
background_color |
Background color of the figure TYPE: str or NoneDEFAULT: None
|
Returns an object with:
-
fig: the Matplotlib figure object -
ax: the Matplotlib axis object
The object includes .plotfig() and .savefig() methods for convenience.
First, run KEGGaNOG in multi-sample mode:
Where to get demo data? Here
! KEGGaNOG -M -i demo_data/listFile.txt -o KEGGaNOG_multi_output
Then you can build a radar plot of selected pathways across samples:
import kegganog as kgn
import pandas as pd
df = pd.read_csv("KEGGaNOG_multi_output/merged_pathways.tsv", sep="\t")
# List of pathways to visualize
pathways = ["Glycolysis", "Chemotaxis", "Cobalamin biosynthesis"]
# Order of samples on radar plot
sample_order = ["SoCe", "PsePu", "CloAce", "BaSu", "MeRu", "AciSa", "StaCa", "LaPla", "BaThe", "TheMa"]
kgnradar = kgn.radarplot(
df,
pathways=pathways,
sample_order=sample_order,
label_weight="bold",
label_background="white",
label_edgecolor="black",
label_pad=1.15,
colors=["#1f77b4", "#2ca02c", "#ff7f0e"],
yticklabels=["0.2", "", "0.6", "", "1.0"],
fill_alpha=0.15
)
# Show the figure
kgnradar.plotfig()Sample output:

To save the plot:
kgnradar.savefig("pic_name.png", dpi=600)