exercise 1 review - cornell universitycbsuss05.tc.cornell.edu/doc/rna-seq-2016-lecture2.pdf ·...

29
Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no- novel-juncs testgenome a.fastq.gz -G: align to annotated transcript in first step, using annotated junctions; --no-novel-juncs: Do not identify new junctions; -N: read mismatches (default 2) -g: maximum multi-hits ( default 20) Some other parameters:

Upload: others

Post on 29-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Exercise 1 ReviewSetting parameters

tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs testgenome a.fastq.gz

-G: align to annotated transcript in first step, using annotated junctions;

--no-novel-juncs: Do not identify new junctions;

-N: read mismatches (default 2)

-g: maximum multi-hits ( default 20)

Some other parameters:

Page 2: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Exercise 1 ReviewMake a shell script

tophat -o A -G testgenome.gff3 --no-novel-juncs testgenome a.fastq.gz

tophat -o B -G testgenome.gff3 --no-novel-juncs testgenome b.fastq.gz

mv A/accepted_hits.bam ./a.bam

mv B/accepted_hits.bam ./b.bam

samtools index a.bam

samtools index b.bam

Run a shell script

nohup sh /home/my_user_ID/runtophat.sh >& mylog &

Page 3: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Genome Databases on BioHPC Lab

• On /local_data directory (not on general machines):

human, mouse, Drosophila, C. elegans, yeast, Arabidopsis, maize.

• On /shared_data/genome_db/: rice, grape, apple, older versions of databases.

Page 4: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

How to prepare TOPHAT genome database

bowtie2-build rice7.fa rice7

Genome fasta file

Give the database a name

* Keep a copy of the indexed genome in home directory so that the files can be reused next time

Page 5: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

1.Quantification (count reads per gene)

2.Normalization (normalize counts between samples)

3.Differentially expressed genes

RNA-seq Data Analysis Lecture 2

Page 6: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Different summarization strategies will result in the inclusion or exclusion of different sets of reads in the table of counts.

Quantification: Count reads per gene

Presenter
Presentation Notes
(b) A schematic of a genomic region and reads that might arise from it. Reads are color-coded by the genomic feature from which they originate. Different summarization strategies will result in the inclusion or exclusion of different sets of reads in the table of counts. For example, including only reads coming from known exons will exclude the intronic reads (green) from contributing to the results. Splice junctions are listed as a separate class to emphasize both the potential ambiguity in their assignment (such as which exon should a junction read be assigned to) and the possibility that many of these reads may not be mapped because they are harder to map than continuous reads. CDS, coding sequence.
Page 7: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Complications in quantification1. Multi-mapped reads

Cufflinks/Cuffdiff– uniformly divide each read to all mapped positions

HTSeq– Discard multi-mapped reads

Page 8: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

0

1

-10

1

-1

2. Normalization

Before normalization After normalizationMA Plots

• Y axis: log ratio of expression level between two conditions;• With the assumption that most genes are expressed equally,

the log ratio should mostly be close to 0

Page 9: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

A simple normalization

FPKM (CUFFLINKS)Fragments Per Kilobase Of Exon Per Million FragmentsNormalization factor:Default: total reads from genes defined in GFF-total-hits-norm: all aligned reads

CPM (EdgeR)Count Per Million ReadsNormalization factor:• total reads from genes defined in GFF • Correction with TMM

Reads that are not mapped to gene region (e.g. rRNA, pseudo-genes would not affect normalization

Page 10: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Robinson & Oshlack 2010 Genome Biology 2010, 11:R25.

Default normalization in EdgeR: TMM

Evalute normalization with M-A plot

Presenter
Presentation Notes
M is, therefore, the log intensity ratio (or difference between log intensities) A is the average log intensity c) An M versus A plot comparing liver and kidney shows a clear offset from zero. Green points indicate 545 housekeeping genes, while the green line signifies the median log-ratio of the housekeeping genes. The red line shows the estimated TMM normalization factor. The smear of orange points highlights the genes that were observed in only one of the liver or kidney Tissues. The black arrow highlights the set of prominent genes that are largely attributable for the overall bias in log-fold-changes. M=log2(R/G)=log2(R)-log2(G) A=1/2*log2(RG) = \frac12 (log_2(R) + log_2(G))
Page 11: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Normalization methods

Total-count normalization

• By total mapped reads

Upper-quantile normalization

• By read count of the gene at upper-quantile

Normalization by housekeeping genes

Trimmed mean (TMM) normalization

