MCPcopy Index your code
hub / github.com/Zsailer/phylopandas

github.com/Zsailer/phylopandas @v0.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8.0 ↗ · + Follow
58 symbols 157 edges 17 files 25 documented · 43%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Gitter chat Documentation Status Build Status Binder

Bringing the Pandas DataFrame to phylogenetics.

PhyloPandas provides a Pandas-like interface for reading sequence and phylogenetic tree data into pandas DataFrames. This enables easy manipulation of phylogenetic data using familiar Python/Pandas functions. Finally, phylogenetics for humans!

How does it work?

Don't worry, we didn't reinvent the wheel. PhyloPandas is simply a DataFrame (great for human-accessible data storage) interface on top of Biopython (great for parsing/writing sequence data) and DendroPy (great for reading tree data).

PhyloPandas does two things: 1. It offers new read functions to read sequence/tree data directly into a DataFrame. 2. It attaches a new phylo accessor to the Pandas DataFrame. This accessor provides writing methods for sequencing/tree data (powered by Biopython and dendropy).

Basic Usage

Sequence data:

Read in a sequence file.

import phylopandas as ph

df1 = ph.read_fasta('sequences.fasta')
df2 = ph.read_phylip('sequences.phy')

Write to various sequence file formats.

df1.phylo.to_clustal('sequences.clustal')

Convert between formats.

# Read a format.
df = ph.read_fasta('sequences.fasta')

# Write to a different format.
df.phylo.to_phylip('sequences.phy')

Tree data:

Read newick tree data

df = ph.read_newick('tree.newick')

Visualize the phylogenetic data (powered by phylovega).

df.phylo.display(
    height=500,
)

Contributing

If you have ideas for the project, please share them on the project's Gitter chat.

It's easy to create new read/write functions and methods for PhyloPandas. If you have a format you'd like to add, please submit PRs! There are many more formats in Biopython that I haven't had the time to add myself, so please don't be afraid to add them! I thank you ahead of time!

Testing

PhyloPandas includes a small pytest suite. Run these tests from base directory.

$ cd phylopandas
$ pytest

Install

Install from PyPI:

pip install phylopandas

Install from source:

git clone https://github.com/Zsailer/phylopandas
cd phylopandas
pip install -e .

Dependencies

  • BioPython: Library for managing and manipulating biological data.
  • DendroPy: Library for phylogenetic scripting, simulation, data processing and manipulation
  • Pandas: Flexible and powerful data analysis / manipulation library for Python
  • pandas_flavor: Flavor pandas objects with new accessors using pandas' new register API (with backwards compatibility).

Core symbols most depended-on inside this repo

_read_function
called by 9
phylopandas/seqio/read.py
_write_function
called by 7
phylopandas/seqio/write.py
status
called by 4
setup.py
combine
called by 3
phylopandas/core.py
get_random_id
called by 3
phylopandas/utils.py
_write_function
called by 3
phylopandas/treeio/write.py
_read_doc_template
called by 3
phylopandas/treeio/read.py
_read_function
called by 3
phylopandas/treeio/read.py

Shape

Function 39
Method 15
Class 4

Languages

Python100%

Modules by API surface

phylopandas/tests/test_frame.py10 symbols
phylopandas/core.py9 symbols
phylopandas/treeio/write.py8 symbols
phylopandas/seqio/write.py8 symbols
phylopandas/treeio/read.py7 symbols
phylopandas/seqio/read.py6 symbols
setup.py5 symbols
phylopandas/tests/__init__.py2 symbols
phylopandas/utils.py1 symbols
phylopandas/treeio/tests/test_read.py1 symbols
phylopandas/tests/test_series.py1 symbols

For agents

$ claude mcp add phylopandas \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page