diff --git a/README.md b/README.md index 308916b..8a848c7 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/krakenparser/kpplot/streamgraph.py b/krakenparser/kpplot/streamgraph.py index e7650a4..ac82e46 100644 --- a/krakenparser/kpplot/streamgraph.py +++ b/krakenparser/kpplot/streamgraph.py @@ -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, @@ -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, @@ -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, diff --git a/krakenparser/version.py b/krakenparser/version.py index 906d362..43c4ab0 100755 --- a/krakenparser/version.py +++ b/krakenparser/version.py @@ -1 +1 @@ -__version__ = "0.6.0" +__version__ = "0.6.1"