Presenter
Presentation Notes
Scaling to library size as a form of normalization makes intuitive sense, given it is expected that sequencing a sample to half the depth will give, on average, half the number of reads mapping to each gene. We believe this is appropriate for normalizing between replicate samples of an RNA population. However, library size scaling is too simple for many biological applications. The number of tags expected to map to a gene is not only dependent on the expression level and length of the gene, but also the composition of the RNA population that is being sampled. Thus, if a large number of genes are unique to, or highly expressed in, one experimental condition, the sequencing 'real estate' available for the remaining genes in that sample is decreased. If not adjusted for, this sampling artifact can force the DE analysis to be skewed towards one experimental condition. Current analysis methods [6,11] have not accounted for this proportionality property of the data explicitly, potentially giving rise to higher false positive rates and lower power to detect true differences. The standard procedure is to compute the proportion of each gene's reads relative to the total number of reads and compare that across all samples, either by transforming the original data or by introducing a constant into a statistical model. However, since different experimental conditions (for example, tissues) express diverse RNA repertoires, we cannot always expect the proportions to be directly comparable.
Page 12: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Normalization methods

Total-count normalization (FPKM, RPKM)

• By total mapped reads (in transcripts)

Upper-quartile normalization

• By read count of the gene at upper-quartile

Normalization by housekeeping genes

Trimmed mean (TMM) normalization

cuffdiff

EdgeR & DESeq

Default

Presenter
Presentation Notes
Scaling to library size as a form of normalization makes intuitive sense, given it is expected that sequencing a sample to half the depth will give, on average, half the number of reads mapping to each gene. We believe this is appropriate for normalizing between replicate samples of an RNA population. However, library size scaling is too simple for many biological applications. The number of tags expected to map to a gene is not only dependent on the expression level and length of the gene, but also the composition of the RNA population that is being sampled. Thus, if a large number of genes are unique to, or highly expressed in, one experimental condition, the sequencing 'real estate' available for the remaining genes in that sample is decreased. If not adjusted for, this sampling artifact can force the DE analysis to be skewed towards one experimental condition. Current analysis methods [6,11] have not accounted for this proportionality property of the data explicitly, potentially giving rise to higher false positive rates and lower power to detect true differences. The standard procedure is to compute the proportion of each gene's reads relative to the total number of reads and compare that across all samples, either by transforming the original data or by introducing a constant into a statistical model. However, since different experimental conditions (for example, tissues) express diverse RNA repertoires, we cannot always expect the proportions to be directly comparable.
Page 13: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Expression level

% o

f rep

licat

es

0 5 10 15 20

0.00

0.05

0.10

0.15

0.20

0.25

Expression level

% o

f rep

licat

es

0 5 10 15 20

0.00

0.05

0.10

0.15

0.20

0.25

If we could do 100 biological replicates,

Condition 1

Condition 2

Distribution of Expression Level of A Gene

3. Differentially expressed genes

Page 14: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Expression level

% o

f rep

licat

es

0 5 10 15 20

0.00

0.05

0.10

0.15

0.20

0.25

Expression level

% o

f rep

licat

es

0 5 10 15 200.

000.

050.

100.

150.

200.

25

Condition 1

Condition 2

Distribution of Expression Level of A Gene

The reality is, we could only do 3 replicates,

Page 15: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Statistical modeling of gene expressionand test for differentially expressed genes

1. Estimate of variance.Eg. EdgeR uses a combination of 1) a common dispersion effect from all genes; 2) a gene-specific dispersion effect.

2. Model the expression level with negative bionomial distribution.

DESeq and EdgeR

3. Multiple test correction Default in EdgeR: Benjamini-Hochberg

Page 16: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Values for each gene:

• Read count (raw & normalized)

• Fold change (Log2 fold) between the two conditions

• P-value

• Q(FDR) value after multiple test.

Output table from RNA-seq pipeline

Using both fold change and FDR value to filter:

E.g. Log2(fold) >1 or <-1&

FDR < 0.05

Page 17: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Rapaport F et al. Genome Biology, 2013 14:R95

Comparison of Methods

Page 18: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

TOPHAT -> BAM files

CUFFDIFF -> raw read counts (File: genes.read_group_tracking)

EdgeR -> Normalization & DE Genes

RNA-seq Workflow at Bioinformatics Facility

http://cbsu.tc.cornell.edu/lab/doc/rna_seq_draft_v8.pdf

Page 19: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Using Cuffdiff for Quantification

• Cufflinks– Input: one single BAM from TOPHAT;– Reference guide transcript assembly;– Output: GTF

• Cuffdiff– Input: multiple BAM files from TOPHAT;– Quantification & DE gene detection– Output: Read count; DE gene list

Page 20: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

CUFFDIFF command

cuffdiff -p 2 -o outDir rice7.gff3 \A_r1.bam,A_r2.bam B_r1.bam,B_r2.bam

