Skip to content

CodeBio-JLU/CARINA

 
 

Repository files navigation

CARINA — Cross-tissue Adaptive RNA-binding Interpretable Network Architecture

DOI

Overview 🔬

CARINA is a deep learning framework for tissue-resolved modeling of RNA–RBP interactions.
It integrates heterogeneous CLIP-seq resources with tissue-level regulatory signals to learn transferable and interpretable RNA-binding grammars across tissues.

Key features

  • Tissue-aware RBP binding prediction
  • Cross-tissue generalization (train in one tissue, test in another)
  • Multi-context regulatory inference
  • Motif-level interpretability (Integrated Gradients and attention)

Model Architecture 🧠

CARINA implements a context-calibrated topological grammar network for tissue-resolved RBP binding.
Instead of treating RNA–protein recognition as a purely sequential pattern-matching problem, CARINA decomposes the binding process into four coupled operators that separate transfer-stable grammar construction from context-dependent grammar deployment.


Overview of computation

Given an RNA sequence and its base-pair probability matrix, CARINA performs:

  1. Motif-field initialization
  2. Probabilistic pairing transport
  3. Context-calibrated reparameterization
  4. Multiscale motif energy pooling

These stages progressively transform nucleotide-level signals into a segment-level binding representation, which is then used for prediction.


1. Motif-field initialization

CARINA first constructs a nucleotide-resolution feature field from the input RNA sequence.

  • Local convolutional operators capture short-range compositional patterns
  • Batch normalization and nonlinear activation stabilize feature learning
  • Channel-wise recalibration selectively enhances informative motif detectors

This stage produces a motif field, representing local binding evidence across the sequence.


2. Probabilistic pairing transport

To incorporate RNA secondary structure, CARINA lifts the motif field onto a probabilistic pairing graph derived from RNAfold.

  • Base-pair probability matrix defines weighted edges between nucleotides
  • Graph-based propagation diffuses features along structural connections
  • Multi-head self-attention captures long-range and higher-order dependencies

This results in a structure-aware representation that integrates both sequence and topology.


3. Context-calibrated affine reparameterization

CARINA introduces a context-aware normalization mechanism to model tissue-specific regulatory variability.

  • Standard batch normalization is augmented with instance-level channel statistics
  • A lightweight gating mechanism modulates feature scaling dynamically
  • The same motif field can be reweighted differently across biological contexts

This step enables context-dependent deployment of shared regulatory grammar.


4. Multiscale motif energy pooling

Finally, CARINA aggregates motif signals into a segment-level representation.

  • Nucleotide salience is modeled via local interaction operators
  • Motif importance is inferred through structured (convolution-like) attention
  • Hierarchical pooling integrates signals across multiple spatial scales

The output is a compact latent vector summarizing motif-aware and context-calibrated binding evidence.


Outputs

The learned representation is used for two prediction tasks:

  • Binding prediction (peak vs. background)
  • Tissue assignment (multi-label classification across tissues)

Dependencies 📦

Core Python dependencies include:

  • PyTorch (torch, torchvision, torchaudio)
  • PyTorch Geometric (pyg)
  • NumPy, SciPy, Pandas, scikit-learn
  • Matplotlib, seaborn
  • Captum, SHAP, logomaker
  • pybedtools, pysam, pyBigWig, pyranges
  • transformers

External Dependencies 🧰

The following external tools are required:

  • ViennaRNA (RNA secondary structure prediction)
  • bedtools (genomic interval processing)

Make sure they are installed and available in your system PATH.


Installation 🪡

1. Clone the repository

git clone https://github.com/zhuhr213/CARINA.git
cd CARINA

2. Create the conda environment

CARINA was developed with Python 3.12. We recommend creating the environment directly from the provided YAML file.

conda env create -f environment.yml
conda activate torch-env

Usage 🚀

1. Data preparation

Before training, please ensure that:

  • RNA sequences are prepared in FASTA or BED-derived format
  • eCLIP peaks and tissue annotations are properly processed
  • RNA secondary structures are generated using ViennaRNA (RNAfold)

Example:

RNAfold < input.fa > structure.txt

We also provide dataset construction pipelines in: tutorial

2. Model training and validation

You can train the model using either the main script or the provided shell script.

Option 1: Direct Python execution

CUDA_VISIBLE_DEVICES=0 python -u main_CARINA.py \
    --train \
    --arch CARINA \
    --data_dir "$file_dir" \
    --p_name "$file_name" \
    --batch_size 64 \
    --hidden_size 128 \
    --num_att_layers 1 \
    --lr 0.001 \
    --weight_decay 1e-6 \
    --dropout 0.3 \
    --out_dir ./CARINA_results \
    --early_stopping 20 \
    

Option 2: Using shell script (recommended)

bash run_CARINA_train.sh

In validate mode, users can specify the --model_path parameter to load a pretrained model trained in a different context, enabling train-in-one, test-in-another cross-context prediction.

3. Model interpretation

CARINA provides saliency-based interpretability to identify nucleotide-level contributions to RBP binding predictions. This allows users to uncover motif-like patterns and regulatory signals learned by the model.

Users can generate saliency maps using the main entry script:

CUDA_VISIBLE_DEVICES=0 python -u main_CARINA.py \
    --saliency_img \
    --arch CARINA \
    --data_dir "$file_dir" \
    --p_name "$file_name" \
    --batch_size 64 \
    --hidden_size 128 \
    --num_att_layers 1 \
    --lr 0.001 \
    --weight_decay 1e-6 \
    --dropout 0.3 \
    --out_dir ./CARINA_results \
    --early_stopping 20

Alternatively, users can directly run the provided shell script:

bash run_CARINA_saliency_img.sh

The generated outputs include:

  • Nucleotide-level saliency scores
  • Visualization of high-attention binding regions
  • Motif-like patterns inferred from model attribution

For RNA sequences outside the provided datasets, we offer a complete workflow in the tutorials: tutorial

This includes:

  • Construction of model-compatible input data
  • End-to-end saliency generation
  • Visualization of interpretability results

The corresponding Jupyter Notebook demonstrates how to process arbitrary RNA sequences and obtain biologically meaningful interpretation from CARINA.


Data Availability 📊

All datasets used in this study, including:

  • tissue-resolved RBP binding peaks derived from ENCODE and GTEx integration
  • independent validation datasets (e.g., POSTAR)
  • processed datasets for tissue-resolved regulatory modeling

are available at:


License 💼

This project is licensed under the Apache License 2.0.


Thank you for using CARINA! Any questions, suggestions or advice are welcome!
Contact: lixt314@jlu.edu.cn, zhuhr213@gmail.com

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 46.2%
  • Jupyter Notebook 41.8%
  • Perl 10.4%
  • Shell 1.3%
  • R 0.3%