### Install OpenSpliceAI from source Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Clone the OpenSpliceAI repository and install it from source using the setup.py script. ```bash git clone https://github.com/Kuanhao-Chao/OpenSpliceAI.git cd OpenSpliceAI python setup.py install ``` -------------------------------- ### Example Training Command Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_train.rst This example demonstrates how to train a SpliceAI-PyTorch model using human MANE datasets. Ensure the HDF5 files are generated or downloaded beforehand. ```bash openspliceai train \ --flanking-size 10000 \ --exp-num full_dataset \ --train-dataset /path/to/dataset_train.h5 \ --test-dataset /path/to/dataset_test.h5 \ --output-dir /path/to/model_train_outdir/ \ --project-name human_MANE_adaptive_lr \ --random-seed 22 \ --model SpliceAI \ --loss cross_entropy_loss \ --epochs 20 \ --patience 5 \ --scheduler ReduceLROnPlateau \ --early-stopping \ -d ``` -------------------------------- ### Check OpenSpliceAI Installation Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Run this command after installation to verify that OpenSpliceAI is set up correctly and to view its usage information and version details. ```bash openspliceai -h ``` -------------------------------- ### GPL Notice for Program Startup (Interactive Mode) Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/license.rst If your program has terminal interaction, display this notice when it starts in interactive mode. It informs users about the lack of warranty and how to view license details. ```text Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Install PyTorch with GPU support Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Installs PyTorch with GPU support using pip, specifying the CUDA version. Ensure NVIDIA drivers and CUDA toolkit are installed. ```bash pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 ``` -------------------------------- ### Transfer Learning Example Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_transfer.rst This example demonstrates how to initiate transfer learning from a human-trained model to adapt it for a new species. It requires specifying training data and the pre-trained model checkpoint. ```bash openspliceai transfer \ --train-dataset dataset_train.h5 \ ``` -------------------------------- ### Install OpenSpliceAI via pip Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Use this command to install OpenSpliceAI and its dependencies from PyPI. Pip handles dependency resolution automatically. ```bash pip install openspliceai ``` -------------------------------- ### OpenSpliceAI Terminal Output Example Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Example of the expected terminal output when running the OpenSpliceAI check command, showing the framework's purpose. ```text ==================================================================== Deep learning framework to train your own SpliceAI model ==================================================================== ``` -------------------------------- ### Install mappy via pip Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Installs the mappy package using pip. ```bash pip install mappy ``` -------------------------------- ### Install OpenSpliceAI via conda Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Install OpenSpliceAI and its dependencies using conda for an easy-to-manage sandboxed environment. ```bash conda install -c bioconda openspliceai ``` -------------------------------- ### Predict Splice Sites for Human Genes Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_predict.rst This example demonstrates how to use the 'predict' subcommand with a specified model checkpoint and input FASTA file for human gene splice site prediction. ```bash openspliceai predict \ --model /path/to/model_best.pt \ ``` -------------------------------- ### Install mappy via conda Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Installs the mappy package, which provides Python bindings for minimap2, using the bioconda channel. ```bash conda install -c bioconda mappy ``` -------------------------------- ### Create Training and Testing HDF5 Datasets Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/quick_start_guide/quickstart_create-data.rst Use the create-data subcommand with specified parameters to generate HDF5 files for training and testing. Ensure you have the necessary FASTA genome and GFF annotation files. ```bash openspliceai create-data \ --remove-paralogs \ --min-identity 0.8 \ --min-coverage 0.8 \ --parse-type canonical \ --split-method human\ --canonical-only \ --genome-fasta GCF_000001405.40_GRCh38.p14_genomic_10_sample.fna \ --annotation-gff MANE.GRCh38.v1.3.refseq_genomic_10_sample.gff \ --output-dir train_test_dataset/ ``` -------------------------------- ### Create Training and Testing Datasets Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/pretrained_models/GRCh38_MANE.rst Use this command to generate datasets for training and testing. Ensure you have the genome FASTA and annotation GFF files. ```bash openspliceai create-data \ --genome-fasta GCF_000001405.40_GRCh38.p14_genomic.fna \ --annotation-gff MANE.GRCh38.v1.2.refseq_genomic.gff \ --output-dir ./MANE/ \ --parse-type maximum ``` -------------------------------- ### Standard GPL Notice for Source Files Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/license.rst Include this notice at the beginning of each source file to state the exclusion of warranty and specify the license terms. Ensure it includes copyright information and a pointer to the full license. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Install PyTorch CPU-only version Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/installation.rst Installs the CPU-only version of PyTorch using pip. Note that conda packages for PyTorch are no longer available. ```bash pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu ``` -------------------------------- ### Create Mouse Training and Test Datasets Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/train_your_own_model/train_mouse.rst Use the `create-data` subcommand with mouse-specific genome and annotation files to generate HDF5 datasets. Key options include filtering paralogs, setting identity and coverage thresholds, selecting canonical transcripts, and applying mouse-specific data splitting rules. ```bash openspliceai create-data \ --genome-fasta mouse_genome.fna \ --annotation-gff mouse_annotation.gff \ --output-dir train_test_dataset_mouse/ \ --remove-paralogs \ --min-identity 0.8 \ --min-coverage 0.8 \ --parse-type canonical \ --write-fasta \ --split-method mouse \ --canonical-only ``` -------------------------------- ### Example VCF Annotation String Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_variant.rst An example of an annotated VCF line, detailing the alternate allele, gene symbol, delta scores, and delta positions for splice site alterations. ```text A|MYGENE|0.27|0.00|0.09|0.02|3|-4|7|-2 ``` -------------------------------- ### Openspliceai Train Subcommand Usage Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_train.rst This shows the command-line arguments and options available for the 'train' subcommand. Use this to configure training parameters like epochs, scheduler, output directory, and datasets. ```text usage: openspliceai train [-h] [--epochs EPOCHS] [--scheduler {MultiStepLR,CosineAnnealingWarmRestarts}] [--early-stopping] [--patience PATIENCE] --output-dir OUTPUT_DIR --project-name PROJECT_NAME [--exp-num EXP_NUM] [--flanking-size {80,400,2000,10000}] [--random-seed RANDOM_SEED] --train-dataset TRAIN_DATASET --test-dataset TEST_DATASET [--loss {cross_entropy_loss,focal_loss}] [--model MODEL] optional arguments: -h, --help show this help message and exit --epochs EPOCHS, -n EPOCHS Number of epochs for training --scheduler {MultiStepLR,CosineAnnealingWarmRestarts}, -s {MultiStepLR,CosineAnnealingWarmRestarts} Learning rate scheduler --early-stopping, -E Enable early stopping --patience PATIENCE, -P PATIENCE Number of epochs to wait before early stopping --output-dir OUTPUT_DIR, -o OUTPUT_DIR Output directory to save the data --project-name PROJECT_NAME, -p PROJECT_NAME Project name for the train experiment --exp-num EXP_NUM, -e EXP_NUM Experiment number --flanking-size {80,400,2000,10000}, -f {80,400,2000,10000} Flanking sequence size --random-seed RANDOM_SEED, -r RANDOM_SEED Random seed for reproducibility --train-dataset TRAIN_DATASET, -train TRAIN_DATASET Path to the training dataset --test-dataset TEST_DATASET, -test TEST_DATASET Path to the testing dataset --loss {cross_entropy_loss,focal_loss}, -l {cross_entropy_loss,focal_loss} Loss function for training --model MODEL, -m MODEL ``` -------------------------------- ### Run OpenSpliceAI Calibration Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/quick_start_guide/quickstart_calibrate.rst Execute the calibration process using the `openspliceai calibrate` command. Ensure you provide the path to your pre-trained model, test dataset, flanking size, and an output directory. ```bash openspliceai calibrate \ --pretrained-model model_10000nt_rs10.pt \ --test-dataset dataset_test.h5 \ --flanking-size 10000 \ --output-dir ./calibration_results/ ``` -------------------------------- ### Transfer Learning Command-Line Arguments Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_transfer.rst This command initiates the transfer learning process. It specifies the dataset, pre-trained model, freezing strategy, learning rate scheduler, loss function, training epochs, early stopping patience, and output directory. ```bash --test-dataset dataset_test.h5 \ --pretrained-model OpenSpliceAI-MANE-best.pt \ --flanking-size 400 \ --unfreeze 2 \ --scheduler CosineAnnealingWarmRestarts \ --loss focal_loss \ --epochs 15 \ --patience 3 \ --early-stopping \ --project-name new_species_transfer \ --output-dir ./transfer_outputs/ ``` -------------------------------- ### Create Training and Test Datasets with OpenSpliceAI Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/train_your_own_model/train_human_mane.rst Use the `create-data` subcommand to process genome FASTA and MANE GFF files into HDF5 datasets. This command one-hot encodes gene sequences and labels splice sites, with options to filter paralogs and select canonical transcripts. ```bash openspliceai create-data \ --genome-fasta GCF_000001405.40_GRCh38.p14_genomic.fna \ --annotation-gff MANE.GRCh38.v1.3.refseq_genomic.gff \ --output-dir train_test_dataset_MANE/ \ --remove-paralogs \ --min-identity 0.8 \ --min-coverage 0.8 \ --parse-type canonical \ --write-fasta \ --split-method human \ --canonical-only ``` -------------------------------- ### Create Human MANE Dataset Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_create-data.rst Use this command to generate training and testing datasets for the human MANE dataset. Ensure you have downloaded the reference genome and annotation files. ```bash openspliceai create-data \ --genome-fasta GCF_000001405.40_GRCh38.p14_genomic.fna \ --annotation-gff MANE.GRCh38.v1.3.refseq_genomic.gff \ --output-dir train_test_dataset_MANE/ ``` -------------------------------- ### OpenSpliceAI Calibrate Subcommand Usage Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_calibrate.rst This is the command-line usage for the openspliceai calibrate subcommand. It outlines all available arguments for performing temperature scaling calibration. ```text usage: openspliceai calibrate [-h] [--epochs EPOCHS] [--early-stopping] [--patience PATIENCE] --output-dir OUTPUT_DIR --project-name PROJECT_NAME [--exp-num EXP_NUM] [--flanking-size {80,400,2000,10000}] [--random-seed RANDOM_SEED] [--temperature-file TEMPERATURE_FILE] --pretrained-model PRETRAINED_MODEL --train-dataset TRAIN_DATASET --test-dataset TEST_DATASET [--loss {cross_entropy_loss,focal_loss}] optional arguments: -h, --help show this help message and exit --epochs EPOCHS, -n EPOCHS Number of epochs for training --early-stopping, -E Enable early stopping --patience PATIENCE, -P PATIENCE Number of epochs to wait before early stopping --output-dir OUTPUT_DIR, -o OUTPUT_DIR Output directory for model checkpoints and logs --project-name PROJECT_NAME, -p PROJECT_NAME Project name for the fine-tuning experiment --exp-num EXP_NUM, -e EXP_NUM Experiment number --flanking-size {80,400,2000,10000}, -f {80,400,2000,10000} Flanking sequence size --random-seed RANDOM_SEED, -r RANDOM_SEED Random seed for reproducibility --temperature-file TEMPERATURE_FILE, -T TEMPERATURE_FILE Path to the temperature file --pretrained-model PRETRAINED_MODEL, -m PRETRAINED_MODEL Path to the pre-trained model --train-dataset TRAIN_DATASET, -train TRAIN_DATASET Path to the training dataset --test-dataset TEST_DATASET, -test TEST_DATASET Path to the testing dataset --loss {cross_entropy_loss,focal_loss}, -l {cross_entropy_loss,focal_loss} Loss function to use ``` -------------------------------- ### OpenSpliceAI create-data Subcommand Usage Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_create-data.rst This is the command-line usage for the create-data subcommand, detailing all available arguments and their purposes. Use this to understand how to configure the data processing pipeline. ```text usage: openspliceai create-data [-h] --annotation-gff ANNOTATION_GFF --genome-fasta GENOME_FASTA --output-dir OUTPUT_DIR [--parse-type {canonical,all_isoforms}] [--biotype {protein-coding,non-coding}] [--chr-split {train-test,test}] [--split-method {random,human}] [--split-ratio SPLIT_RATIO] [--canonical-only] [--flanking-size FLANKING_SIZE] [--verify-h5] [--remove-paralogs] [--min-identity MIN_IDENTITY] [--min-coverage MIN_COVERAGE] [--write-fasta] optional arguments: -h, --help show this help message and exit --annotation-gff ANNOTATION_GFF Path to the GFF file --genome-fasta GENOME_FASTA Path to the FASTA file --output-dir OUTPUT_DIR Output directory to save the data --parse-type {canonical,all_isoforms} Type of transcript processing --biotype {protein-coding,non-coding} Biotype of transcript processing --chr-split {train-test,test} Whether to obtain testing or both training and testing groups --split-method {random,human} Chromosome split method for training and testing dataset --split-ratio SPLIT_RATIO Ratio of training and testing dataset --canonical-only Flag to obtain only canonical splice site pairs --flanking-size FLANKING_SIZE Sum of flanking sequence lengths on each side of input (i.e. 40+40) --verify-h5 Verify the generated HDF5 file(s) --remove-paralogs Remove paralogous sequences between training and testing dataset --min-identity MIN_IDENTITY Minimum minimap2 alignment identity for paralog removal between training and testing dataset --min-coverage MIN_COVERAGE Minimum minimap2 alignment coverage for paralog removal between training and testing dataset ``` -------------------------------- ### Bash Command for Transfer Learning Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/quick_start_guide/quickstart_transfer.rst Initiates transfer learning using the OpenSpliceAI CLI. This command loads a pre-trained model, unfreezes all layers, and fine-tunes the model on custom training and testing datasets for a specified number of epochs. ```bash openspliceai transfer \ --train-dataset dataset_train.h5 \ --test-dataset dataset_test.h5 \ --pretrained-model model_10000nt_rs10.pt \ --flanking-size 10000 \ --unfreeze-all \ --epochs 10 \ --early-stopping \ --project-name new_species_transfer \ --output-dir ./transfer_out/ ``` -------------------------------- ### Train OpenSpliceAI Model with Human MANE Dataset Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/train_your_own_model/train_human_mane.rst Use this command to initiate the training process for a SpliceAI model. Ensure the dataset paths and output directory are correctly specified. Reproducibility is ensured by setting a random seed. ```bash openspliceai train \ --flanking-size 10000 \ --exp-num full_dataset \ --train-dataset train_test_dataset_MANE/dataset_train.h5 \ --test-dataset train_test_dataset_MANE/dataset_test.h5 \ --output-dir model_train_outdir/ \ --project-name OpenSpliceAI-MANE \ --random-seed 1 \ --model SpliceAI \ --loss cross_entropy_loss ``` -------------------------------- ### Calibrate a Trained Model with OpenSpliceAI Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_calibrate.rst Use this command to calibrate a trained model. Provide the path to the pretrained model and the test dataset, along with parameters for flanking size and output directory. A random seed can be set for reproducibility. ```bash openspliceai calibrate \ --pretrained-model model_best.pt \ --test-dataset dataset_test.h5 \ --flanking-size 10000 \ --output-dir ./calibration_results/ \ --random-seed 42 ``` -------------------------------- ### OpenSpliceAI Train Command Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/quick_start_guide/quickstart_train.rst Use this command to train an OpenSpliceAI model. It requires flanking size, training and testing datasets, an output directory, project name, and scheduler/loss function. ```bash openspliceai train \ --flanking-size 10000 \ --train-dataset dataset_train.h5 \ --test-dataset dataset_test.h5 \ --output-dir /path/to/model_train_outdir/ \ --project-name human_MANE_example \ --scheduler CosineAnnealingWarmRestarts \ --loss cross_entropy_loss ``` -------------------------------- ### OpenSpliceAI Transfer Subcommand Usage Source: https://github.com/kuanhao-chao/openspliceai/blob/main/docs/source/content/openspliceai_transfer.rst This shows the command-line usage for the 'openspliceai transfer' subcommand, detailing all available arguments and their purposes. ```text usage: openspliceai transfer [-h] [--epochs EPOCHS] [--scheduler {MultiStepLR,CosineAnnealingWarmRestarts}] [--early-stopping] [--patience PATIENCE] --output-dir OUTPUT_DIR --project-name PROJECT_NAME [--exp-num EXP_NUM] [--flanking-size {80,400,2000,10000}] [--random-seed RANDOM_SEED] --pretrained-model PRETRAINED_MODEL --train-dataset TRAIN_DATASET --test-dataset TEST_DATASET [--loss {cross_entropy_loss,focal_loss}] [--unfreeze-all] [--unfreeze UNFREEZE] optional arguments: -h, --help show this help message and exit --epochs EPOCHS, -n EPOCHS Number of epochs for training --scheduler {MultiStepLR,CosineAnnealingWarmRestarts}, -s {MultiStepLR,CosineAnnealingWarmRestarts} Learning rate scheduler --early-stopping, -E Enable early stopping --patience PATIENCE, -P PATIENCE Number of epochs to wait before early stopping --output-dir OUTPUT_DIR, -o OUTPUT_DIR Output directory for model checkpoints and logs --project-name PROJECT_NAME, -p PROJECT_NAME Project name for the fine-tuning experiment --exp-num EXP_NUM, -e EXP_NUM Experiment number --flanking-size {80,400,2000,10000}, -f {80,400,2000,10000} Flanking sequence size --random-seed RANDOM_SEED, -r RANDOM_SEED Random seed for reproducibility --pretrained-model PRETRAINED_MODEL, -m PRETRAINED_MODEL Path to the pre-trained model --train-dataset TRAIN_DATASET, -train TRAIN_DATASET Path to the training dataset --test-dataset TEST_DATASET, -test TEST_DATASET Path to the testing dataset --loss {cross_entropy_loss,focal_loss}, -l {cross_entropy_loss,focal_loss} Loss function for fine-tuning --unfreeze-all, -A Unfreeze all layers for fine-tuning --unfreeze UNFREEZE, -u UNFREEZE Number of layers to unfreeze for fine-tuning ```