Skip to main content

spice-bio

PyPI version Downloads

Installation

Create a conda environment

conda create -n spice-env python=3.9
conda activate spice-env

Install spice-bio via pip:

pip3 install spice-bio

Examples

Detailed documentation for SOMA and Melange can be found at folder examples.

SOMA

Here is a simple example of how to use SOMA to train a model and predict PSI values:

from SPICE import Soma
import pandas as pd

df_train = pd.read_csv('path/to/your/df_data') # df contains columns 'psi'(ratio) and 'seq'

# train SOMA models, after training, the model parameters will be saved as 'SOMA_params_seed_0.pth', 'SOMA_params_seed_1.pth', etc.
Soma.train(
    df_train,    # pandas DataFrame with columns 'psi' and 'seq'
    device='cuda',    # 'cuda' or 'cpu'
    epochs=1,    # number of training epochs
    batch_size=512,    # batch size
    learning_rate=1e-4,    # learning rate
    num_seeds=10    # number of SOMA models to train with different random initializations
)

df_test = pd.read_csv('path/to/your/df_test_data') # df_test contains column 'seq'

# predict PSI values using a trained SOMA model
pred_psi = Soma.predict(
    df_test,   # pandas DataFrame with column 'seq'
    device='cuda',  # 'cuda' or 'cpu'
    batch_size=512,    # batch size
    params='SOMA_params_seed_0.pth')  # path to the trained SOMA model parameters

Melange

Here is a simple example of how to use Melange and SOMA to generate sequences with desired PSI values:

from SPICE import Melange
import pandas as pd

df_train = pd.read_csv('path/to/your/df_data') # df contains columns 'psi'(ratio) and 'seq'

Melange.train(
    df_train,    # pandas DataFrame with columns 'psi' and 'seq'
    device='cuda',    # 'cuda' or 'cpu'
    lambda_cls=5.0,   # weight for the classification loss, use to control the trade-off between reconstruction and classification accuracy
    max_len=250,    # maximum sequence length
    epochs=10,      # number of training epochs
    clf_ids=[0,1,2,3,4,5,6,7,8],    # indices of the SOMA models to use as teachers
    mode='PSI1to0',    # choose from {'PSI1to0', 'PSI0to1', 'PSI1to0.5', 'PSI0to0.5', 'PSI0.5to1', 'PSI0.5to0'}
    save_path='Melange_params.pth'    # path to save the trained Melange model parameters
)

df_test = pd.read_csv('path/to/your/df_test_data') # df_test contains column 'seq'

gen_seq_psi_pred, org_seq_psi_pred = Melange.evaluate_reconstructions(
    df_test,    # pandas DataFrame with column 'seq'
    clf_id=9,    # index of the SOMA model to use for evaluation
    device='cuda',    # 'cuda' or 'cpu' 
    max_len=250,    # maximum sequence length
    params='Melange_params.pth'   # path to the trained Melange model parameters
)

# visualize any parent and generated sequence using a trained Melange model
Melange.reconstruct_sequence(
    df_test.iloc[0]['seq'],    # input sequence
    max_len=250,    # maximum sequence length
    device='cuda',    # 'cuda' or 'cpu'
    params='Melange_params.pth'    # path to the trained Melange model parameters
)

Metadata

Release files for spice-bio 1.0.1

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

Source distribution (sdist)

Source distribution for spice-bio 1.0.1
File Size Uploaded
spice-bio-1.0.1.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spice-bio 1.0.1
File Interpreter ABI Platform
spice_bio-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / spice-bio-1.0.1.tar.gz

Download URL spice-bio-1.0.1.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cdfd04bce2f5e5cc7f6bdfab48d0e187f09e685c43f0b627b8218ae989414464
BLAKE2b-256 checksum
How to use checksums
a38968e0db86c312d39fc900a12afba0bf70bf2a0f0850bf798871add096bd92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / spice_bio-1.0.1-py3-none-any.whl

Download URL spice_bio-1.0.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7574f4f0c5f9a131ba240e63a2d5da7e2d439abc6fce9221110176c6eda32411
BLAKE2b-256 checksum
How to use checksums
b20c804962900fb35591264b6c08bf34a5f1c0e0d196c534bc8ea938d2cd08d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.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