plastree 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
plastree-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BioSys_BUT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: plastree
3
+ Version: 0.1.0
4
+ Summary: Build plasmid phylogenetic trees from dotplot, pangenome presence/absence, and k-mer methods, with cluster detection.
5
+ Author: Helena Vitkova, Matej Bezdicek, Ema Holubova, Martina Lengerova
6
+ Author-email: Marketa Jakubickova <jakubickova@vut.cz>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/BioSys-BUT/PlasTree
9
+ Project-URL: Repository, https://github.com/BioSys-BUT/PlasTree
10
+ Project-URL: Issues, https://github.com/BioSys-BUT/PlasTree/issues
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: biopython==1.87
19
+ Requires-Dist: numpy==2.4.6
20
+ Requires-Dist: pandas==2.3.3
21
+ Requires-Dist: scipy==1.17.1
22
+ Requires-Dist: matplotlib==3.10.9
23
+ Dynamic: license-file
24
+
25
+ # PlasTree
26
+
27
+ A tree-based pipeline for clustering complete bacterial plasmids from long-read assemblies, combining structural, k-mer, and gene-content similarity into a single weighted consensus tree.
28
+
29
+ ![PlasTree overview](plastree_overview.png "PlasTree pipeline and an example consensus tree with color-coded clusters")
30
+
31
+ ## Overview
32
+
33
+ PlasTree integrates three complementary similarity methods, DotPloTree (pairwise dotplot-based structural similarity), KmerTree (ranked k-mer frequency similarity), and PanGTree (pangenome presence/absence similarity), and combines them into a single weighted consensus tree. Plasmids are then automatically grouped into clusters based on branch length and cluster size thresholds. PlasTree is intended for complete plasmid assemblies from long-read sequencing (e.g. Oxford Nanopore Technologies), where rearrangements, recombination, and accessory gene turnover can obscure relationships found by a single similarity measure.
34
+
35
+ ## Content
36
+
37
+ - [Key Features](#key-features)
38
+ - [Requirements](#requirements)
39
+ - [Installation](#installation)
40
+ - [Usage](#usage)
41
+ - [Parameters](#parameters)
42
+ - [Example](#example)
43
+ - [Output](#output)
44
+ - [Generating pangenome input (Bakta + Roary/Panaroo)](#generating-pangenome-input-bakta--roarypanaroo)
45
+ - [License](#license)
46
+ - [Citation](#citation)
47
+ - [Contact](#contact)
48
+
49
+ ## Key Features
50
+
51
+ - **Three independent tree-building methods**: DotPloTree (structural), KmerTree (nucleotide composition), and PanGTree (gene content, Roary or Panaroo format)
52
+ - **Weighted consensus tree** (3:2:1 DotPloTree:PanGTree:KmerTree) when two or more methods are combined
53
+ - **Automatic clustering** of plasmids by branch length, with support for multiple thresholds computed in a single run
54
+ - **Installable as a standard Python package**, exposing a single `plastree` command
55
+ - Optional PNG rendering of pairwise dotplots and the final cluster-colored consensus tree
56
+
57
+ ## Requirements
58
+
59
+ - Python 3.10+
60
+ - All other dependencies (Biopython, NumPy, Pandas, SciPy, Matplotlib) are installed automatically with the package.
61
+
62
+ ## Installation
63
+
64
+ First create an isolated environment named `plastree` (pick one option below), then install PlasTree into it.
65
+
66
+ **Option A: venv**
67
+ ```bash
68
+ python3 -m venv plastree
69
+ source plastree/bin/activate
70
+ pip install --upgrade pip
71
+ ```
72
+
73
+ **Option B: conda / miniforge**
74
+ ```bash
75
+ conda create -n plastree python=3.12
76
+ conda activate plastree
77
+ ```
78
+
79
+ With the environment active, install PlasTree directly from GitHub:
80
+ ```bash
81
+ pip install git+https://github.com/BioSys-BUT/PlasTree.git
82
+ ```
83
+
84
+ Or, if you want a local copy of the source:
85
+ ```bash
86
+ git clone https://github.com/BioSys-BUT/PlasTree.git
87
+ cd PlasTree
88
+ pip install .
89
+ ```
90
+
91
+ Verify the install:
92
+ ```bash
93
+ plastree --help
94
+ ```
95
+
96
+ ## Usage
97
+
98
+ ```bash
99
+ plastree --fasta <fasta_path> [--pang_format {roary,panaroo}] [--pang_csv <csv_path>] [--methods dotplot kmer pang] [--outdir <out_dir>] [--max_cluster_size <int>] [--max_branch_length <float> [<float> ...]] [--dotplot_window {19,22}] [--dotplot_threads <int>] [--dotplot_png] [--result_tree_png]
100
+ ```
101
+
102
+ ### Parameters
103
+
104
+ - `--fasta`: Path to a single FASTA file containing all plasmid sequences (one record per plasmid). **Required.**
105
+ - `--pang_format {roary,panaroo}`: Format of the pangenome CSV. Required when using `--methods pang`.
106
+ - `--pang_csv`: Path to the pangenome presence/absence CSV file. Required when using `--methods pang`.
107
+ - `--methods [dotplot pang kmer ...]`: Tree construction methods to apply. Default: `dotplot` only.
108
+ - `--outdir`: Directory to store output files. Default: `output`.
109
+ - `--max_cluster_size`: Maximum OTUs (plasmids) per cluster. Default: half the number of input sequences.
110
+ - `--max_branch_length`: Maximum allowed branch length within a cluster (0-1). Accepts one or more values (e.g. `0.1 0.2 0.05`); one cluster-assignment table is produced per value. Default: `0.2`.
111
+ - `--dotplot_window {19,22}`: Sliding window size for dotplot comparison. Default: `22`.
112
+ - `--dotplot_threads`: Number of parallel worker processes for dotplot pairwise distance computation. Default: `1`.
113
+ - `--dotplot_png`: Save pairwise dotplots as PNGs. Only for <=20 sequences. Default: off.
114
+ - `--result_tree_png`: Save the consensus tree as a PNG with node support and cluster coloring. Default: off.
115
+
116
+ ### Example
117
+
118
+ ```bash
119
+ plastree \
120
+ --fasta sequences.fasta \
121
+ --methods dotplot kmer pang \
122
+ --pang_format panaroo \
123
+ --pang_csv gene_presence_absence.csv \
124
+ --dotplot_window 22 \
125
+ --dotplot_threads 8 \
126
+ --max_cluster_size 30 \
127
+ --max_branch_length 0.05 0.1 0.2 0.4 \
128
+ --result_tree_png \
129
+ --outdir output
130
+ ```
131
+
132
+ with example data (8 small real plasmids from *Enterococcus faecium*, included in [`examples/`](examples)):
133
+ ```bash
134
+ plastree \
135
+ --fasta examples/plasmids.fasta \
136
+ --methods dotplot kmer pang \
137
+ --pang_format panaroo \
138
+ --pang_csv examples/gene_presence_absence.csv \
139
+ --result_tree_png \
140
+ --outdir examples/output
141
+ ```
142
+
143
+ ### Output
144
+
145
+ All output files are written to `--outdir`.
146
+
147
+ | File | Description |
148
+ |---|---|
149
+ | `dotplot_tree.newick` | DotPloTree structural similarity tree (`--methods dotplot`) |
150
+ | `dotplot_distmat.tsv` | DotPloTree distance matrix |
151
+ | `kmer_tree.newick` | KmerTree nucleotide composition tree (`--methods kmer`) |
152
+ | `kmer_distmat.tsv` | KmerTree distance matrix |
153
+ | `pang_tree.newick` | PanGTree gene content tree (`--methods pang`) |
154
+ | `pang_distmat.tsv` | PanGTree distance matrix |
155
+ | `consensus_tree.newick` | weighted consensus tree (only when 2+ methods are used) |
156
+ | `plasmid_clusters.tsv` | cluster assignment per plasmid (cluster 0 = outlier) |
157
+ | `cluster_tree.png` | consensus tree rendered with clusters color-coded (only with `--result_tree_png`) |
158
+
159
+ If multiple `--max_branch_length` values are given, `plasmid_clusters.tsv` and `cluster_tree.png` are produced once per threshold, suffixed with the value (dots replaced by underscores), e.g. `plasmid_clusters_bl0_2.tsv` and `cluster_tree_0_2.png` for threshold `0.2`.
160
+
161
+ ## Generating pangenome input (Bakta + Roary/Panaroo)
162
+
163
+ The `--pang_csv` file used by `--methods pang` is not produced by PlasTree itself. It comes from annotating the same plasmid FASTA files and clustering the predicted genes into orthologous groups, using external tools:
164
+
165
+ 1. Annotate each plasmid with [Bakta](https://github.com/oschwengers/bakta) (or another tool that outputs GFF3 annotations), producing one GFF3 file per plasmid.
166
+ 2. Collect all resulting GFF3 files into one directory.
167
+ 3. Run [Roary](https://sanger-pathogens.github.io/Roary/) and/or [Panaroo](https://github.com/gtonkinhill/panaroo) on the collected GFF3 files:
168
+ ```bash
169
+ roary *.gff3 -f roary_out
170
+ ```
171
+ ```bash
172
+ panaroo -i *.gff3 -o panaroo_out
173
+ ```
174
+
175
+ Both produce a `gene_presence_absence.csv`. Pass this file as `--pang_csv`, together with the matching `--pang_format roary` or `--pang_format panaroo`. See each tool's own documentation for annotation database setup, threading, and other options. Bakta, Roary, and Panaroo have their own, sometimes conflicting, dependencies, so it is common to install them into separate environments (e.g. separate conda environments).
176
+
177
+ ## License
178
+
179
+ See [LICENSE](LICENSE) for details (MIT).
180
+
181
+ ## Citation
182
+
183
+ The manuscript describing PlasTree is currently in submission. Until it is published, if you use PlasTree in your research, please cite this repository:
184
+
185
+ ```bibtex
186
+ @software{plastree2026,
187
+ title={PlasTree},
188
+ author={Vitkova, Helena and Jakubickova, Marketa and Bezdicek, Matej and Holubova, Ema and Lengerova, Martina},
189
+ year={2026},
190
+ url={https://github.com/BioSys-BUT/PlasTree}
191
+ }
192
+ ```
193
+
194
+ ## Contact
195
+
196
+ For questions and feedback, please open an issue on GitHub or contact us via email at [jakubickova@vut.cz](mailto:jakubickova@vut.cz).
@@ -0,0 +1,172 @@
1
+ # PlasTree
2
+
3
+ A tree-based pipeline for clustering complete bacterial plasmids from long-read assemblies, combining structural, k-mer, and gene-content similarity into a single weighted consensus tree.
4
+
5
+ ![PlasTree overview](plastree_overview.png "PlasTree pipeline and an example consensus tree with color-coded clusters")
6
+
7
+ ## Overview
8
+
9
+ PlasTree integrates three complementary similarity methods, DotPloTree (pairwise dotplot-based structural similarity), KmerTree (ranked k-mer frequency similarity), and PanGTree (pangenome presence/absence similarity), and combines them into a single weighted consensus tree. Plasmids are then automatically grouped into clusters based on branch length and cluster size thresholds. PlasTree is intended for complete plasmid assemblies from long-read sequencing (e.g. Oxford Nanopore Technologies), where rearrangements, recombination, and accessory gene turnover can obscure relationships found by a single similarity measure.
10
+
11
+ ## Content
12
+
13
+ - [Key Features](#key-features)
14
+ - [Requirements](#requirements)
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ - [Parameters](#parameters)
18
+ - [Example](#example)
19
+ - [Output](#output)
20
+ - [Generating pangenome input (Bakta + Roary/Panaroo)](#generating-pangenome-input-bakta--roarypanaroo)
21
+ - [License](#license)
22
+ - [Citation](#citation)
23
+ - [Contact](#contact)
24
+
25
+ ## Key Features
26
+
27
+ - **Three independent tree-building methods**: DotPloTree (structural), KmerTree (nucleotide composition), and PanGTree (gene content, Roary or Panaroo format)
28
+ - **Weighted consensus tree** (3:2:1 DotPloTree:PanGTree:KmerTree) when two or more methods are combined
29
+ - **Automatic clustering** of plasmids by branch length, with support for multiple thresholds computed in a single run
30
+ - **Installable as a standard Python package**, exposing a single `plastree` command
31
+ - Optional PNG rendering of pairwise dotplots and the final cluster-colored consensus tree
32
+
33
+ ## Requirements
34
+
35
+ - Python 3.10+
36
+ - All other dependencies (Biopython, NumPy, Pandas, SciPy, Matplotlib) are installed automatically with the package.
37
+
38
+ ## Installation
39
+
40
+ First create an isolated environment named `plastree` (pick one option below), then install PlasTree into it.
41
+
42
+ **Option A: venv**
43
+ ```bash
44
+ python3 -m venv plastree
45
+ source plastree/bin/activate
46
+ pip install --upgrade pip
47
+ ```
48
+
49
+ **Option B: conda / miniforge**
50
+ ```bash
51
+ conda create -n plastree python=3.12
52
+ conda activate plastree
53
+ ```
54
+
55
+ With the environment active, install PlasTree directly from GitHub:
56
+ ```bash
57
+ pip install git+https://github.com/BioSys-BUT/PlasTree.git
58
+ ```
59
+
60
+ Or, if you want a local copy of the source:
61
+ ```bash
62
+ git clone https://github.com/BioSys-BUT/PlasTree.git
63
+ cd PlasTree
64
+ pip install .
65
+ ```
66
+
67
+ Verify the install:
68
+ ```bash
69
+ plastree --help
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ ```bash
75
+ plastree --fasta <fasta_path> [--pang_format {roary,panaroo}] [--pang_csv <csv_path>] [--methods dotplot kmer pang] [--outdir <out_dir>] [--max_cluster_size <int>] [--max_branch_length <float> [<float> ...]] [--dotplot_window {19,22}] [--dotplot_threads <int>] [--dotplot_png] [--result_tree_png]
76
+ ```
77
+
78
+ ### Parameters
79
+
80
+ - `--fasta`: Path to a single FASTA file containing all plasmid sequences (one record per plasmid). **Required.**
81
+ - `--pang_format {roary,panaroo}`: Format of the pangenome CSV. Required when using `--methods pang`.
82
+ - `--pang_csv`: Path to the pangenome presence/absence CSV file. Required when using `--methods pang`.
83
+ - `--methods [dotplot pang kmer ...]`: Tree construction methods to apply. Default: `dotplot` only.
84
+ - `--outdir`: Directory to store output files. Default: `output`.
85
+ - `--max_cluster_size`: Maximum OTUs (plasmids) per cluster. Default: half the number of input sequences.
86
+ - `--max_branch_length`: Maximum allowed branch length within a cluster (0-1). Accepts one or more values (e.g. `0.1 0.2 0.05`); one cluster-assignment table is produced per value. Default: `0.2`.
87
+ - `--dotplot_window {19,22}`: Sliding window size for dotplot comparison. Default: `22`.
88
+ - `--dotplot_threads`: Number of parallel worker processes for dotplot pairwise distance computation. Default: `1`.
89
+ - `--dotplot_png`: Save pairwise dotplots as PNGs. Only for <=20 sequences. Default: off.
90
+ - `--result_tree_png`: Save the consensus tree as a PNG with node support and cluster coloring. Default: off.
91
+
92
+ ### Example
93
+
94
+ ```bash
95
+ plastree \
96
+ --fasta sequences.fasta \
97
+ --methods dotplot kmer pang \
98
+ --pang_format panaroo \
99
+ --pang_csv gene_presence_absence.csv \
100
+ --dotplot_window 22 \
101
+ --dotplot_threads 8 \
102
+ --max_cluster_size 30 \
103
+ --max_branch_length 0.05 0.1 0.2 0.4 \
104
+ --result_tree_png \
105
+ --outdir output
106
+ ```
107
+
108
+ with example data (8 small real plasmids from *Enterococcus faecium*, included in [`examples/`](examples)):
109
+ ```bash
110
+ plastree \
111
+ --fasta examples/plasmids.fasta \
112
+ --methods dotplot kmer pang \
113
+ --pang_format panaroo \
114
+ --pang_csv examples/gene_presence_absence.csv \
115
+ --result_tree_png \
116
+ --outdir examples/output
117
+ ```
118
+
119
+ ### Output
120
+
121
+ All output files are written to `--outdir`.
122
+
123
+ | File | Description |
124
+ |---|---|
125
+ | `dotplot_tree.newick` | DotPloTree structural similarity tree (`--methods dotplot`) |
126
+ | `dotplot_distmat.tsv` | DotPloTree distance matrix |
127
+ | `kmer_tree.newick` | KmerTree nucleotide composition tree (`--methods kmer`) |
128
+ | `kmer_distmat.tsv` | KmerTree distance matrix |
129
+ | `pang_tree.newick` | PanGTree gene content tree (`--methods pang`) |
130
+ | `pang_distmat.tsv` | PanGTree distance matrix |
131
+ | `consensus_tree.newick` | weighted consensus tree (only when 2+ methods are used) |
132
+ | `plasmid_clusters.tsv` | cluster assignment per plasmid (cluster 0 = outlier) |
133
+ | `cluster_tree.png` | consensus tree rendered with clusters color-coded (only with `--result_tree_png`) |
134
+
135
+ If multiple `--max_branch_length` values are given, `plasmid_clusters.tsv` and `cluster_tree.png` are produced once per threshold, suffixed with the value (dots replaced by underscores), e.g. `plasmid_clusters_bl0_2.tsv` and `cluster_tree_0_2.png` for threshold `0.2`.
136
+
137
+ ## Generating pangenome input (Bakta + Roary/Panaroo)
138
+
139
+ The `--pang_csv` file used by `--methods pang` is not produced by PlasTree itself. It comes from annotating the same plasmid FASTA files and clustering the predicted genes into orthologous groups, using external tools:
140
+
141
+ 1. Annotate each plasmid with [Bakta](https://github.com/oschwengers/bakta) (or another tool that outputs GFF3 annotations), producing one GFF3 file per plasmid.
142
+ 2. Collect all resulting GFF3 files into one directory.
143
+ 3. Run [Roary](https://sanger-pathogens.github.io/Roary/) and/or [Panaroo](https://github.com/gtonkinhill/panaroo) on the collected GFF3 files:
144
+ ```bash
145
+ roary *.gff3 -f roary_out
146
+ ```
147
+ ```bash
148
+ panaroo -i *.gff3 -o panaroo_out
149
+ ```
150
+
151
+ Both produce a `gene_presence_absence.csv`. Pass this file as `--pang_csv`, together with the matching `--pang_format roary` or `--pang_format panaroo`. See each tool's own documentation for annotation database setup, threading, and other options. Bakta, Roary, and Panaroo have their own, sometimes conflicting, dependencies, so it is common to install them into separate environments (e.g. separate conda environments).
152
+
153
+ ## License
154
+
155
+ See [LICENSE](LICENSE) for details (MIT).
156
+
157
+ ## Citation
158
+
159
+ The manuscript describing PlasTree is currently in submission. Until it is published, if you use PlasTree in your research, please cite this repository:
160
+
161
+ ```bibtex
162
+ @software{plastree2026,
163
+ title={PlasTree},
164
+ author={Vitkova, Helena and Jakubickova, Marketa and Bezdicek, Matej and Holubova, Ema and Lengerova, Martina},
165
+ year={2026},
166
+ url={https://github.com/BioSys-BUT/PlasTree}
167
+ }
168
+ ```
169
+
170
+ ## Contact
171
+
172
+ For questions and feedback, please open an issue on GitHub or contact us via email at [jakubickova@vut.cz](mailto:jakubickova@vut.cz).
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "plastree"
7
+ version = "0.1.0"
8
+ description = "Build plasmid phylogenetic trees from dotplot, pangenome presence/absence, and k-mer methods, with cluster detection."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "Helena Vitkova" },
13
+ { name = "Marketa Jakubickova", email = "jakubickova@vut.cz" },
14
+ { name = "Matej Bezdicek" },
15
+ { name = "Ema Holubova" },
16
+ { name = "Martina Lengerova" },
17
+ ]
18
+ requires-python = ">=3.10"
19
+ classifiers = [
20
+ "Programming Language :: Python :: 3",
21
+ "Operating System :: OS Independent",
22
+ "Intended Audience :: Science/Research",
23
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
24
+ ]
25
+ dependencies = [
26
+ "biopython==1.87",
27
+ "numpy==2.4.6",
28
+ "pandas==2.3.3",
29
+ "scipy==1.17.1",
30
+ "matplotlib==3.10.9",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/BioSys-BUT/PlasTree"
35
+ Repository = "https://github.com/BioSys-BUT/PlasTree"
36
+ Issues = "https://github.com/BioSys-BUT/PlasTree/issues"
37
+
38
+ [project.scripts]
39
+ plastree = "plastree.plasmid_tree_tool:main"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+
44
+ [tool.pytest.ini_options]
45
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"