knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(RMeDPower)
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)
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)
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)
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.