Skip to main content

A native Python port of the R vegan package for community ecology.

Project description

mapu

A native Python implementation of the classic R package vegan for community ecology.

This package aims to provide ecologists and data scientists using Python with rapid, pure-Python ports of popular vegan functions, including diversity indices, distance matrices (vegdist), ordination techniques, and multivariate statistical tests.

Installation

You can install mapu using pip:

pip install mapu

Or using uv for ultra-fast dependency resolution and installation:

uv pip install mapu

Development Installation

To install from source for development using uv:

git clone https://github.com/pedropablosilvaa/mapu.git
cd mapu
uv venv
source .venv/bin/activate  # On Unix/macOS
uv pip install -e ".[dev]"

Features

The library currently supports a wide array of functions mirroring R vegan:

  • Diversity Analysis: diversity (Shannon, Simpson, etc.), fisher_alpha, specnumber, renyi, tsallis, rarefaction functions (rarefy, rrarefy), and species accumulation curves.
  • Distance Matrices: vegdist (Bray-Curtis, Jaccard, Euclidean, Manhattan, Gower, etc.), designdist.
  • Ordination: Unconstrained (PCoA/cmdscale, PCA, NMDS/metaMDS, isomap) and Constrained (rda, cca, capscale).
  • Data Transformation: decostand, wisconsin.
  • Statistical Tests: adonis (PERMANOVA), anosim, mantel, mrpp, simper, betadisper.
  • Clustering: spantree, cascadeKM, cophenetic.

Example Usage

import numpy as np
import pandas as pd
from mapu import vegdist, metaMDS, diversity

# Create a mock species abundance matrix (sites x species)
np.random.seed(42)
community_data = pd.DataFrame(np.random.poisson(lam=2, size=(10, 20)))

# Calculate Bray-Curtis distance
bray_dist = vegdist(community_data, method="bray")

# Perform Non-metric Multidimensional Scaling (NMDS)
nmds_result = metaMDS(community_data, distance="bray", k=2)
print("Stress:", nmds_result.stress)

# Calculate Shannon diversity
shannon_h = diversity(community_data, index="shannon")
print("Shannon Diversity:\\n", shannon_h)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

mapu-0.1.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

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

mapu-0.1.0-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mapu-0.1.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mapu-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a4827b37d5c56d31e6bb000aef3bd98061d9946eda999b864ce3e22df7127ffa
MD5 f5e4590dfbba701243812ade974baefa
BLAKE2b-256 dd66ffee898e0714a76b573ece6d53f81e7148b2b655daeca543ba5659f2280f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mapu-0.1.0.tar.gz:

Publisher: publish.yml on pedropablosilvaa/mapu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: mapu-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mapu-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50c0d9660157ed44bd9bee5d02a4bf95e7d01b811ddb5958ea3ae0ae803c1bef
MD5 c09bf15803a55271e3b49ec91edc4ea1
BLAKE2b-256 3ab839833056563055a9944e27ba050b793b643f5884704f70442eaa91e3b42f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mapu-0.1.0-py3-none-any.whl:

Publisher: publish.yml on pedropablosilvaa/mapu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page