Skip to main content

PhyloCartoPlot

PhyloCartoPlot is a Python tool for phylogeographic visualization. It overlays phylogenetic trees on geographic raster maps, letting researchers explore the spatial distribution of evolutionary relationships and trait variation across species.


Key Features

  • Integrates GBIF occurrence data with phylogenetic trees
  • Renders trees directly on GeoTIFF raster base maps (e.g. environmental data)
  • Supports arbitrary traits via a generic trait_value column
  • Works with any taxa, geographic region, or raster dataset
  • Usable as a Python library (Jupyter) or command-line tool

Requirements

  • Python ≥ 3.8
  • Biopython – tree construction and parsing
  • Cartopy – geographic projections
  • Rasterio – raster data I/O
  • Matplotlib – plotting
  • pandas, numpy, scikit-image

Installation

git clone https://github.com/tahiri-lab/PhyloCartoPlot.git
cd PhyloCartoPlot
pip install -e .

Quick Start

1 – Format GBIF occurrence data

python -m phylocartoplot.preprocessing.format_gbif_data \
    examples/sample_data/use_case_1/gbif_coffea_ex3.csv \
    examples/sample_data/use_case_1/node_names.csv

2 – Add trait metadata

python -m phylocartoplot.preprocessing.add_metadata \
    examples/sample_data/use_case_1/gbif_coffea_ex3_formatted.csv \
    examples/sample_data/use_case_1/no_caffeine_nodes_w_specimen.csv

3 – Build phylogenetic tree

python -m phylocartoplot.preprocessing.build_phylogenetic_tree \
    sequences.fasta

4 – Visualize

from phylocartoplot.visualisation.tree_to_map_raster import PhyloCartoPlotter

plotter = PhyloCartoPlotter(
    nwk_file="sequences_tree.nwk",
    gps_file="examples/sample_data/use_case_1/coords_w_caff.csv",
    offset_file="examples/sample_data/use_case_1/offsets_caff.csv",
    raster_file="enviro.tif",
    raster_band=1
)
plotter.plot()
plotter.save(output_dir="output")

Or use the interactive walkthrough notebooks in examples/use_case_1/.


Documentation

Complete documentation for the PhyloCartoPlot workflow.

Files

1. PIPELINE.md

Technical documentation of the entire workflow

Explains:

  • Module breakdown (what each script does)
  • Input/output specifications
  • Data flow diagrams
  • Key functions and their purposes
  • Customization points
  • Troubleshooting guide

Read this for: Understanding how the pipeline works technically


2. 01_phylocartoplot_walkthrough.ipynb

Interactive step-by-step Jupyter notebook

Walks through:

  • Step 1: Format geographic coordinates
  • Step 2: Add trait/metadata values
  • Step 3: Build phylogenetic tree
  • Step 4: Create visualization

Read this for: Hands-on learning, executing the workflow

Running the Notebook

# Navigate to docs folder
cd phylocartoplot/examples

# Start Jupyter
jupyter notebook

# Open: 01_phylocartoplot_walkthrough.ipynb

Or from project root:

jupyter notebook examples/use_case_1/01_phylocartoplot_walkthrough.ipynb
jupyter notebook examples/use_case_1/02_tree_to_map_raster_walkthrough.ipynb

How to Use This Documentation

For Quick Understanding

  1. Read the main README.md

Tutorial

  1. Open 01_phylocartoplot_walkthrough.ipynb (examples folder)
  2. Follow cells step-by-step
  3. Execute and inspect outputs

Notebook Features

Automatic path configuration Step-by-step explanations Data inspection and sampling Error checking and reporting Clear output messages Next step instructions



Quick Links

New to PhyloCartoPlot? → Start with README.md, then run the notebook in this folder

Need technical details? → Read PIPELINE.md or check source code

Want to understand the structure? → See STRUCTURE.txt in project root

Ready to use the workflow? → Run the notebook: jupyter notebook examples/use_case_1/01_phylocartoplot_walkthrough.ipynb


Generality and Reusability

PhyloCartoPlot is designed as a parameterized, dataset-agnostic workflow. While the provided examples use Coffea species occurrence data and a WorldClim raster layer, the pipeline imposes no assumptions specific to that use case. Researchers can apply the tool to any combination of the following inputs:

  • Phylogenetic tree: any Newick-formatted tree produced by standard inference tools
  • Taxa: any group of organisms for which georeferenced occurrence records are available
  • Geographic region: any spatial extent, limited only by the chosen raster layer coverage
  • Trait or metadata: any continuous or categorical variable supplied via a trait_value column in the coordinate file
  • Raster base map: any single-band or multi-band GeoTIFF (e.g., climate layers, land-cover, elevation)

To apply the workflow to a new dataset, it is sufficient to substitute the input files and adjust the column names and raster band index accordingly. No modifications to the source code are required for standard use cases.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phylocartoplot-0.1.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phylocartoplot-0.1.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file phylocartoplot-0.1.0.tar.gz.

File metadata

  • Download URL: phylocartoplot-0.1.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.6

File hashes

Hashes for phylocartoplot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea2a43ddfc14bc726509d8615a81f7d680472db50cb0e82e3f9f87ef19eae075
MD5 177b34b8fa29c785b40bc828ab8f5227
BLAKE2b-256 b64f71daab03f60787f38947ef8fdb6a511f88f06af54c2f8f37da7fa854533e

See more details on using hashes here.

File details

Details for the file phylocartoplot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: phylocartoplot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.6

File hashes

Hashes for phylocartoplot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1a2da20e07bbf08f5d645280a2842128b289e9906050a662124a5934d256896
MD5 a0615741c02f357c8280a64a0eeb9e95
BLAKE2b-256 b99c0cc0f5f7036c0b502f73161e5551e4cf57a335f6ae75e7575b98b5855837

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page