Skip to content

Commit

Permalink
update READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
balajtimate committed Oct 27, 2023
1 parent 8afcd64 commit 1fc38e8
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 241 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
# Simulating single cell RNA library generation (scRNA-seq)
# scRNAsim: Simulating single cell RNA (scRNA-seq) library generation
The projects implements a simulation of single cell RNA sequencing (scRNA-seq), accounting for some common sources noise that complicate the analysis of the resulting data.

### Setting up the virtual environment

Create and activate the environment with necessary dependencies with Conda:

```bash
conda env create -f environment.yml
conda activate scrnasim-toolz
```

### Tools

The tools available in this repo are:
1. Transcript sampler
2. Structure generator
3. Sequence extractor
4. Priming site predictor
5. cDNA generator
6. Fragment selector
7. Read sequencer

### Description

Although all cells in a multicellular organism carry the same genomic information, they differ a lot in their function, due to the fact that they are equipped with distinct toolboxes of molecular functions, implemented by different proteins and RNAs. Thus, being able to detect and measure the abundance of gene products (RNAs and/or proteins) in individual cells holds the key to understanding how organisms are organized and function. In the past decade, much progress has been made in the development of technologies for single cell RNA sequencing. They make use of microfluidic devices that allow RNA-seq sample preparation for individual cells encapsulated in droplets, followed by pooling of the resulting DNA fragments and sequencing. The broadly used 10x Genomics technology uses oligo-dT primers to initiate the cDNA sequencing from the poly(A) tails of fragmented RNAs. Subsequent sequencing yields *libraries* of relatively short (100-200 nucleotides) *reads* that come predominantly from the 3’ ends of RNAs given the priming on the poly(A) tail. As in the ideal case (no amplification bias) each read came from the end of one mRNA, simply counting the reads that map to mRNAs of individual genes provides estimates of the expression levels of those genes within the respective cell. Currently, typical data sets cover thousands of genes in tens-to-hundreds of thousands of cells. However, we are still far from being able to prepare ideal libraries, for many reasons. First, as gene expression is a bursty, stochastic process, there will be fluctuations in the number of RNAs (corresponding to a given gene) that are present in any one cell at the time of sampling, even when the time-average of those RNA numbers were to be the same across cells. Secondly, the sample preparation steps are carried out by various enzymes with limited efficiency. This leads to substantial fluctuations in the number of molecules that are “captured” for a gene in a given cell, even if all cells were to have the same abundance of these molecules at the time of sampling. Third, the biochemical reactions that are part of sample preparation do not have absolute specificity. A clear example is the priming of the cDNA synthesis with oligo(dT): although the primer is intended for the poly(A) tails at the 3’ ends of RNAs, it is clear that the primer also binds to A-rich stretches that are internal to transcripts, and especially located in intronic regions. Finally, a conceptual issue with the single cell data is that one cannot apply the principle of averaging measurement values across replicate experiments to obtain more precise estimates, because we do not know which cells could be considered replicates of each other (if that is at all conceivable).

Expand Down
42 changes: 25 additions & 17 deletions scRNAsim_toolz/cdna_generator/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# cDNA Generator module
## Usage
```
usage: cdna-generator [-h] -ifa INPUT_FASTA -igtf INPUT_GTF -icpn INPUT_COPY_NUMBER -ofa OUTPUT_FASTA -ocsv OUTPUT_CSV [-v]
Generate cDNA sequences based on primer probabilities.
options:
-h, --help show this help message and exit
-ifa INPUT_FASTA, --input_fasta INPUT_FASTA
genome fasta file
-igtf INPUT_GTF, --input_gtf INPUT_GTF
gtf file
-icpn INPUT_COPY_NUMBER, --input_copy_number INPUT_COPY_NUMBER
input copy number (csv) file
-ofa OUTPUT_FASTA, --output_fasta OUTPUT_FASTA
output fasta file
-ocsv OUTPUT_CSV, --output_csv OUTPUT_CSV
output fasta file
```
Example:
```
cdna-generator -ifa tests/cdna_generator/files/transcript.fasta -igtf tests/cdna_generator/files/Example_GTF_Input.GTF -icpn tests/cdna_generator/files/copy_number_input.csv -ofa cdna_seq.fa -ocsv cdna_counts.csv
```

## Overview
Generate cDNA based on mRNA transcript sequences and the coresponding priming probabilities.

## Example usage
A simple example can be run from the test_files directory:

python ../cdna/cli.py -ifa yeast_example.fa -icpn copy_number_input.csv -igt Example_GTF_Input.GTF -ofa cDNA.fasta -ocsv cDNA.csv

## Installation

pip install .

## Docker
A docker image is available, to fetch this image:

docker pull ericdb/my-image

To run a simple example using this image:

docker run my-image python cdna/cli.py -ifa test_files/yeast_example.fa -icpn test_files/copy_number_input.csv -igt test_files/Example_GTF_Input.GTF -ofa test_files/cDNA.fasta -ocsv test_files/cDNA.csv

## License

Expand Down
2 changes: 1 addition & 1 deletion scRNAsim_toolz/cdna_generator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
"""
parser = argparse.ArgumentParser(
prog="cDNA generator",
prog="cdna-generator",
description="Generate cDNA sequences based on primer probabilities.",
)
parser.add_argument(
Expand Down
44 changes: 27 additions & 17 deletions scRNAsim_toolz/fragment_selector/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
# Terminal fragment selecting
# Terminal fragment selector

## Usage
```
usage: fragment-selector [-h] --fasta FASTA --counts COUNTS -o OUTPUT [--mean MEAN] [--std STD] [-s SIZE] [--sep SEP] [-v]
Takes as input FASTA file of cDNA sequences, a CSV/TSV with sequence counts, and mean and std. dev. of fragment lengths and 4 nucleotide probabilities for the cuts. Outputs most terminal fragment (within desired length
range) for each sequence.
options:
-h, --help show this help message and exit
--fasta FASTA Path to FASTA file with cDNA sequences
--counts COUNTS Path to CSV/TSV file with sequence counts
-o OUTPUT, --output OUTPUT
output file path
--mean MEAN Mean fragment length (default: 300)
--std STD Standard deviation fragment length (defafult: 60)
-s SIZE, --size SIZE Chunk size for batch processing
--sep SEP Sequence counts file separator.
```

Example:

`fragment-selector --fasta tests/fragment_selector/files/test.fasta --counts tests/fragment_selector/files/test.csv --mean 50 --output fragments.fa`
## Overview
Simulating single cell RNA library generation (scRNA-seq)

This repository is as part of the Uni Basel course <E3: Programming for Life Science – 43513>. To test the accuracy of scRNA-seq data we generated the *synthetic data*. That is, we reconstruct the properties of the experimental data set and determine whether the computational analysis can recover properties of the data that was assumed in the simulation. This is never trivial since setting the ground truth is much needed in the computational method to evaluate the result.

# Synopsis

As part of the sub-project, we implemented python code for selecting terminal fragments. Detailed distribution used for the selecting fragments can be found below, summarised in [this paper](https://www.nature.com/articles/srep04532#MOESM1).
> Next Generation Sequencing (NGS) technology is based on cutting DNA into small fragments and their massive parallel sequencing. The multiple overlapping segments termed “reads” are assembled into a contiguous sequence. To reduce sequencing errors, every genome region should be sequenced several dozen times. This sequencing approach is based on the assumption that genomic DNA breaks are random and sequence-independent. However, previously we showed that for the sonicated restriction DNA fragments the rates of double-stranded breaks depend on the nucleotide sequence. In this work we analyzed genomic reads from NGS data and discovered that fragmentation methods based on the action of the hydrodynamic forces on DNA, produce similar bias. Consideration of this non-random DNA fragmentation may allow one to unravel what factors and to what extent influence the non-uniform coverage of various genomic regions.
As a whole project, we implemented a procedure for sampling reads from mRNA sequences, incorporating a few sources of “noise”. These include the presence of multiple transcript isoforms from a given gene, some that are incompletely spliced, stochastic binding of primers to RNA fragments and stochastic sampling of DNA fragments for sequencing. We will then use standard methods to estimate gene expression from the simulated data. We will repeat the process multiple times, each time corresponding to a single cell. We will then compare the estimates obtained from the simulated cells with the gene expression values assumed in the simulation. We will also try to explore which steps in the sample preparation have the largest impact on the accuracy of gene expression estimates.


# Usage

CLI arguments:
- fasta (required): Path to FASTA file with cDNA sequences
- counts (required): Path to CSV/TSV file with sequence counts
Expand All @@ -26,20 +50,6 @@ CLI arguments:
Output:
- Text file with most terminal fragments for each sequence.

To install package, run

```
pip install .
```


# Development

To build Docker image, run

```
docker build -t terminal_fragment_selector .
```

# License

Expand Down
37 changes: 22 additions & 15 deletions scRNAsim_toolz/priming_site_predictor/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# Priming Site Predictor of Transcript Sequences

## Overview
Priming Site Predictor which uses a seed-and-extension algorithm (*RIblast*: https://github.com/fukunagatsu/RIblast) to *Predict Priming Sites* of oligo dT primers in target sequences. Furthermore, *Binding Energies* are calculated and classified with a threshold value. Additionally, the binding sites are associated with *Binding Probabilities* and stored in a *gtf file* for further processes.

## Version
Version 0.1.0 (2022/11/15)

## Installation from GitLab
Priming Site Predictor requires Python 3.9 or later.
## Usage
```
usage: priming-site-predictor [-h] [-f FASTA_FILE] [-p PRIMER_SEQUENCE] [-e ENERGY_CUTOFF] [-r RIBLAST_OUTPUT] [-o OUTPUT_FILENAME] [-v]
Install Priming Site Predictor from GitLab using:
Compute potential priming sites using RIBlast.
options:
-h, --help show this help message and exit
-f FASTA_FILE, --fasta-file FASTA_FILE
Fasta-formatted file of transcript sequences
-p PRIMER_SEQUENCE, --primer-sequence PRIMER_SEQUENCE
Primer sequence
-e ENERGY_CUTOFF, --energy-cutoff ENERGY_CUTOFF
Energy cutoff for interactions
-r RIBLAST_OUTPUT, --riblast-output RIBLAST_OUTPUT
Path to RIBlast output file
-o OUTPUT_FILENAME, --output-filename OUTPUT_FILENAME
Path where the output gtf should be written
```
git clone https://git.scicore.unibas.ch/zavolan_group/tools/priming-site-predictor.git
cd priming-site-predictor
```
Create scRNA-seq-simulation conda environment:

Example:
```
conda env create --file environment.yml
conda activate scrna-seq-sim
priming-site-predictor --riblast-output tests/priming_site_predictor/files/RIBlast_output_example.txt --output-filename priming_sites.gtf
```

## Overview
Priming Site Predictor which uses a seed-and-extension algorithm (*RIblast*: https://github.com/fukunagatsu/RIblast) to *Predict Priming Sites* of oligo dT primers in target sequences. Furthermore, *Binding Energies* are calculated and classified with a threshold value. Additionally, the binding sites are associated with *Binding Probabilities* and stored in a *gtf file* for further processes.

## Usage
```
usage: primingsitepredictor [-h] [-f FASTA_FILE] [-p PRIMER_SEQUENCE] [-e ENERGY_CUTOFF] [-r RIBLAST_OUTPUT] [-o OUTPUT_FILENAME]
Expand Down
40 changes: 12 additions & 28 deletions scRNAsim_toolz/read_sequencer/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,37 @@
# Read Sequencer

## Overview

Read Sequencer is a python package to simulate sequencing.
It reads fasta files, simulate sequencing with specified read length and writes the resulting sequences into a new fasta file.


## Installation from github

Read Sequencer requires Python 3.9 or later.

Install Read Sequencer from Github using:

```
git clone https://git.scicore.unibas.ch/zavolan_group/tools/read-sequencer.git
cd read-sequencer
pip install .
```

## Usage

```
usage: readsequencer [-h] [-i INPUT] [-r READ_LENGTH] [-n N_RANDOM] [-s CHUNK_SIZE] output
usage: read-sequencer [-h] [-i INPUT] [-r READ_LENGTH] [-n N_RANDOM] [-s CHUNK_SIZE] [-v] output
Simulates sequencing of DNA sequences specified by an FASTA file.
positional arguments:
output path to FASTA file
optional arguments:
options:
-h, --help show this help message and exit
-i INPUT, --input INPUT
path to FASTA file
-r READ_LENGTH, --read-length READ_LENGTH
read length for sequencing
-n N_RANDOM, --n_random N_RANDOM
n random sequences. Just used if input fasta file is not specified.
n random sequences. Just used if inputfasta file is not specified.
-s CHUNK_SIZE, --chunk-size CHUNK_SIZE
chunk_size for batch processing
```

Examples:
```
read-sequencer -i tests/read_sequencer/files/50_seqs_50_1000_bp.fasta -r 100 sequenced_reads.fa
read-sequencer -n 50 -r 100 random_reads.fa
```

## Docker
## Overview

The docker image is available on docker hub: https://hub.docker.com/r/grrchrr/readsequencer
Read Sequencer is a python package to simulate sequencing.
It reads fasta files, simulate sequencing with specified read length and writes the resulting sequences into a new fasta file.

```
docker pull grrchrr/readsequencer
docker run readsequencer readsequencer --help
```

## Contributors and Contact Information

Expand Down
2 changes: 1 addition & 1 deletion scRNAsim_toolz/read_sequencer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def main():
"""Use CLI arguments to simulate sequencing."""
parser = argparse.ArgumentParser(
prog="readsequencer",
prog="read-sequencer",
description="Simulates sequencing of DNA sequences specified \
by an FASTA file.",
)
Expand Down
44 changes: 26 additions & 18 deletions scRNAsim_toolz/sequence_extractor/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
# Sequence Extractor

# Extract transcript sequences
## Usage
```
usage: sequence-extractor [-h] --mode {pre_bedtools,post_bedtools} [-i INPUT_FASTA_FILE] [-o OUTPUT_FILE_NAME] [-p POLY_A_LENGTH] [--input-gtf-file INPUT_GTF_FILE] [--output-bed-file OUTPUT_BED_FILE] [-v]
extracts transcript sequences from genome sequence andouputs transcripts with PolyA tail added to them
options:
-h, --help show this help message and exit
--mode {pre_bedtools,post_bedtools}
Select the mode of operation('pre_bedtools' or 'post_bedtools').
-i INPUT_FASTA_FILE, --input-fasta-file INPUT_FASTA_FILE
Fasta-formatted file obtained from bedtools
-o OUTPUT_FILE_NAME, --output-file-name OUTPUT_FILE_NAME
Name of the output fasta file
-p POLY_A_LENGTH, --polyA-length POLY_A_LENGTH
Length of the polyA tail to be added (def: 250)
--input-gtf-file INPUT_GTF_FILE
Ordered and processed gtf file for 'pre_bedtools' mode.
--output-bed-file OUTPUT_BED_FILE
Bed file with only exons with strandednesstaken into account for 'pre_bedtools' mode.
```

Example:

### Project aim:
`sequence-extractor --mode post_bedtools --input-fasta-file tests/sequence_extractor/files/post_bedtools_test.fa --polyA-length 250 --output-file-name polyA_output.fa`
## Overview

Given a gtf specification of transcript exon/intron structures and the genome sequence, construct the nucleotide sequence of the transcripts and add poly(A) tails.

Expand Down Expand Up @@ -39,22 +63,6 @@ d. Append via e.g. str.join(), str.ljust()
e. Output the final transcript sequences as a .fasta file. (Final Output)


## Installation

TBA


## Usage/Examples

```python script
transcript_sequence_extractor
--input_fasta_file `genome fasta file`
--input_gtf `gtf file`
--output_file_name `output fasta file`
```



## License

[MIT](https://choosealicense.com/licenses/mit/) license, Copyright (c) 2022 Zavolan Lab, Biozentrum, University of Basel
Expand Down
36 changes: 24 additions & 12 deletions scRNAsim_toolz/structure_generator/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# Synopsis
# Structure generator

The human body contains a countless variety and diversity of cell types, states, and interactions. We wish to understand these tissues and the cell types at much deeper level. Single-cell RNA-seq (scRNA-seq) offers a look into what genes are being expressed at the level of individual cells. Overall this method allows one to identify cell types, find rare or unidentified cell types or states, identify genes that are differently expressed in different cell types, and explore changes in expression whilst including spatial, regulatory, and protein interactions.

We hope that others would find use for this transcript_structure generator that allows one to take input gtf-files of specific gene transcripts and outputs a gtf-file containing intron/exon structures per input transcript. Moreover, one can specify a probability for intron-inclusion which is used to simulate incorrect splicing.
## Usage

# Installation
```
usage: structure-generator [-h] [-p PROB_INCLUSION] [--log LOG] [-v] transcripts annotation
To install package, run
positional arguments:
transcripts Path to csv file with number of transcripts (ID,Count).
annotation Path to gtf-file with exon annotation.
options:
-h, --help show this help message and exit
-p PROB_INCLUSION, --prob-inclusion PROB_INCLUSION
Probability of intron inclusion.
--log LOG Level of logging. Can be one of ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
```
pip install "setuptools>=62.1.0"
pip install .
```

# Usage
Example:

`structure-generator -p 0.3 tests/structure_generator/files/Transcript1.csv tests/structure_generator/files/Annotations2.gtf`
## Overview

The human body contains a countless variety and diversity of cell types, states, and interactions. We wish to understand these tissues and the cell types at much deeper level. Single-cell RNA-seq (scRNA-seq) offers a look into what genes are being expressed at the level of individual cells. Overall this method allows one to identify cell types, find rare or unidentified cell types or states, identify genes that are differently expressed in different cell types, and explore changes in expression whilst including spatial, regulatory, and protein interactions.

We hope that others would find use for this transcript_structure generator that allows one to take input gtf-files of specific gene transcripts and outputs a gtf-file containing intron/exon structures per input transcript. Moreover, one can specify a probability for intron-inclusion which is used to simulate incorrect splicing.



Input:
- csv-formatted file ("ID,Count") with counts for individual transcripts
Expand All @@ -31,12 +43,12 @@ Output:
To generate the sampled transcripts, run

```
transcript-structure-generator --prob-inclusion <probability_inclusion> [--log "INFO"] <transcripts_file> <annotations_file>
structure-generator --prob-inclusion <probability_inclusion> [--log "INFO"] <transcripts_file> <annotations_file>
```

where the transcripts file should be csv-formatted, the annotation file gtf-formatted and the inclusion probability for introns a float in the range [0,1]. The log parameter is optional and can be one of `["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]`. The default is `INFO`.

Sample Transcripts and Annotation files can be found in the repository under main/tests/resources.
Sample Transcripts and Annotation files can be found in the repository under tests/.

# License

Expand Down
Loading

0 comments on commit 1fc38e8

Please sign in to comment.