semvec/pypi-packages huggingface dataset:
plotly-phylotree 0.0.1
A package to plot phylogenetic trees with Plotly.
License: MIT License
Requires Python: >=3.9

# Plotly PhyloTree Extension

This package extends Plotly to create interactive plots of phylogenetic trees from Newick strings. It can be used with plotly.py and can also be integrated into Dash Apps.

See also:
- Newick format - https://en.wikipedia.org/wiki/Newick_format
- Plotly - https://github.com/plotly/plotly.py

## Installation

```bash
pip install plotly-phylotree
```

## Usage

### 1. Basic Tree
- Labels shown by default
- No distances specified in Newick string

```python
from phylotree import create_phylogenetic_tree

newick_str = "(A,(B,C)D)E;"
fig = create_phylogenetic_tree(newick_str)
fig.show()
```
![Alt text](/examples/output_images/basic_tree_labels.png "Basic Tree")

### 2. Basic Tree with specified maximum display level
- Display level specifies level up to which tree is plotted. Defaults to np.inf.

```python
from phylotree import create_phylogenetic_tree

newick_str = "(A,(B,C)D)E;"
fig = create_phylogenetic_tree(newick_str, display_level=1)
fig.show()
```

![Alt text](/examples/output_images/basic_tree_display_level.png "Basic Tree with max display level")

### 3. Tree with specified distances
- Labels shown by default
- Distances specified in Newick string

```python
from phylotree import create_phylogenetic_tree

newick_str = "(Bovine:0.69395,(Gibbon:0.36079,(Orang-Utan:0.33636,(Gorilla:0.17147,(Chimp:0.19268,Human:0.11927):0.08386):0.06124):0.15057):0.54939,Mouse:1.21460)"
fig = create_phylogenetic_tree(newick_str)
fig.show()
```
![Alt text](/examples/output_images/mammals_tree_labels.png "Mammals")

### 4. Tree without labels
- Labels deactivated
- Distances specified

```python
from phylotree import create_phylogenetic_tree

newick_str = "(Bovine:0.69395,(Gibbon:0.36079,(Orang-Utan:0.33636,(Gorilla:0.17147,(Chimp:0.19268,Human:0.11927):0.08386):0.06124):0.15057):0.54939,Mouse:1.21460)"
fig = create_phylogenetic_tree(newick_str, show_labels=False)
fig.show()
```
![Alt text](/examples/output_images/mammals_tree_no_labels.png "Mammals without labels")

## Contributing

Suggestions for improvement are welcome. As this is a small side project, please allow some time for answers and revision.

## License

MIT License