Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ X9,0.7232472324723247,0.7352941176470589,...,0.8066914498141264,0.0

|[Stacked Barplot](https://github.com/PopovIILab/KrakenParser/wiki/Stacked-Barplot-API)|[Streamgraph](https://github.com/PopovIILab/KrakenParser/wiki/Streamgraph-API)|
|-------|-------|
|![kpstbar](https://github.com/user-attachments/assets/916b0164-28be-4f49-9634-707408487b85)|![kpstream](https://github.com/user-attachments/assets/5c6d930c-e85f-4e2e-9dbf-8caefca49a76)|
|![kpstbar](https://github.com/user-attachments/assets/916b0164-28be-4f49-9634-707408487b85)|![kpstream](https://github.com/user-attachments/assets/8fc09fdb-e397-4c39-9290-ad11da5335a8)|

[Stacked Barplot + Streamgraph](https://github.com/PopovIILab/KrakenParser/wiki/Combined-Stacked-Barplot-&-Streamgraph)|[Clustermap](https://github.com/PopovIILab/KrakenParser/wiki/Clustermap)|
|-------|-------|
|![combined_white](https://github.com/user-attachments/assets/58acea93-f079-46fd-ac4b-d2ac83098c59)|![kpclust](https://github.com/user-attachments/assets/98a4d540-7c43-4802-8f77-277a5637a7a1)|
|![combined_white](https://github.com/user-attachments/assets/48b3f6e3-6dd5-4298-a793-23dcd549e90c)|![kpclust](https://github.com/user-attachments/assets/98a4d540-7c43-4802-8f77-277a5637a7a1)|

## Quick Start (Full Pipeline)
To run the full pipeline, use the following command:
Expand Down Expand Up @@ -263,10 +263,10 @@ data/
│ │ ├─ counts_family.txt
│ │ ├─ ...
│ └─ csv/ # Total abundance CSV output
├─ counts_species.csv
├─ counts_genus.csv
├─ counts_family.csv
├─ ...
├─ counts_species.csv
├─ counts_genus.csv
├─ counts_family.csv
├─ ...
├─ rel_abund/ # Relative abundance CSV output
│ ├─ ra_species.csv
│ ├─ ra_genus.csv
Expand Down
12 changes: 8 additions & 4 deletions krakenparser/kpplot/streamgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def streamgraph(
sample_order: Optional[List[str]] = None,
figsize: Tuple[int, int] = (14, 7),
cmap: Optional[Union[str, List[str]]] = "tab20",
bar_width: float = 0.6,
fill_alpha: float = 1.0,
edgecolor: Optional[str] = None,
edge_linewidth: float = 0.3,
Expand Down Expand Up @@ -137,11 +138,15 @@ def streamgraph(

colors = [color_dict[col] for col in df_plot.columns]

centers = np.arange(len(df_plot.index))
xs = np.column_stack((centers - bar_width / 2, centers + bar_width / 2)).flatten()

fig, ax = plt.subplots(figsize=figsize, facecolor=background_color)

ys = np.repeat(df_plot.values.T, 2, axis=1)
layers = ax.stackplot(
df_plot.index,
df_plot.values.T,
xs,
ys,
labels=df_plot.columns,
colors=colors,
alpha=fill_alpha,
Expand Down Expand Up @@ -187,10 +192,9 @@ def streamgraph(
if grid:
ax.grid(axis="x", linestyle=grid_linestyle, alpha=grid_alpha, zorder=0)

positions = np.arange(len(df_plot.index))
labels = df_plot.index.tolist()
plt.xticks(
positions,
centers,
labels,
rotation=xticks_rotation,
ha=xticks_ha,
Expand Down
2 changes: 1 addition & 1 deletion krakenparser/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.0"
__version__ = "0.6.1"