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.
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:
uv run --with uchimata --with numpy --with pyarrow --with jupyterlab jupyter lab- make a new notebook
- copy and paste the code above into an empty cell
Contributing
Running tests:
uv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uchimata-0.4.0.tar.gz.
File metadata
- Download URL: uchimata-0.4.0.tar.gz
- Upload date:
- Size: 216.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ee8dd35f5f9007f68b7cf309474b9b9d0a75c0a371a9613b613d2aa2c141abe
|
|
| MD5 |
f7eff112074ba2a0c504f9931b246e13
|
|
| BLAKE2b-256 |
4a5bb15a476d5f4bcced084047878a5e1f45009c87cf1384d60a7474f07d447c
|
File details
Details for the file uchimata-0.4.0-py3-none-any.whl.
File metadata
- Download URL: uchimata-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a22cb368c22589e6f93e10677e6532deb52f459c02d62bd2d80634a79bc0070
|
|
| MD5 |
4d452f0329ad7c65429a657c1b241d89
|
|
| BLAKE2b-256 |
e919dec3143b45dab56a66afa886ef84d41d0ec2e0ce37470c2da271f665c1f4
|