Skip to main content

Harmonizome Python Wrapper

A Python wrapper around the Ma'ayan Lab Harmonizome API and download endpoints. The package provides a Python interface for querying Harmonizome entities, downloading Harmonizome datasets, and loading the downloaded artifacts into pandas DataFrames.

Installation

pip install harmonizome

Quick Start

from harmonizome import Harmonizome

# Inspect one gene from the API
gene_info = Harmonizome.get('gene', 'BRCA1')
print(f"Gene: {gene_info['name']}")

# Download one dataset artifact
for filename in Harmonizome.download(['ENCODE']):
    print(f"Downloaded: {filename}")

Features

  • API Wrapper: Query genes, gene sets, attributes, and datasets from the Ma'ayan Lab Harmonizome API
  • Dataset Downloads: Download complete Harmonizome datasets (~30GB total) from the Ma'ayan Lab service
  • DataFrame Support: Load data directly as pandas DataFrames
  • Sparse Matrix Support: Efficient handling of large sparse datasets
  • Python 3.9+ Support: Targets the package minimum version and newer

Quick API Reference

Core Methods

Harmonizome.get(entity, name=None, start_at=None)

Retrieve entities from the Ma'ayan Lab Harmonizome API.

  • entity: Type of entity ('gene', 'gene_set', 'attribute', etc.)
  • name: Specific entity name (optional)
  • start_at: Cursor position for pagination (optional)

Harmonizome.download(datasets=None, what=None)

Download Harmonizome dataset files from the Ma'ayan Lab service to local directories.

  • datasets: List of dataset names (defaults to all datasets)
  • what: List of file types to download (defaults to all types)

Harmonizome.download_df(datasets=None, what=None, sparse=False)

Download Harmonizome dataset files and load them as pandas DataFrames.

  • datasets: List of dataset names
  • what: List of file types to download
  • sparse: Use sparse matrices for memory efficiency

Entity Types

  • DATASET: Dataset information
  • GENE: Gene information
  • GENE_SET: Gene set collections
  • ATTRIBUTE: Gene attributes
  • GENE_FAMILY: Gene family classifications
  • NAMING_AUTHORITY: Naming authorities
  • PROTEIN: Protein information
  • RESOURCE: Data resources

Examples

Querying Genes

brca1 = Harmonizome.get('gene', 'BRCA1')
print(f"BRCA1 description: {brca1['description']}")

Downloading Datasets

# Download one dataset
for filename in Harmonizome.download(['ENCODE']):
    print(f"Downloaded: {filename}")

Working with DataFrames

# Load one dataset into a pandas DataFrame
for df in Harmonizome.download_df(['ENCODE']):
    print(f"DataFrame: {df.shape}")
    break

Working with Gene Associations as DataFrames

You can fetch all associations for a gene and convert them to a pandas DataFrame:

from harmonizome import Harmonizome

gene = "STAT3"
gene_data = Harmonizome.get_gene_data(gene, use_cache=True)

# Get all associations as a DataFrame
df = gene_data.to_dataframe()

# Filter to one dataset
dataset_df = df[df["dataset"] == "ENCODE Transcription Factor Binding Site Profiles"]
print(dataset_df.head())

API Reference: GeneData.to_dataframe()

gene_data.to_dataframe(dataset: str = None) -> pandas.DataFrame
  • Returns a DataFrame with columns: 'gene_set', 'dataset', 'thresholdValue', 'standardizedValue'.
  • Optionally filter by dataset name.

File Types

The following file types are available for download:

  • gene_attribute_matrix.txt.gz: Gene-attribute association matrix
  • gene_list_terms.txt.gz: List of genes with terms
  • attribute_list_entries.txt.gz: List of attributes with entries

Requirements

  • Python 3.9+
  • numpy >= 1.19.0
  • pandas >= 1.3.0
  • scipy >= 1.7.0

Development

# Install development dependencies
pip install -e .

# Run tests
pytest

License

This project is licensed under the MIT License.

Data Source and Citation

This wrapper depends on the public Harmonizome resource maintained by the Ma'ayan Lab. If you use this package in your research, cite the Harmonizome resource itself:

Rouillard AD, Gundersen GW, Fernandez NF, Wang Z, Monteiro CD, McDermott MG, Ma'ayan A. The harmonizome: a collection of processed datasets gathered to serve and mine knowledge about genes and proteins. Database (Oxford). 2016 Jul 3;2016:baw100. doi: 10.1093/database/baw100.

Metadata

Release files for harmonizome 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for harmonizome 1.0.1
File Size Uploaded Provenance Actions
harmonizome-1.0.1.tar.gz 30.3 kB Without provenance Details for harmonizome-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for harmonizome 1.0.1
File Interpreter ABI Platform Actions
harmonizome-1.0.1-py3-none-any.whl Python 3 none any Details for harmonizome-1.0.1-py3-none-any.whl

Total release size: 48.4 kB

Release files / harmonizome-1.0.1.tar.gz

Download URL harmonizome-1.0.1.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f5ab97fe2f3040becf55e17185b06d92ffaa594c5f908bbf2adade6fa979a8cf
BLAKE2b-256 checksum
How to use checksums
7cc429a4b6c15dc387ec20c596b62af79e0160a95c338f572863a0782d1dd96a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / harmonizome-1.0.1-py3-none-any.whl

Download URL harmonizome-1.0.1-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f42256a5a3dee6f19f63759d7365b4e8dbb890343c6f6e79589a108f33b2790
BLAKE2b-256 checksum
How to use checksums
e3d12c61a15b627dbf16bf0e1645841eeeafa59572b36e365afdcd675e4c1532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Security for harmonizome 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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