No project description provided
Project description
uchimata-py
This repository contains code for the Python widget version of the uchimata library. Made with anywidget, this allows people to use the functionality in computational notebooks, such as Jupyter Notebook.
Basic usage
The available functionality is pretty limited at this moment. We will stabilize the API as we go. At this point, you can display 3D chromatin models.
pip install 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)
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
Or: run the example in Google Colab.
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.2.0.tar.gz.
File metadata
- Download URL: uchimata-0.2.0.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffe7e235ad69328a380565959d6db9111ad6f141f8c78e75ebb01e08f319b966
|
|
| MD5 |
15f7460611b6d3b5d00ec4cbfc928939
|
|
| BLAKE2b-256 |
17ed79fad41f4f0b3d8b9efc8fb0d523397ba9003c2766e8a41418e16499ec9f
|
File details
Details for the file uchimata-0.2.0-py3-none-any.whl.
File metadata
- Download URL: uchimata-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47fe04f4233649be577d608a8e1960f908ec5052c0da73affa4761985f066e9a
|
|
| MD5 |
f85fbfeac924e17a1eb064ccbdc2d980
|
|
| BLAKE2b-256 |
63a9ebfbecd77aab672e12a2691dcd81b5a402ac05e91808134a20c4fbfaee59
|