powerCalcPlot: Plotting PowerCalc Results

Description Usage Arguments Value Examples

View source: R/powerCalcPlot.R

Description

Plotting function for powerCalc sample estimation. Generates a plot of the estimated sample size as a function of the CpG probes that have a power of 0.8.

Usage

1
2
3
4
5
6
powerCalcPlot(
  ...,
  sampleSizeSteps = c(5, 10, 15, 20, 25, 30, 35, 40, 45, 50),
  returnCleanPlotObj = FALSE,
  explicitNames = NULL
)

Arguments

...

Any data.frames produced by powerCalc.

sampleSizeSteps

Estimated sample sizes for which the number of CpG-probes with power of 0.8 are calculated. Represents the range that will be plotted. By default this is "c(5,10,15,20,25,30,35,40,45,50)".

returnCleanPlotObj

Returns an empty ggplot2 object that can be modified. Is set to "FALSE" by default.

explicitNames

The explicit names of the data.frames inputted in the dots argument. Maybe useful for plots shown in presentations. Assumes same order as the data.frames. Is not used by default.

Value

A plot or a ggplot object depending on returnCleanPlotObj choice.

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
# Standard Example

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=""))
pdA <- data.frame(c(rep("Group_1",3),rep("Group_2",3)))
colnames(pdA) <- "Groups"

A <- as.matrix(A)

powerCalcA <-powerCalc(betaMatrix = A,
                       type = "unpaired",
                       pdGroups = pdA$Groups,
                       nameGroups = c("Group_1","Group_2"),
                       cutOff = 0.1)

B <- data.frame(runif(1000,0.8,1),runif(1000,0.8,0.9),runif(1000,0.7,0.9),
                runif(1000,0.05,0.3),runif(1000,0.2,0.3),runif(1000,0,0.3))

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

B <- as.matrix(B)

powerCalcB <-powerCalc(betaMatrix = B,
                       type = "unpaired",
                       pdGroups = pdB$Groups,
                       nameGroups = c("Group_1","Group_2"),
                       cutOff = 0.1)

powerCalcPlot(powerCalcA, powerCalcB)

# Example with returnCleanPlotObj and explicitNames

g <- powerCalcPlot(powerCalcA, powerCalcB,
                   returnCleanPlotObj = TRUE,
                   explicitNames = c("I Am","The Greatest"))
library(ggplot2)
g + geom_line(aes(color = Group)) + labs(title = "my Title") # + etc as you like

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