Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

splice_sim

splice_sim is a python based RNA-seq simulation and evaluation package specialized on the simulation nucleotide-conversions and splice isoforms. We use Nextflow and containerization via Docker to wrap splice_sim into a readily executable start-to-end framework for simulating and evaluating complex experimental scenarios with mapping based processing pipelines.

Contents

Features

  • Realistic Illumina short-read simulation using ART
  • Simulation of customizable nucleotide-conversions at configurable rates
  • Simulation of isoforms at configurable splicing states per transcript
  • Mapping accuracies and performance metrics at different scopes of genomic annotation
  • Elaborate output tracks for visual inspection stratified by performance metric

Installation

splice_sim itself is a python package with several dependencies that are best simply installed in a conda environment:

conda env create -f environment.yml

Then clone the splice_sim repository and call its main method:

git clone https://github.com/popitsch/splice_sim.git
cd splice_sim
python main.py

To run our full-blown all-on-one Nextflow based workflow, you simply need to install Nextflow and Docker to have all dependencies available and be ready to go. To run splice_sim on HPC environments, most administrators prefer Singularity (apptainer) containers which can be seamlessly created from our Docker container.

Usage

splice_sim itself is the Python package and includes the simulation engine to both simulate and evaluate datasets. splice_sim provides dedicate commands for the individual logical steps outlined below, starting from creating transcript models, simulating reads from those transcripts and finally evaluating the performance of a given mapper via the produced bam file. The parameters for the highlighted relevant steps for such a process are described in the splice_sim engine.

We have also wrapped a ready-to-use out of the box workflow that executes all step from start to end into our Nextflow workflow with a description provided in the adjacent section. We provide two separate workflows: (i)splice_sim.nf that handles the entire logic contained in the Simulation Pipeline block and (ii)splice_sim_eva.nf that handles everything related to the Evaluation Pipeline block in the diagram below. To avoid supplying an extensive set of parameters to theindividual steps via the command line, we designed splice_sim to be driven by a configuration file in json format that contains all necessary inputs and parameters needed for any of splice_sim steps.

Nextflow workflow

All you need to get started with our workflows is Nextflow and Docker. Typically one would also need to tweak the resource requirements for each of the processes that are executed. We did that already for you for the small (typically expressed genes size) and large (full transcriptome) datasets simulated in our study in the provided nextflow.config.example ready to use. Both workflows need as only input the configuration file file provided by the user.

Simulation workflow splice_sim.nf

This workflow executes the following steps to obtain the simulated truth alignments and mapped read alignments of the mappers under investigation in BAM format as final output:

  • Build a transcript model with splice_sim build_model
  • Simulate reads with ART for all conditions
  • Calculate and encode truth alignments for all conditions
  • Map simulated reads with mappers under investigation for all conditions
  • Postprocess BAM files with splice_sim postfilter_bam

Evaluation workflow splice_sim_eva.nf

This workflow executes the following steps to obtain the evaluation metrics and output files from the simulated truth alignments and mapped read alignments of the mappers under investigation as final output:

  • Evaluate a given read alignment of a mapper with splice_sim evaluate
  • Extract associated metadata of the annotated features under investigation with splice_sim extract_feature_metadata
  • Bundle, package and compress the produced output tables into RDS files to futher process in R with preprocess_results.R

splice_sim engine

The core splice_sim python engine covers isolated steps of the simulation and evaluation process process as highlighted in the previous block diagram. The most important commands along the way a documented in this section.

build_model

The build_model command takes the reference and configuration provided by the user and creates the transcript model and sequence files needed that contains the composition of the transcriptome and serves and input to the read simulation step of splice_sim.

 python splice_sim/main.py build_model --help
