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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: chromospyce-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 855b4de7045267eff9aa1ff6a6051f0c2fe0ce786ec2a0346744c8b29f15e5e3
MD5 302a8ad0367e5b48e6d3f1f7c722d018
BLAKE2b-256 ff1287eb459c74e25e1dba9601b9891c6cffdc70b2360c39da0e8fe40cef1d2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromospyce-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea20cfd88bb627ea6ce24bafa0e68498db59d71a16a8c85078aa309214328627
MD5 89662c4cf662387aa0d0f6af29ec6cf8
BLAKE2b-256 1890da668df8cf04e685cc543e5cc4bf43dbdb7ad9b7a09d04163b0ac0a2266b

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