powerCalc: Power and sample size estimation

Description Usage Arguments Value Examples

View source: R/powerCalc.R

Description

The purpose of this function is to evaluate the power and estimated sample size across all CpG probes present in a beta-value or M-value matrix. The calculation of power and sample size estimation are based on the t-test functions of the pwr package and can only be performed between features that have two levels, e.g., primary PanNET versus metastasis. PowerCalc works for normal two-group designs or paired designs. The core functions used in powerCalc are from the pwr package created by Stephane Champely (aut), Claus Ekstrom (ctb), Peter Dalgaard (ctb), Jeffrey Gill (ctb), Stephan Weibelzahl (ctb), Aditya Anandkumar (ctb), Clay Ford (ctb), Robert Volcic (ctb), and Helios De Rosario cre. pwr is licensed under GPL (>= 3).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
powerCalc(
  betaMatrix,
  pdGroups,
  nameGroups,
  alpha = 1e-06,
  power = 0.8,
  cutOff = 0,
  type,
  limmaFit = NULL,
  pairs = NULL,
  M = T
)

Arguments

betaMatrix

A matrix of beta-values where the rows are the CpG probes and the columns are the samples.

pdGroups

A minfi- or ChAMP-type sample sheet with group information, e.g. pd\$Sample\_Group.

nameGroups

Name of the groups, e.g. c("Met", "Primary").

alpha

Desired alpha-significance level.

power

Desired power.

cutOff

The power and sample size estimation is omitted if the effect size (Cohen's D) of a probe is less than the desired cutoff. Use this with caution as information about many CpG probes will be lost.

type

Can be "paired" or "limma". Any other string will lead to the standard two.sample t-test procedure of pwr.

limmaFit

A LIMMA LMfit object with one contrast can be added to calculate the effect size based on the posterior values for the residual variances obtained from the empirical Bayes procedure.

pairs

Pair information of sample sheet, e.g. pd\$Pairs.

M

Convert beta-values to M-values.

Value

A data.frame containing CpG probe-wise power, estimated sample size, and Cohen's D. Depending on the type other information are included (e.g. mean and SD of the difference between 2 groups when type = "paired).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
A <- data.frame(runif(1000,0.5,1),runif(1000,0.4,0.8),runif(1000,0.6,0.99),
                runif(1000,0.1,0.5),runif(1000,0.2,0.6),runif(1000,0,0.4))

colnames(A) <- rep(paste("Sample_",1:6,sep=""))
pd <- data.frame(c(rep("Group_1",3),rep("Group_2",3)))
colnames(pd) <- "Groups"

A <- as.matrix(A)

powerCalc(betaMatrix = A,
          type = "unpaired",
          pdGroups = pd$Groups,
          nameGroups = c("Group_1","Group_2"),
          M = TRUE,
          cutOff = 0.1)

LionelRohner/LRTools documentation built on Dec. 17, 2021, 1:10 a.m.