usage: main.py [-h] -c config_file [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-o outdir, --outdir outdir
output directory (default is current dir)

create_genome_bam

The create_genome_bam command takes the simulated read set with your short-read simulator of choice (we use ART) and calculates the truth alignments that serve as the reference benchmark in splice_sim.

python splice_sim/main.py create_genome_bam --help
usage: main.py [-h] -m model_file -a config_file [-t threads] [-o outdir]
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-m model_file, --model model_file
model file
-a config_file, --art_sam config_file
ART sam file
-t threads, --threads threads
threads
-o outdir, --outdir outdir
output directory (default is current dir)

postfilter_bam

The postfilter_bam command filters secondary and supplementary reads and highlights isoforms.

python splice_sim/main.py postfilter_bam --help
usage: main.py [-h] -c config_file -b bam_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-b bam_file, --bam bam_file
input bam file
-o outdir, --outdir outdir
output dir

evaluate

The evaluate command runs the splice_sim evaluation routine on a given mapper bam file produced for a condition of the splice_sim simulation run.

python splice_sim/main.py evaluate --help
usage: main.py [-h] -b bam_file -c config_file -m model_file [-f filter_bed] [-t THREADS] -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-b bam_file, --bam_file bam_file
input bam file
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-f filter_bed, --filter_bed filter_bed
Filter regions BED file
-t THREADS, --threads THREADS
used threads
-o outdir, --outdir outdir
output dir

extract_feature_metadata

The extract_feature_metadata extracts comprehensive metadata that lists various characteristics of the genomic features under evaluation.

python splice_sim/main.py extract_feature_metadata --help
usage: main.py [-h] -c config_file -m model_file -o outdir
Copyright (C) 2021 XXX. All rights reserved.
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-c config_file, --config config_file
JSON config file
-m model_file, --model model_file
model file
-o outdir, --outdir outdir
output dir

Running splice_sim with Docker

All the above commands of the splice_sim engine can be run without installing any dependencies out of the box of our Docker container. Simply precede the individual splice_sim calls like illustrated below:

docker run --cpus <number of CPUS> -m <GB memory>g -v $(pwd):$(pwd) -w $(pwd) tobneu/splice_sim:release python <path to splice_sim repository>/main.py

Processing results into R objects (RDS)

We provide a Rscript that takes all splice_sim evaluation outputs and processes them into readily usable RDS objects to be imported in R. The script is located in splice_sim/src/main/R/splice_sim/preprocess_results.R and all dependencies are again wrapped into our splice_simR Docker containertobneu/splice_sim_r:latest.

Rscript --vanilla splice_sim/src/main/R/splice_sim/preprocess_results.R
Error: usage: preprocess_results.R <splice_sim_config> [<outdir>]
Execution halted

Configuration

We made the deliberate decision to have a central configuration file in json format that encapsulate and document all input files and parameters that are driving all splice_sim related processes. Here we document all required and optional parameters:

ParameterDescriptionRequired
dataset_nameName of the simulation run
splice_sim_cmdPath to main.py in the clone splice_sim repository
splice_eva_preprocess_cmdPath to main.py in the cloned splice_sim repository
gene_gffPath to the transcriptome annotation in gff3-format (obtained e.g. from Gencode
intron_gffAnnotated introns from the transcriptome annotation in gff3-format
genome_faReference genome sequence in fasta format
genome_chromosome_sizesChromosome lengths file with chromosome name and chromosome lengths separated by a tab as produced by samtools faidx
genome_conservationGenome conservation score in bigwig format (obtained e.g. from UCSC)
genome_mappabilityGenome mappability score in bigwig format (obtained e.g. from the Hoffman lab)
transcript_dataTranscript state configuration file
transcript_idsSubset of transcript IDs from the reference annotation used in this simulation
isoform_modeFraction of unspliced to mature spliced transcripts
frac_old_matureFraction of pre-existing fully-spliced transcripts before labelling onset
conditionDictionary of the conditions in this simulation defining the base conversion type (ref and alt base), conversion_rates (list of doubles between 0 and 1) and the base_coverage (integer)
mappersDictionary of dictionary of the mappers employed and evaluated in this simulation defining the name of the mapper, the command how to call it, the mapping index and known splice sites file
create_tdfBoolean whether TDF files for track visualization in IGV should be produced
max_ilenInteger defining the maximum considered intron length
min_abundanceInteger defining the minimum abundance value fo a transcript to be considered
random_seedInteger seed to keep simulation deterministic
readlenInteger defining the short read length
write_readsBoolean value defining whether reads should be output to disk or not
write_intron_bamBoolean value defining whether intronic reads should be written to BAM file not
pre_existDirectory of pre-existing runs to restart the simulation in case a run crashes
snp_fileOptional VCF file containing SNVs to be injected into the simulated data. The VCF file may contain the following (optional) properties in the INFO section: prob: conversion probability [0; 1] (optional, default:1), strand: strand specificity [NA, +, -] (optional, default:NA), enable_nc: [yes, no] (optional, default: yes) if yes, configured NC are possible at the same position if no SNV was injected

Find below an example config json:

{
"dataset_name": "test_simulation",
"splice_sim_cmd": "python /software/splice_sim/main.py", # should point to your local splice_sim clone"splice_eva_preprocess_cmd": "Rscript --vanilla /software/splice_sim/src/main/R/splice_sim/preprocess_results.R", # should point to your local splice_sim clone"gene_gff": "/references/gencode.vM21.gff3.gz", # gene annotation GFF3 file"genome_fa": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa",
"genome_chromosome_sizes": "/references/Mus_musculus.GRCm38.dna.primary_assembly.fa.chrom.sizes",
"genome_conservation": "/references/mm10.60way.phastCons60wayEuarchontoGlire.bw", # optional"genome_mappability": "/references/mm10.k24.umap.bedgraph.gz", # optional"transcript_data": "data.config.json", # if this file exists, "transcript_ids": "tids.tsv", # optional (TSV file with one column 'transcript_id' containing all considered transcript ids)"isoform_mode": "1:1", # mode for creating isoform data; '1:1': mat and pre form as in paper (default), 'from_file': data will be loaded from 'transcript_id','abundance','frac_mature','frac_old_mature' columns in the configured transcript_ids file"frac_old_mature": 0, # fraction of OLD RNA that was not exposed to a nucleotide analog "condition": {
"ref": "T", # reference base"alt": "C", # alternat base"conversion_rates": [ 0.02, 0.04 ], # list of conversion rates"base_coverage": 10# used to calculate simulated coverage per tx; 
},
"mappers": {
"STAR": {
"star_cmd": "STAR-2.7.1a",
"star_genome_idx": "star_2.7.1",
"star_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"HISAT3N": {
"hisat3n_cmd": "hisat-3n",
"hisat3n_idx": "/indices/Mus_musculus.GRCm38.dna.primary_assembly",
"hisat3n_kss": "/indices/gencode.vM21.gtf.hisat2_splice_sites.txt"# TXT file with known splice sites
},
"MERANGS": {
"merangs_cmd": "meRanGs",
"star_cmd": "STAR",
"merangs_genome_idx": "/indices/meRanTK-1.2.1b/BSgenomeIDX",
"merangs_splice_gtf": "/indices/gencode.vM21.gtf"# GTF file with known splice sites
},
"SEGEMEHL": {
"segemehl_cmd": "segemehl.x",
"segemehl_ctidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.ctidx",
"segemehl_gaidx": "/indices/segemehl/Mus_musculus.GRCm38.dna.primary_assembly.gaidx"
}
},
"create_tdf": true, "max_ilen": 100000,
"min_abundance": 1,
"random_seed": 1234,
"readlen": 100,
"write_reads": false,
"write_intron_bam": false
}

Output Structure

Mapper count tables

These tables contain the performance metrics for a given mapper in the count/*.counts.tsv.gz files.

ColumnDescriptionNotes
mapperName of the respective mapper; Supported mappers are STAR, HISAT3N, MERANGS and SEGEMEHL
conversion_rateConversion rate between 0 and 1.0
fidfeature/transcript id
true_isoformname of the isoform (as configured) the read originates from
cv11 if read contains at least one NC or 0 otherwise
cv21 if read contains at least two NC or 0 otherwise
se11 if read contains at least one simulated sequencing error or 0 otherwise
se21 if read contains at least two simulated sequencing errors or 0 otherwise
classificationRead classification: TP: true positive, FN: false negative: FP_raw: false-positive/not
normalised, FP: false-positive/normalised
countread count. FP classified rows may include fractions
class_typeread type: acc: acceptor spanning, don: donor spanning, spl: spliced readSJ only

Metadata tables

These tables contain various metadata for the genomic intervals under investigation stratified at transcript level (tx), exon / intron feature level (fx) or splice-junction level (sj) in the meta/*.metadata.tsv.gz files.

ColumnDescriptionNotes
tidTranscript ID
fidFeature ID (intron or exon ID)FX+SJ only
ftypeFeature type: tx, fx, don, acc or spl
rnkRank. For transcripts this is the number exons, for introns/exons it is the rank from the transcript 5'-end
chromosomeChromosome of the annotate feature
start / endGenomic start/end position of the annotated feature
strandStrand of the annotation
A/C/T/GNumber of A/C/T/G bases in the annotated sequence
mean_mapMean mappability for the annotated feature. Calculated from the configured mappability bedgraph file
tx_rnkRank in the transcriptFX+SJ only
num_exonsNumber of exons in tx; 1,2,3,4,5,>5
tx_mappabilityTranscript mappability, factor with levels: low, medium, highFX+SJ only
lenLength of annotated feature
mappabilityAnnotation mappability, factor with levels: low, medium, high
GCFraction of G/C for annotated feature
frac_convertibleFraction of convertible bases for annotationSJ only
convertibilityConvertibility, factor with levels: low, medium, high
don_ex_A/C/T/GNumber of A/C/T/G bases in exonic part of donor window
(genomic window centred on splice donor site with size: 2xreadlen+1)
SJ only
don_in_A/C/T/GNumber of A/C/T/G bases in intronic part of donor windowSJ only
don_win_mapMean mappability of donor windowSJ only
don_mappabilityDonor window mappability, factor w levels: low, medium, highSJ only
don_ex_fcFraction of convertible bases in the exonic part of the donor windowSJ only
don_in_fcFraction of convertible bases in the intronic part of the donor windowSJ only
ac_*Analogous to the splice donor columns above, but for splice acceptor siteSJ only

Customization

NC simulation

Splice_sim simulates nucleotide conversions in reads based on Bernoulli processes with given (configured) conversion probabilities. While we believe this to be appropriate for simulating BS-seq or SLAM-seq data (see our paper), it might not be suitable for other use-cases where, e.g., conversion prob abilities are affected by local sequence context (e.g., RNA-editing) or the like.

For customization of the NC simulation process, users may alter/extend the splice_sim.simulator.modify_bases method that has access to

  • the sequence of the simulated read (w/o NC)
  • genomic coordinates and orientation (strand) of the simulated read
  • configured NC reference and alternate bases
  • the configured conversion_rate
  • a list of convertible positions in the read
  • a list of SNPs that affect this read (if configured)

About

Splice_sim: a nucleotide-conversion enabled RNA-seq simulation and evaluation framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages