Files and Software
Introduzione all’analisi RNASeq in R
Dipartimento di Biomedicina e Prevenzione
Marco Chiapello, Revelo Datalab
2023-03-31
Definizione
Il Formato FASTA è un formato di testo per rappresentare le sequenze nucleotidiche o le sequenze aminoacidiche. Sia i nucleotidi che gli aminoacidi sono rappresentati da una singola lettera. Sulla prima linea antecedente alla sequenza nucleotidica/aminoacidica viene riportato il nome della sequenza, preceduto dal simbolo “>”
I file contenenti queste sequenze possono avere varie desinenze: fasta, fna, ffn, faa, fa, frn
Definizione
Il Formato FASTA è un formato di testo per rappresentare le sequenze nucleotidiche o le sequenze aminoacidiche. Sia i nucleotidi che gli aminoacidi sono rappresentati da una singola lettera. Sulla prima linea antecedente alla sequenza nucleotidica/aminoacidica viene riportato il nome della sequenza, preceduto dal simbolo “>”
>NM_001404729.1 Oryza sativa ribulose bisphosphate carboxylase small chain A
CTCAACAGCACTGCTACTGGACATACTCTACTACTACTAGCCAGTAAGCTAGCTAACTAACTACGTGGCT
ATGGCCCCCACCGTGATGGCCTCCTCGGCCACCTCCGTGGCTCCATTCCAAGGGCTCAANNNNNNNNNNN
Definizione
Il Formato FASTA è un formato di testo per rappresentare le sequenze nucleotidiche o le sequenze aminoacidiche. Sia i nucleotidi che gli aminoacidi sono rappresentati da una singola lettera. Sulla prima linea antecedente alla sequenza nucleotidica/aminoacidica viene riportato il nome della sequenza, preceduto dal simbolo “>”
>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken
MADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID
FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA
DIDGDGQVNYEEFVQMMTAKXXXXXX
È possibile creare dei file che contengano più sequenze concatenando singoli FASTA file.
>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken
MADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID
FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA
DIDGDGQVNYEEFVQMMTAK
>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY*
Definizione
Il formato FASTQ è un formato di testo per rappresentare sia le sequenze biologiche (normalmente nucleotidiche) sia il corrispettivo valore di qualità. Sia le sequenze che lo score di qualità sono codificati da una singola lettera (carattere ASCII) per brevità.
Definizione
Il formato FASTQ è un formato di testo per rappresentare sia le sequenze biologiche (normalmente nucleotidiche) sia il corrispettivo valore di qualità. Sia le sequenze che lo score di qualità sono codificati da una singola lettera (carattere ASCII) per brevità.
Un file FASTQ è identificato da 4 linee:
Definizione
Il formato FASTQ è un formato di testo per rappresentare sia le sequenze biologiche (normalmente nucleotidiche) sia il corrispettivo valore di qualità. Sia le sequenze che lo score di qualità sono codificati da una singola lettera (carattere ASCII) per brevità.
@SEQ_ID
GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT
+
!''*((((***+))%%%++)(%%%%).1***-+*''))**55CCF>>>>>>CCCCCCC65
Lo score di qualità è usato per identificare la probabilità di corretta identificazione del corrispondente nucleotide.
Lo score di qualità è usato per identificare la probabilità di corretta identificazione del corrispondente nucleotide.

I FASTQ file possono avere dimensioni molto grandi, per questo nella maggior parte dei casi non avrete a che fare con ilMioFile.fastq, ma con ilMioFile.fastq.gz.
Questo significa che il file è compresso, quindi non leggibile da un editor di testa senza prima essere de-compresso.
Definizione
I file SAM (Sequence Alignment Map) sono file di testo creati originariamente per contenere le sequenze biologiche allineate ad una sequenza di riferimento (genoma).
I file SAM/BAM consistono in 2 parti una intestazione (header) e un allineamento.
@RG ID:1 SM:C5926_BM_IonCode_0118
@PG ID:samtools PN:samtools VN:1.16.1 CL:samtools view -H C5926_BM_IonCode_0118.reassembled.bam
I file SAM/BAM consistono in 2 parti una intestazione (header) e un allineamento.





Definizione
Questi sono i tre principali formati di annotazione. Ci sono molte somiglianze ma anche alcune fondamentali differenze.
Definizione
I file BED (Browser Extensible Data) sono file di testo creati per descrivere caratteristiche del genoma.


Definizione
GFF2 or GTF (General Transfer Format) è un formato usato per descrivere due livelli di annotazione: geni e trascritti.

Definizione
GFF2 or GTF (General Transfer Format) è un formato usato per descrivere due livelli di annotazione: geni e trascritti.

Definizione
GFF3 (General Feature Format) è un file ti testo che contiene informazioni su ogni caratteristica delle sequenze nucleiche o aminiacidiche che descrive. CDS, microRNAs, binding domains, ORFs e molto altro possono essere gestite da questo formato


DEMO
Questo passaggio è importante per
rimuovere i primer adapters
Filtrare le reads di bassa qualità (se presenti)
La rimozione delle reads di bassa qualità semplifica l’analisi a valle
Definizione
L’allineamenro delle reads al genoma permette di individuare le differenze tra le reads e il genoma di riferimento

Spliced Transcripts Alignment to a Reference
STAR is an aligner designed to specifically address many of the challenges of RNA-seq data mapping
STAR requires a lot of computational power

Common to all of these tools is that base-to-base alignment of the reads is avoided, which is the time-consuming step
These lightweight alignment tools provide quantification estimates much faster than older tools (typically more than 20 times faster) with improvements in accuracy
These transcript expression estimates, often referred to as ‘pseudocounts’ or ‘abundance estimates’, can be aggregated to the gene level for use with differential gene expression tools like DESeq2
Salmon is a tool for wicked-fast transcript quantification from RNA-seq data
All you need are:
a FASTA file containing your reference transcripts
a (set of) FASTA/FASTQ file(s) containing your reads
Two strategies:
- mapping-based mode
- alignment-based modePreparing transcriptome indices
> salmon index -t transcripts.fa.gz -i transcripts_indexQuantify
> salmon quant -i transcripts_index -l <LIBTYPE> -1 reads1.fq -2 reads2.fq -o transcripts_quantPrepare your alignments using your favorite aligner
Quantify using Salmon
> salmon quant -t transcripts.fa.gz -l <LIBTYPE> -a aln.bam -o salmon_quantThere are numerous library preparation protocols for RNA-seq
The library type string consists of three parts:
the relative orientation of the reads,
the strandedness of the library,
the directionality of the reads


Name — This is the name of the target transcript provided in the input transcript database (FASTA file).
Length — This is the length of the target transcript in nucleotides.
EffectiveLength — This is the computed effective length of the target transcript. It takes into account all factors being modeled that will effect the probability of sampling fragments from this transcript, including the fragment length distribution and sequence-specific and gc-fragment bias (if they are being modeled).
TPM — This is salmon’s estimate of the relative abundance of this transcript in units of Transcripts Per Million (TPM). TPM is the recommended relative abundance measure to use for downstream analysis.
NumReads — This is salmon’s estimate of the number of reads mapping to each transcript that was quantified. It is an “estimate” insofar as it is the expected number of reads that have originated from each transcript given the structure of the uniquely mapping and multi-mapping reads and the relative abundance estimates for each transcript.
Important
The goal of differential expression testing is to determine which genes are expressed at different levels between conditions.
These tools perform normalization and calculate the abundance of each gene expressed in a sample:
From: https://en.wikipedia.org/wiki/List_of_RNA-Seq_bioinformatics_tools
The count data used for DGE represents the number of sequence reads that originated from a particular gene.

The count data needs to be normalized to account for differences in library sizes and RNA composition between samples
Important
Normalization is essential for differential expression analyses, and also for exploratory data analysis, visualization of data, and whenever you are exploring or comparing counts between or within samples
| Normalization method | Description | Accounted factors | Recommendations for use |
| CPM (counts per million) | counts scaled by total number of reads | sequencing depth | gene count comparisons between replicates of the same samplegroup; NOT for within sample comparisons or DE analysis |
| TPM (transcripts per kilobase million) | counts per length of transcript (kb) per million reads mapped | sequencing depth and gene length | gene count comparisons within a sample or between samples of the same sample group; NOT for DE analysis |
| RPKM/FPKM (reads/fragments per kilobase of exon per million reads/fragments mapped) | similar to TPM | sequencing depth and gene length | gene count comparisons between genes within a sample; NOT for between sample comparisons or DE analysis |
| DESeq2’s median of ratios [1] | counts divided by sample-specific size factors determined by median ratio of gene counts relative to geometric mean per gene | sequencing depth and RNA composition | gene count comparisons between samples and for DE analysis; NOT for within sample comparisons |
Which samples are similar to each other, which are different?
Does this fit to the expectation from the experiment’s design?
What are the major sources of variation in the dataset?
Log2-transformed normalized counts are used to assess similarity between samples using:

Important
Prior to differential expression analysis it is beneficial to omit genes that have little or no chance of being detected as differentially expressed
Genes with zero counts in all samples
Genes with an extreme count outlier
Genes with a low mean normalized counts
Important
Prior to differential expression analysis it is beneficial to omit genes that have little or no chance of being detected as differentially expressed

Important
Prior to differential expression analysis it is beneficial to omit genes that have little or no chance of being detected as differentially expressed
DESeq2 will perform this filtering by default,
however other DE tools will not


So what do we use for RNA-seq count data?
DESeq2 uses the negative binomial model
“All models are wrong, but some are useful”.
George E. P. Box

nrows <- 200
ncols <- 6
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)),
IRanges(floor(runif(200, 1e5, 1e6)), width=100),
strand=sample(c("+", "-"), 200, TRUE),
feature_id=sprintf("ID%03d", 1:200))
colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
row.names=LETTERS[1:6])
se <- SummarizedExperiment(assays=list(counts=counts),
rowRanges=rowRanges, colData=colData)
assay(se)
rowData(se)
rowRanges(se)
colData(se)
rowData(se)$marco <- FALSE
rowData(se)$marco[c(1,2,5,200)] <- TRUE
assay(se[rowData(se)$marco == TRUE, ])
colData(se[,colData(se)$Treatment == "Input"])
se[rowData(se)$marco == TRUE, colData(se)$Treatment == "Input"]
Domande?