-
Notifications
You must be signed in to change notification settings - Fork 4
Heatmap API
This API generates a heatmap from KEGGaNOG output, with optional grouping.
If user is not happy with default KEGGaNOG's heatmap — user can adjust some parameters!
For now the main usability for heatmap() function is:
- Setting difficult sample name in
KEGGaNOG'ssinglemode - Reordering samples on heatmap in
KEGGaNOG'smultimode - Using different figure size in any mode
heatmap() function automatically understands if input data frame is single sample or multi sample
Heatmap APIis under development — more features coming soon
heatmap(df, ...)
| PARAMETER | DESCRIPTION |
|---|---|
df |
Input data as a pandas DataFrame TYPE: pd.DataFrame
|
figsize |
Size of the heatmap figure (width, height) TYPE: Tuple[int, int]DEFAULT: (10, 10)
|
color |
Colormap name TYPE: strDEFAULT: "Blues"
|
group |
Enable grouped heatmap layout TYPE: boolDEFAULT: False
|
sample_name |
Name of a single sample to create per-sample heatmap (used in single mode only)TYPE: str or NoneDEFAULT: None
|
annot |
Annotate cells with values (used in single mode only)TYPE: boolDEFAULT: False
|
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 single-sample mode:
Where to get demo data? Here
! KEGGaNOG -i demo_data/LaPla/LaPla.emapper.annotations -o KEGGaNOG_single_output
Then generate a full heatmap of pathway completeness
Now we can set the sample name comprehensively — using regular expressions
import kegganog as kgn
import pandas as pd
df = pd.read_csv("KEGGaNOG_single_output/SAMPLE_pathways.tsv", sep="\t")
kgnheat = kgn.heatmap(df, color="Greens", annot=False, sample_name="$\it{Lpb. plantarum}$ IS-10506")
# Show the figure
kgnheat.plotfig()Sample output:
For saving a plot please use:
kgnheat.savefig("pic_name.png", dpi=600)
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 generate a full heatmap of pathway completeness
kgn.heatmap() takes exactly the same order of samples as they are in input data frame
To change the order of samples on heatmap please change the order of columns in df
import kegganog as kgn
import pandas as pd
df = pd.read_csv("KEGGaNOG_multi_output/merged_pathways.tsv", sep="\t")
df = df[["Function", "StaCa", "BaSu", "TheMa", "PsePu", "AciSa", "MeRu", "CloAce", "LaPla", "SoCe", "BaThe"]]
kgnheat = kgn.heatmap(
df,
color="Greens",
group=False,
)
# Show the figure
kgnheat.plotfig()Sample output:
For saving a plot please use:
kgnheat.savefig("pic_name.png", dpi=600)