Skip to main content

No project description provided

Project description

uchimata-py

This repository contains code for a widget version of the uchimata library. Made with anywidget, this allows people to visualize 3D genome models in Python-based computational notebooks, such as Jupyter Notebook.

colorful squiggly thick line depicting 3D chromatin running in jupyter
notebook

Basic usage

uchimata is available on PyPI:

pip install uchimata

We like to use uv to manage project dependencies:

uv add uchimata
import uchimata as uchi
import numpy as np

BINS_NUM = 1000

# Step 1: Generate random structure, returns a 2D numpy array:
def make_random_3D_chromatin_structure(n):
    position = np.array([0.0, 0.0, 0.0])
    positions = [position.copy()]
    for _ in range(n):
        step = np.random.choice([-1.0, 0.0, 1.0], size=3)  # Randomly choose to move left, right, up, down, forward, or backward
        position += step
        positions.append(position.copy())
    return np.array(positions)

random_structure = make_random_3D_chromatin_structure(BINS_NUM)

# Step 2: Display the structure in an uchimata widget
numbers = list(range(0, BINS_NUM+1))
vc = {
    "color": {
        "values": numbers,
        "min": 0,
        "max": BINS_NUM,
        "colorScale": "Spectral"
    }, 
    "scale": 0.01, 
    "links": True, 
    "mark": "sphere"
}
uchi.Widget(random_structure, vc)

Run the example in Google Colab.

The API is still frequently changing. The main feature of the widget right now is the ability to display 3D chromatin models and we're working on capabilities to integrate with other bioinformatics tools.

The underlying JS library only supports data in the Apache Arrow format.

In the widget version, on the other hand, we provide interface to load data in many notebook-native formats, such as 2D numpy arrays, or pandas dataframe (with columns named 'x', 'y', 'z').

Quickly test out uchimata with uv:

  1. uv run --with uchimata --with numpy --with pyarrow --with jupyterlab jupyter lab
  2. make a new notebook
  3. copy and paste the code above into an empty cell

Contributing

Running tests: uv run pytest

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

uchimata-0.3.0.tar.gz (215.4 kB view details)

Uploaded Source

Built Distribution

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

uchimata-0.3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file uchimata-0.3.0.tar.gz.

File metadata

  • Download URL: uchimata-0.3.0.tar.gz
  • Upload date:
  • Size: 215.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for uchimata-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cd9760a12dbb5937d8221177715ebfbe026ce39e4985fd3e0094dbb3c195d482
MD5 709ecf3669c65437523a0ef37e917a10
BLAKE2b-256 b014df675fe0e8e887b6a8c4f2780296ab481794a38af35670516a8c752ebe5f

See more details on using hashes here.

File details

Details for the file uchimata-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: uchimata-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for uchimata-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f6cbb58c01c7d9957617405445922a512586122c17a582d89f878213c4cca41
MD5 7c094a8463999624c30400e2a96c8225
BLAKE2b-256 263d1be994c7cb8374dd2e02765f2d168cf65ecd87875f0a0fbb860bd07af329

See more details on using hashes here.

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