-
Notifications
You must be signed in to change notification settings - Fork 0
/
power_calculation.R
48 lines (34 loc) · 1.64 KB
/
power_calculation.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
library(PROPER)
# Calculating power for an RNA-seq experiment using LCLs
# The determination of sample sizes is important, however challenges include:
# Multiple testing problem: Many genes are tested for DE simultaneously
# Coverage depth
# DE detection procedure --> Different shrinkage procedures are used to stabilize the estimation of within group variation
### setting up a simulation scenario
## The Cheung data uses expression of 41 LCLs from unrelated individuals, so the expressions show a large biological variation
sim.opts.Cheung = RNAseq.SimOptions.2grp(ngenes = 16000, p.DE=0.02,lOD="cheung", lBaselineExpr="cheung")
## The dispersions in this data set wil be very large
## Nreps is number of reps in group 1 --> in this case original control samples, orginal control samples with gtex
## Nreps2 is number of reps in group 2: in this case, the condition group
simres = runSims(Nreps = c(73,73,7,7),Nreps2 = c(1,3,3,1), sim.opts=sim.opts.Cheung,DEmethod="edgeR", nsims=30)
# Comparing power
# Method to control for type I error (FDR or raw pvalue)
# Method to stratify genes
# Method to identify interesting
powers = comparePower(simres, alpha.type="fdr", alpha.nominal=0.1,stratify.by="expr", delta=0.5)
summaryPower(powers)
# Summary table
# Marginal power
# TD --> True discovery
# FD --> False discovery
# FDC --> False discovery cost defined as the number of FD / TD
# plot stratified powers
plotPower(powers)
# plot number of true discoveries
plotPowerTD(powers)
# plot stratified false discovery cost
plotFDcost(powers)
# Plot everything in a single finger
plotAll(powers)
# Power and seq depth
power.seqDepth(simres,powers)