Skip to main content

No project description provided

Project description

chromospyce

This is an anywidget-powered version of the chromospace library intended for use in computational notebooks, such as Jupyter Notebook.

colorful squiggly thick line depicting 3D chromatin running in 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.

import chromospyce
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 a chromospyce 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"
}
chromospyce.Widget(random_structure, vc)

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

In chromospyce, on the other hand, you can also visualize structures defined as 2D numpy arrays, or pandas dataframe (with columns named 'x', 'y', 'z'.

Quickly test out chromospyce with uv:

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

Or: run the example in Google Colab.

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

chromospyce-0.1.2.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

chromospyce-0.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file chromospyce-0.1.2.tar.gz.

File metadata

  • Download URL: chromospyce-0.1.2.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.16

File hashes

Hashes for chromospyce-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d8990f84e7bb19c17e944affc6d3f7df69c28f2cce777926a7b5feb4a58b85ca
MD5 b35d99f9ba7b44b83cef715265da42a0
BLAKE2b-256 98bff43b6cbad614198c2ccf902d1885b546c6991c45f2e7d992a8573abbf3dd

See more details on using hashes here.

File details

Details for the file chromospyce-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chromospyce-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0d6a7f23339daf9161adc8e34cd9d7a7674c670f8f97a1dfa1c32e177e64ef99
MD5 87fd566aea05d737d836b6e56b6b338f
BLAKE2b-256 1209880a1647ae8a2c0435d3d0df6ac5feb51bde5b1c4093265f770273555fbf

See more details on using hashes here.

Supported by

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