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.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

chromospyce-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chromospyce-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for chromospyce-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be3e73fdd9b235e3ae3d47ad06ed8c6b4be130810bf3395b45f79a834d919b93
MD5 3d66be08e4bec0a3bcd0409385b5824f
BLAKE2b-256 c502150fa72d1f52d87c8092f4e52e87c48bdd1dedf8726c313a0a49e240befd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chromospyce-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for chromospyce-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1461c0c618355104f0d32297dc6a7ae95a8c132f4a336c541d57a63cd6923cc6
MD5 8a533d5bbfc79fba4ef397b46700f506
BLAKE2b-256 62d91e7faba886ef6e717352f0bc7b443d62e566e589da6b9a31b2f3473c3c6b

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