This function uses simulation to perform power analysis. It is designed to explore the power of biological experiments and to suggest an optimal number of experimental variables with reasonable power. The backbone of the function is based on simr package, which fits a fixed effect or mixed effect model based on the observed data and simulates response variables. Users can test the power of different combinations of experimental variables and parameters.
library(devtools)
install_github('gladstone-institutes/RMeDPower', build_vignettes=TRUE)
head(RMeDPower_data1)
#> experiment plate line classification feature1 feature2 feature3 feature4
#> 1 exp7 1 line1 0 62 3261.238 16.69571 118.4444
#> 2 exp7 1 line1 0 77 2033.726 54.10482 114.0946
#> 3 exp7 1 line1 0 56 1935.731 -100.00000 122.7329
#> 4 exp7 1 line1 0 54 1533.812 -100.00000 118.7066
#> 5 exp7 1 line1 0 19 1437.420 -100.00000 117.0279
#> 6 exp7 1 line1 0 30 1899.334 -100.00000 117.9523
#> feature5
#> 1 10
#> 2 14
#> 3 13
#> 4 13
#> 5 19
#> 6 11
exp1, exp2, exp3, …, exp9
calculate_power(data=RMeDPower_data1,power_curve=1,
variance_estimate_from="data",condition_variable="classification",
experimental_variable=c("experiment","plate","line"), response_variable="feature1",
nsimn=10, target_parameters="experiment", levels=1)
table(RMeDPower_data1$line)
#>
#> line1 line2 line3 line4 line5 line6 line7 line8
#> 42 40 37 51 71 37 42 20
calculate_power(data=RMeDPower_data1,power_curve=1,
variance_estimate_from="data",condition_variable="classification",
experimental_variable=c("experiment","plate","line"), response_variable="feature1",
nsimn=10, target_parameters="line", levels=0)
calculate_power(data=RMeDPower_data1,power_curve=0,
variance_estimate_from="data",condition_variable="classification",
experimental_variable=c("experiment","plate","line"), response_variable="feature1",
nsimn=10, target_parameters="experiment", levels=1, max_size=15,output="test.txt")
Power for predictor ‘condition\_variable’, (95% confidence interval): 80.00% (44.39, 97.48) Test: Likelihood ratio Based on 10 simulations, (0 warnings, 0 errors) alpha = 0.05, nrow = 544 Time elapsed: 0 h 0 m 2 s nb: result might be an observed power calculation
calculate_power(data=RMeDPower_data1,power_curve=0,
variance_estimate_from="data",condition_variable="classification",
experimental_variable=c("experiment","plate","line"), response_variable="feature1",
nsimn=10, target_parameters="experiment", levels=1, effect_size = c(10))
Power for predictor ‘condition\_variable’, (95% confidence interval): 50.00% (18.71, 81.29) Test: Likelihood ratio Based on 10 simulations, (0 warnings, 0 errors) alpha = 0.05, nrow = 1700 Time elapsed: 0 h 0 m 10 s
calculate_power(data=RMeDPower_data1,power_curve=1,
variance_estimate_from="data",condition_variable="classification",
experimental_variable=c("experiment","plate","line"), response_variable="feature2",
nsimn=10, target_parameters=c("experiment","line"), levels=c(1,0), max_size=c(9,142))
Check sample size table of experimental varaibles:
table(RMeDPower_data2$experiment,RMeDPower_data2$plate,RMeDPower_data2$line)
#> , , = line1
#>
#>
#> 1
#> exp1 14
calculate_power(data=RMeDPower_data2,power_curve=1,
variance_estimate_from="ICC",condition_variable="classification",
experimental_variable=c("experiment","plate","line"), response_variable="feature2",
nsimn=10, target_parameters=c("experiment"), levels=1, ICC=c(0.2,0.15,0.3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.