powerLMEnoCov: Power Calculation for Simple Linear Mixed Effects Model...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/powerLMEnoCov.R

Description

Power calculation for simple linear mixed effects model without covariate. This function can be used to calculate one of the 3 parameters (power, sample size, and minimum detectable slope) by setting the corresponding parameter as NULL and providing values for the other 2 parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
powerLMEnoCov(
  slope, 
  n, 
  m, 
  sigma.y,
  power = NULL,
  rho = 0.8, 
  FWER = 0.05,
  nTests = 1,
  n.lower = 2.01,
  n.upper = 1e+30)

Arguments

slope

numeric. Slope under alternative hypothesis.

n

integer. Total number of subjects.

m

integer. Number of pairs of replicates per subject.

sigma.y

numeric. Standard deviation of the outcome y.

power

numeric. Desired power.

rho

numeric. Intra-class correlation (i.e., correlation between y_{ij} and y_{ik} for the j-th and k-th observations of the i-th subject).

FWER

numeric. Family-wise Type I error rate.

nTests

integer. Number of tests (e.g., number of genes in differential expression analysis based on scRNAseq to compare gene expression before and after treatment).

n.lower

numeric. Lower bound of the total number of subjects. Only used when calculating total number of subjects.

n.upper

numeric. Upper bound of the total number of subjects. Only used when calculating total number of subjects.

Details

In an experiment, there are n samples. For each sample, we get m pairs of replicates. For each pair, one replicate will receive no treatment. The other replicate will receive treatment. The outcome is the expression of a gene. The overall goal of the experiment is to check if the treatment affects gene expression level or not. Or equivalently, the overall goal of the experiment is to test if the mean within-pair difference of gene expression is equal to zero or not. In the design stage, we would like to calculate the power/sample size of the experiment for testing if the mean within-pair difference of gene expression is equal to zero or not.

We assume the following linear mixed effects model to characterize the relationship between the within-pair difference of gene expression y_{ij} and the mean of the within-pair difference β_{0i}:

y_{ij} = β_{0i} + ε_{ij},

where

β_{0i} \sim N≤ft(β_0, σ^2_{β}\right),

and

ε_{ij} \sim N≤ft(0, σ^2\right),

i=1,…, n, j=1,…, m, n is the number of subjects, m is the number of pairs of replicates per subject, y_{ij} is the within-pair difference of outcome value for the j-th pair of the i-th subject.

We would like to test the following hypotheses:

H_0: β_0=0,

and

H_1: β_0 = δ,

where δ\neq 0. If we reject the null hypothesis H_0 based on a sample, we then get evidence that the treatment affects the gene expression level.

We can derive the power calculation formula:

power=1- Φ≤ft(z_{α^{*}/2}-a\times b\right) +Φ≤ft(-z_{α^{*}/2} - a\times b\right),

where

a= \frac{1 }{σ_y}

and

b=\frac{δ√{mn}}{√{1+(m-1)ρ}}

and z_{α^{*}/2} is the upper 100α^{*}/2 percentile of the standard normal distribution, α^{*}=α/nTests, nTests is the number of tests, σ_y=√{σ^2_{β}+σ^2} and ρ=σ^2_{β}/≤ft(σ^2_{β}+σ^2\right) is the intra-class correlation.

Value

power if the input parameter power = NULL.

sample size (total number of subjects) if the input parameter n = NULL;

minimum detectable slope if the input parameter slope = NULL.

Author(s)

Xianjun Dong <XDONG@rics.bwh.harvard.edu>, Xiaoqi Li<xli85@bwh.harvard.edu>, Tzuu-Wang Chang <Chang.Tzuu-Wang@mgh.harvard.edu>, Scott T. Weiss <restw@channing.harvard.edu>, Weiliang Qiu <weiliang.qiu@gmail.com>

References

Dong X, Li X, Chang T-W, Scherzer CR, Weiss ST, and Qiu W. powerEQTL: An R package and shiny application for sample size and power calculation of bulk tissue and single-cell eQTL analysis. Bioinformatics, 2021;, btab385

Examples

 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
  n = 17
  m = 5
  sigma.y = 0.68
  slope = 1.3*sigma.y
  print(slope)
  
  # estimate power
  power = powerLMEnoCov(
    slope = slope, 
    n = n, 
    m = m,
    sigma.y = sigma.y,
    power = NULL,
    rho = 0.8, 
    FWER = 0.05,
    nTests = 20345)

  print(power)

  # estimate sample size (total number of subjects)
  n = powerLMEnoCov(
    slope = slope, 
    n = NULL, 
    m = m,
    sigma.y = sigma.y,
    power = 0.8721607,
    rho = 0.8, 
    FWER = 0.05,
    nTests = 20345)

  print(n)
  
  # estimate slope
  slope = powerLMEnoCov(
    slope = NULL, 
    n = n, 
    m = m,
    sigma.y = sigma.y,
    power = 0.8721607,
    rho = 0.8, 
    FWER = 0.05,
    nTests = 20345)

  print(slope)

powerEQTL documentation built on July 22, 2021, 9:08 a.m.