A_r1 : timepoint 1; repeat 1A_r2 : timepoint 1; repeat 2

B_r1 : timepoint 1; repeat 1B_r2 : timepoint 2; repeat 2

Space comma

Notable parameter: --max-bundle-frags: maximum reads per gene (default: 1 million)

Page 21: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Connection between CUFFDIFF and EdgeR

tracking_id condition replicate raw_frags

internal_scaled_frags

external_scaled_frags FPKM

effective_length status

gene1 q1 0 16 11.3905 11.3905 0.305545 - OKgene1 q1 1 12 8.08334 8.08334 0.216832 - OKgene1 q2 0 15 26.084 26.084 0.699692 - OKgene1 q2 1 19 21.9805 21.9805 0.589617 - OKgene2 q1 0 61 43.4262 43.4262 4.50677 - OKgene2 q1 1 53 35.7014 35.7014 3.69312 - OKgene2 q2 0 35 60.8627 60.8627 6.35236 - OKgene2 q2 1 30 34.7061 34.7061 3.59016 - OK

CUFFDIFF output file with raw read count: genes.read_group_tracking

EdgeR input file:

Gene A1 A2 B1 B2gene1 16 12 15 19gene2 61 53 35 30

parse_cuffdiff_readgroup.pl

File conversion PERL script:

• The script would produce a raw read count table (edgeR_count.xls) and a FPKM table (edgeR_FPKM.xls).• If you want to get this script, you can use FileZilla to download it, it is located at/programs/bin/perlscripts/parse_cuffdiff_readgroup.pl

Page 22: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

A few notes about cuffdiff:

1. Here we only use cuffdiff to get raw read count at gene level, and use EdgeR for normalization and other statistical analysis;

2. Notable parameters:• -p: number of threads• -max-bundle-frags: maximum reads per gene.

Default at 1 million. In some rare cases, a small number of genes could have very high expression level and cause problems.

Page 23: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Using EdgeR to makeMDS plot of the samples

• Check reproducibility from replicates, remove outliers• Check batch effects;

Page 24: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Use EdgeR to identify DE genes

Treat Time

Sample 1-3 Drug 0 hr

Sample 4-6 Drug 1 hr

Sample 7-9 Drug 2 hr

group <- factor(c(1,1,1,2,2,2,3,3,3))design <- model.matrix(~0+group)fit <- glmFit(myData, design)

lrt12 <- glmLRT(fit, contrast=c(1,-1,0)) #compare 0 vs 1h lrt13 <- glmLRT(fit, contrast=c(1,0,-1)) #compare 0 vs 2h lrt23 <- glmLRT(fit, contrast=c(0,1,-1)) #compare 1 vs 2h

Page 25: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Multiple-factor Analysis in EdgeR

Treat Time

Sample 1-3 Placebo 0 hr

Sample 4-6 Placebo 1 hr

Sample 7-9 Placebo 2 hr

Sample 10-12 Drug 0 hr

Sample 13-15 Drug 1 hr

Sample 16-18 Drug 2 hr

group <- factor(c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6))design <- model.matrix(~0+group)fit <- glmFit(mydata, design)

lrt <- glmLRT(fit, contrast=c(-1,0,1,1,0,-1))### equivalent to (Placebo.2hr – Placbo.0hr) – (Drug.2hr-Drug.1hr)

Page 26: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Exercise

• Using cuffdiff for quantification and identifying differentially expressed genes of two different biological conditions A and B. There are two replicates for each condition.

• Using EdgeR package to make MDS plot of the 4 libraries, and identify differentially expressed genes

Page 27: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

PATH in Linux

aa

myDataFile

my_Directory/ myDataFile

./myDataFile

../ myDataFile

Relative PATH

aa /workdir/mydir/myDataFile

Absolute PATH

Page 28: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

tophat -o mydir testgenome a.fastq.gz

mv mydir/accepted_hits.bam ./a.bam

nohup sh /home/my_user_ID/runtophat.sh >& mylog &

$ pwd/workdir/ff111

Use “pwd” to get current directory

PATH in Linux

Page 29: Exercise 1 Review - Cornell Universitycbsuss05.tc.cornell.edu/doc/RNA-Seq-2016-Lecture2.pdf · Exercise 1 Review Setting parameters tophat –p 8 -o A -G testgenome.gff3 --no-novel-juncs

Create aliases for files

ln -s /local_data/Homo_sapiens_UCSC_hg19/Bowtie2Index/* ./

tophat /local_data/Homo_sapiens_UCSC_hg19/Bowtie2Index/genome a.fastq.gz

tophat genome a.fastq.gz