### Install onlineFDR from GitHub Source: https://github.com/dsrobertson/onlinefdr/blob/master/README.md Installs the development snapshot of the onlineFDR package from GitHub using the devtools package. Ensure devtools is installed. ```r # install.packages("devtools") # If devtools not installed devtools::install_github("dsrobertson/onlineFDR") ``` -------------------------------- ### SAFFRON Example with Dataframe Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/SAFFRON.html This example demonstrates using SAFFRON with a dataframe containing identifiers, dates, and p-values. It shows how to structure the input data for the function. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), date = as.Date(c(rep('2014-12-01',3), rep('2015-09-21',5), rep('2016-05-19',2), rep('2017-01-15',3), rep('2017-08-08',2))), pval = c(0.001, 0.04, 0.07, 0.005, 0.02, 0.03, 0.001, 0.06, 0.08, 0.01, 0.04, 0.02, 0.003, 0.05, 0.09) ) # SAFFRON(d = sample.df, alpha = 0.05, lambda = 0.5, w0 = 0.025) ``` -------------------------------- ### Install onlineFDR from Bioconductor (release) Source: https://github.com/dsrobertson/onlinefdr/blob/master/README.md Installs the onlineFDR package from Bioconductor's release channel. Ensure BiocManager is installed first. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("onlineFDR") ``` -------------------------------- ### Run ADDIS_spending with a dataframe Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/ADDIS_spending.html This example demonstrates how to use the ADDIS_spending function with a dataframe containing p-values and lags. It shows the default behavior for independent p-values. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757), lags = rep(1,15)) ADDIS_spending(sample.df) #independent ``` -------------------------------- ### SAFFRON with custom alpha and w0 Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/SAFFRON.md This example demonstrates using the SAFFRON function with custom values for the 'alpha' and 'w0' parameters. The 'set.seed(1)' call ensures reproducibility. ```r set.seed(1); SAFFRON(sample.df, alpha=0.1, w0=0.025) ``` -------------------------------- ### LORDstar Example Dataframe Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/LORDstar.html This example demonstrates how to structure the input dataframe 'd' for the LORDstar function. It includes columns for 'id', 'pval', and 'decision.times', which are necessary for the 'async' version of the algorithm. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', ``` -------------------------------- ### Install onlineFDR from Bioconductor (devel) Source: https://github.com/dsrobertson/onlinefdr/blob/master/README.md Installs the onlineFDR package from Bioconductor's development channel. Ensure BiocManager is installed first. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install(version = "devel") BiocManager::install("onlineFDR") ``` -------------------------------- ### Example DataFrame for LOND Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/LOND.html Demonstrates creating a sample dataframe with identifiers, dates, and p-values for use with the LOND function. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), date = as.Date(c(rep('2014-12-01',3), rep('2015-09-21',5), rep('2015-10-01',4), rep('2015-11-01',3))), pval = c(0.001, 0.005, 0.01, 0.002, 0.008, 0.015, 0.003, 0.006, 0.012, 0.004, 0.009, 0.02, 0.007, 0.011, 0.018) ) ``` -------------------------------- ### Running supLORD with Simulated Data Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/supLORD.md This example demonstrates how to use the supLORD function with simulated p-values. It sets a seed for reproducibility and generates data to test the FDX and FDR control. ```r set.seed(1) N <- 1000 B <- rbinom(N, 1, 0.5) Z <- rnorm(N, mean = 3*B) pval <- pnorm(-Z) out <- supLORD(pval, eps=0.15, r=30, eta=0.05, rho=30, random=FALSE) head(out) #> d alphai R #> 1 4.691912e-01 0.0019301522 0 #> 2 6.167166e-01 0.0004197471 0 #> 3 3.462711e-02 0.0003575072 0 #> 4 1.300690e-03 0.0002973164 0 #> 5 1.606961e-01 0.0002520627 0 #> 6 2.174486e-06 0.0002180533 1 sum(out$R) #> [1] 390 ``` -------------------------------- ### R: Alpha Spending Calculation with Randomization Disabled Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/Alpha_spending.md This example shows how to use Alpha_spending while disabling the randomization feature. This can be useful for ensuring reproducible results when randomization is not desired. ```r Alpha_spending(sample.df, random=FALSE) ``` -------------------------------- ### Example DataFrame for LONDstar Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/LONDstar.html Demonstrates the structure of a dataframe that can be used as input for the LONDstar function, including identifiers and p-values. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757) ) ``` -------------------------------- ### BatchBH Usage Example Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/BatchBH.md Demonstrates how to use the BatchBH function with a sample dataframe containing identifiers, p-values, and batch numbers. The output includes discovery indicators. ```r sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757), batch = c(rep(1,5), rep(2,6), rep(3,4))) BatchBH(sample.df) #> id pval batch R alphai #> 1 A15432 2.9000e-08 1 1 0.021874508 #> 2 B90969 6.7430e-02 1 0 0.021874508 #> 3 C18705 1.5140e-02 1 0 0.021874508 #> 4 B49731 8.1740e-02 1 0 0.021874508 #> 5 E99902 1.7100e-03 1 1 0.021874508 #> 6 C38292 3.6000e-05 2 1 0.009621196 #> 7 A30619 7.9149e-01 2 0 0.009621196 #> 8 D46627 2.7201e-01 2 0 0.009621196 #> 9 E29198 2.8295e-01 2 0 0.009621196 #> 10 A41418 7.5900e-08 2 1 0.009621196 #> 11 D51456 6.9274e-01 2 0 0.009621196 #> 12 C88669 3.0443e-01 3 0 0.025012888 #> 13 E03673 1.3600e-03 3 1 0.025012888 #> 14 A63155 7.2342e-01 3 0 0.025012888 #> 15 B66033 5.4757e-01 3 0 0.025012888 ``` -------------------------------- ### Example Usage of BatchStBH Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/BatchStBH.md Demonstrates how to use the BatchStBH function with a sample dataframe. The output includes the original data along with the discovery indicator R and adjusted significance thresholds alphai. ```r sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757), batch = c(rep(1,5), rep(2,6), rep(3,4))) BatchStBH(sample.df) #> id pval batch R alphai #> 1 A15432 2.9000e-08 1 1 0.02187451 #> 2 B90969 6.7430e-02 1 0 0.02187451 #> 3 C18705 1.5140e-02 1 1 0.02187451 #> 4 B49731 8.1740e-02 1 0 0.02187451 #> 5 E99902 1.7100e-03 1 1 0.02187451 #> 6 C38292 3.6000e-05 2 1 0.04363561 #> 7 A30619 7.9149e-01 2 0 0.04363561 #> 8 D46627 2.7201e-01 2 0 0.04363561 #> 9 E29198 2.8295e-01 2 0 0.04363561 #> 10 A41418 7.5900e-08 2 1 0.04363561 #> 11 D51456 6.9274e-01 2 0 0.04363561 #> 12 C88669 3.0443e-01 3 0 0.02484982 #> 13 E03673 1.3600e-03 3 1 0.02484982 #> 14 A63155 7.2342e-01 3 0 0.02484982 #> 15 B66033 5.4757e-01 3 0 0.02484982 ``` -------------------------------- ### Run ADDIS.spending for locally dependent p-values Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/ADDIS.spending.html This example shows how to use the ADDIS.spending function when p-values may exhibit local dependence. The `dep=TRUE` argument is set, and a `lags` vector is provided, which is required for this mode. In this case, a vector of zeros is used for lags, resulting in the same output as the independent case. ```R pval <- c(2.90e-08, 0.06743, 3.51e-04, 0.0154, 0.04723, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-06, 0.69274, 0.30443, 0.00136, 0.82342, 5.4757e-04) ADDIS.spending(pval, dep=TRUE, lags=rep(0,15)) ``` -------------------------------- ### Discarding LORD Procedure Example Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/LORD.html Applies the discarding version of the LORD procedure. This version is useful for optimizing the procedure by discarding certain hypotheses. Results are shown with `set.seed(1)` for reproducibility. ```R set.seed(1); LORD(sample.df, version='discard') ``` -------------------------------- ### Create Sample Dataframe Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/articles/onlineFDR.md Initializes a toy dataset with 'id', 'date', and 'pval' columns. Ensure the 'date' column is in 'YYYY-MM-DD' format. ```r sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), date = as.Date(c(rep("2014-12-01",3), rep("2015-09-21",5), rep("2016-05-19",2), "2016-11-12", rep("2017-03-27",4))), pval = c(2.90e-14, 0.00143, 0.06514, 0.00174, 0.00171, 3.61e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.000487, 0.72342, 0.54757)) ) ``` -------------------------------- ### View onlineFDR Vignette Source: https://github.com/dsrobertson/onlinefdr/blob/master/README.md Opens the vignette for the installed version of the onlineFDR package in R. This provides a more in-depth guide to the package's functionality. ```r browseVignettes("onlineFDR") ``` -------------------------------- ### Initial Analysis with LOND Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/articles/onlineFDR.md Demonstrates the initial use of the LOND algorithm with a small dataset. Ensure the same seed is used for future analyses to maintain reproducibility. ```r # Initial experimental data sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705'), date = as.Date(c(rep("2014-12-01",3))), pval = c(2.90e-14, 0.06743, 0.01514)) set.seed(1) LOND_results <- LOND(sample.df) ``` -------------------------------- ### Initialize and Update LOND with Time-Series Data Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/articles/onlineFDR.html Demonstrates initializing the LOND algorithm with initial data and then updating it with new data from subsequent experiments. Ensure the same seed is used for reproducibility. ```R # Initial experimental data sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705'), date = as.Date(c(rep("2014-12-01",3))), pval = c(2.90e-14, 0.06743, 0.01514)) set.seed(1) LOND_results <- LOND(sample.df) # After you've completed more experiments sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), date = as.Date(c(rep("2014-12-01",3), rep("2015-09-21",5), rep("2016-05-19",2), "2016-11-12", rep("2017-03-27",4))), pval = c(2.90e-14, 0.06743, 0.01514, 0.08174, 0.00171, 3.61e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.000487, 0.72342, 0.54757)) set.seed(1) LOND_results <- LOND(sample.df) ``` -------------------------------- ### ADDIS Example Dataframe Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/ADDIS.html An example dataframe used to demonstrate the ADDIS function. It includes columns for identifier, p-value, and decision times. ```R sample.df1 <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), pval = c(0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015), decision.times = as.Date(c('2023-01-01', '2023-01-01', '2023-01-02', '2023-01-02', '2023-01-03', '2023-01-03', '2023-01-04', '2023-01-04', '2023-01-05', '2023-01-05', '2023-01-06', '2023-01-06', '2023-01-07', '2023-01-07', '2023-01-08')) ) ``` -------------------------------- ### Initialize and Compare LORD Versions Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/articles/advanced-usage.md Demonstrates initializing and comparing different versions of the LORD (Layered Online FDR) algorithm. Use this to select the most appropriate version for your data and analysis goals. ```r set.seed(1); results.LORD.plus <- LORD(sample.df) set.seed(1); results.LORD3 <- LORD(sample.df, version=3) set.seed(1); results.LORD.discard <- LORD(sample.df, version='discard') set.seed(1); results.LORD.dep <- LORD(sample.df, version='dep') ``` -------------------------------- ### Run Alpha Investing with Default Parameters Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/Alpha_investing.html This snippet demonstrates how to call the Alpha Investing function with a sample data frame and default parameters. It shows the expected output format including p-values, alphai, and R indicators. ```r set.seed(1); Alpha_investing(sample.df) #> pval alphai R #> 1 2.9000e-08 0.010818925 1 #> 2 6.7430e-02 0.021406257 0 #> 3 1.5140e-02 0.007164201 0 #> 4 8.1740e-02 0.003757589 0 #> 5 1.7100e-03 0.002374706 1 #> 6 2.7201e-01 0.023680499 0 #> 7 3.6000e-05 0.008803369 1 #> 8 7.9149e-01 0.029838354 0 #> 9 7.5900e-08 0.012084065 1 #> 10 2.8295e-01 0.032981505 0 #> 11 6.9274e-01 0.014137539 0 #> 12 7.2342e-01 0.008529625 0 #> 13 3.0443e-01 0.005905508 0 #> 14 5.4757e-01 0.004412045 0 #> 15 1.3600e-03 0.003461425 1 ``` -------------------------------- ### Alpha Investing with Custom Alpha and Weight Parameters Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/Alpha_investing.md Shows how to use the Alpha Investing function with custom `alpha` and `w0` parameters. This allows for fine-tuning the analysis based on specific thresholds and weighting schemes. ```r set.seed(1); Alpha_investing(sample.df, alpha=0.1, w0=0.025) ``` -------------------------------- ### Example Usage of StoreyBH Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/StoreyBH.md Demonstrates how to use the StoreyBH function with a vector of p-values. The function returns a dataframe with p-values and an indicator of discoveries. ```r pvals <- c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757) StoreyBH(pvals) #> pval R #> 1 2.9000e-08 1 #> 2 6.7430e-02 0 #> 3 1.5140e-02 1 #> 4 8.1740e-02 0 #> 5 1.7100e-03 1 #> 6 3.6000e-05 1 #> 7 7.9149e-01 0 #> 8 2.7201e-01 0 #> 9 2.8295e-01 0 #> 10 7.5900e-08 1 #> 11 6.9274e-01 0 #> 12 3.0443e-01 0 #> 13 1.3600e-03 1 #> 14 7.2342e-01 0 #> 15 5.4757e-01 0 ``` -------------------------------- ### Initialize Toy Dataset for FDR Analysis Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/articles/onlineFDR.html Creates a sample data frame with identifiers, dates, and p-values. Ensure dates are in 'YYYY-MM-DD' format. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), date = as.Date(c(rep("2014-12-01",3), rep("2015-09-21",5), rep("2016-05-19",2), "2016-11-12", rep("2017-03-27",4))), pval = c(2.90e-14, 0.00143, 0.06514, 0.00174, 0.00171, 3.61e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.000487, 0.72342, 0.54757)) ``` -------------------------------- ### Online Fallback with Custom Alpha Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/online_fallback.md Example of using the `online_fallback` function with a custom significance level (`alpha = 0.1`). `set.seed(1)` is used for reproducibility. ```r set.seed(1); online_fallback(sample.df, alpha=0.1) #> pval alphai R #> 1 2.9000e-08 0.0053516771 1 #> 2 6.7430e-02 0.0065154977 0 #> 3 1.5140e-02 0.0009912499 0 #> 4 8.1740e-02 0.0008243606 0 #> 5 1.7100e-03 0.0006988870 0 #> 6 2.7201e-01 0.0006045900 0 #> 7 3.6000e-05 0.0005319444 1 #> 8 7.9149e-01 0.0010064670 0 #> 9 7.5900e-08 0.0004280949 1 #> 10 2.8295e-01 0.0008179201 0 #> 11 6.9274e-01 0.0003577593 0 #> 12 7.2342e-01 0.0003305137 0 #> 13 3.0443e-01 0.0003070841 0 #> 14 5.4757e-01 0.0002867254 0 #> 15 1.3600e-03 0.0002688736 0 ``` -------------------------------- ### AlphaSaving Function Example Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/AlphaSaving.html Demonstrates the usage of the AlphaSaving function with a sample data frame and an alpha value of 0.1. Sets the random seed for reproducibility. ```R set.seed(1) AlphaSaving(sample.df, alpha=0.1) ``` -------------------------------- ### Alpha Investing with Sample Data (Randomization Enabled) Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/Alpha_investing.md Illustrates the Alpha Investing function with randomization enabled, using `set.seed(1)` for reproducibility. This is useful for simulations or when randomness is desired in the analysis. ```r set.seed(1); Alpha_investing(sample.df) ``` -------------------------------- ### AlphaInvesting with DataFrame Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/AlphaInvesting.html Example of using AlphaInvesting with a dataframe containing p-values, identifiers, and dates. Set random=FALSE to disable p-value randomization within batches. ```R sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), date = as.Date(c(rep("2014-12-01",3), rep("2015-09-21",5), rep("2016-05-19",2), "2016-11-12", rep("2017-03-27",4))), pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757)) AlphaInvesting(sample.df, random=FALSE) ``` -------------------------------- ### Run ADDIS.spending with default parameters Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/reference/ADDIS.spending.html This snippet demonstrates the basic usage of the ADDIS.spending function with a vector of p-values and default settings for alpha, lambda, and tau. It returns the p-values, adjusted testing levels, and an indicator of discoveries. ```R pval <- c(2.90e-08, 0.06743, 3.51e-04, 0.0154, 0.04723, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-06, 0.69274, 0.30443, 0.00136, 0.82342, 5.4757e-04) ADDIS.spending(pval) ``` -------------------------------- ### Batch Processing with BatchPRDS Source: https://github.com/dsrobertson/onlinefdr/blob/master/docs/articles/onlineFDR.md Example of using the BatchPRDS algorithm for hypothesis tests performed in batches. This is suitable when data naturally arrives or is processed in distinct groups. ```r sample.df <- data.frame( id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', 'C38292', 'A30619', 'D46627', 'E29198', 'A41418', 'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, 3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, 0.69274, 0.30443, 0.00136, 0.72342, 0.54757), batch = c(rep(1,5), rep(2,6), rep(3,4))) batchprds_results <- BatchPRDS(sample.df) ```