Skip to main content

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.

Metadata

Release files for chromospyce 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chromospyce 0.1.2
File Size Uploaded
chromospyce-0.1.2.tar.gz 2.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for chromospyce 0.1.2
File Interpreter ABI Platform
chromospyce-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 2.0 MB

Release files / chromospyce-0.1.2.tar.gz

Download URL chromospyce-0.1.2.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
d8990f84e7bb19c17e944affc6d3f7df69c28f2cce777926a7b5feb4a58b85ca
BLAKE2b-256 checksum
How to use checksums
98bff43b6cbad614198c2ccf902d1885b546c6991c45f2e7d992a8573abbf3dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.16

Release files / chromospyce-0.1.2-py3-none-any.whl

Download URL chromospyce-0.1.2-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d6a7f23339daf9161adc8e34cd9d7a7674c670f8f97a1dfa1c32e177e64ef99
BLAKE2b-256 checksum
How to use checksums
1209880a1647ae8a2c0435d3d0df6ac5feb51bde5b1c4093265f770273555fbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.16

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page