Planning future experimental designs of PTM experiments in sample size calculation
Source:R/designSampleSizePTM.R
designSampleSizePTM.RdCalculate sample size for future experiments of a PTM experiment based on intensity-based linear model. Calculation is only available for group comparison experimental designs (not including time series). Two options of the calculation: (1) number of biological replicates per condition, (2) power.
Usage
designSampleSizePTM(
data,
desiredFC,
FDR = 0.05,
numSample = TRUE,
power = 0.8,
use_log_file = TRUE,
append = FALSE,
verbose = TRUE,
log_file_path = NULL,
base = "MSstatsPTM_log_"
)Arguments
- data
output of the groupComparisonPTM function.
- desiredFC
the range of a desired fold change which includes the lower and upper values of the desired fold change.
- FDR
a pre-specified false discovery ratio (FDR) to control the overall false positive rate. Default is 0.05
- numSample
minimal number of biological replicates per condition. TRUE represents you require to calculate the sample size for this category, else you should input the exact number of biological replicates.
- power
a pre-specified statistical power which defined as the probability of detecting a true fold change. TRUE represent you require to calculate the power for this category, else you should input the average of power you expect. Default is 0.9
- use_log_file
logical. If TRUE, information about data processing will be saved to a file.
- append
logical. If TRUE, information about data processing will be added to an existing log file.
- verbose
logical. If TRUE, information about data processing will be printed to the console.
- log_file_path
character. Path to a file to which information about data processing will be saved. If not provided, such a file will be created automatically. If
append = TRUE, has to be a valid path to a file.- base
start of the file name.
Value
data.frame - sample size calculation results including varibles: desiredFC, numSample, FDR, and power.
Details
The function fits the model and uses variance components to calculate sample size. The underlying model fitting with intensity-based linear model with technical MS run replication. Estimated sample size is rounded to 0 decimal. The function can only obtain either one of the categories of the sample size calculation (numSample, numPep, numTran, power) at the same time.
Examples
model.lf.msstatsptm = groupComparisonPTM(summary.data,
ptm_label_type="LF",
protein_label_type="LF",
verbose = FALSE)
#> Starting PTM modeling...
#> INFO [2026-04-09 15:19:33] == Start to test and get inference in whole plot ...
#>
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|=== | 4%
|
|=== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 8%
|
|====== | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 26%
|
|=================== | 26%
|
|=================== | 27%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|======================= | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================== | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 73%
|
|=================================================== | 74%
|
|==================================================== | 74%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
#> INFO [2026-04-09 15:19:35] == Comparisons for all proteins are done.
#> Starting Protein modeling...
#> INFO [2026-04-09 15:19:35] == Start to test and get inference in whole plot ...
#>
|
| | 0%
|
|=== | 4%
|
|===== | 8%
|
|======== | 12%
|
|=========== | 15%
|
|============= | 19%
|
|================ | 23%
|
|=================== | 27%
|
|====================== | 31%
|
|======================== | 35%
|
|=========================== | 38%
|
|============================== | 42%
|
|================================ | 46%
|
|=================================== | 50%
|
|====================================== | 54%
|
|======================================== | 58%
|
|=========================================== | 62%
|
|============================================== | 65%
|
|================================================ | 69%
|
|=================================================== | 73%
|
|====================================================== | 77%
|
|========================================================= | 81%
|
|=========================================================== | 85%
|
|============================================================== | 88%
|
|================================================================= | 92%
|
|=================================================================== | 96%
|
|======================================================================| 100%
#> INFO [2026-04-09 15:19:36] == Comparisons for all proteins are done.
#> Starting adjustment...
#(1) Minimal number of biological replicates per condition
designSampleSizePTM(data=model.lf.msstatsptm, numSample=TRUE,
desiredFC=c(2.0,2.75), FDR=0.05, power=0.8)
#> desiredFC numSample FDR power
#> 1 2.000 30 0.05 0.8
#> 2 2.025 29 0.05 0.8
#> 3 2.050 28 0.05 0.8
#> 4 2.075 27 0.05 0.8
#> 5 2.100 27 0.05 0.8
#> 6 2.125 26 0.05 0.8
#> 7 2.150 25 0.05 0.8
#> 8 2.175 24 0.05 0.8
#> 9 2.200 24 0.05 0.8
#> 10 2.225 23 0.05 0.8
#> 11 2.250 22 0.05 0.8
#> 12 2.275 22 0.05 0.8
#> 13 2.300 21 0.05 0.8
#> 14 2.325 21 0.05 0.8
#> 15 2.350 20 0.05 0.8
#> 16 2.375 20 0.05 0.8
#> 17 2.400 19 0.05 0.8
#> 18 2.425 19 0.05 0.8
#> 19 2.450 18 0.05 0.8
#> 20 2.475 18 0.05 0.8
#> 21 2.500 17 0.05 0.8
#> 22 2.525 17 0.05 0.8
#> 23 2.550 17 0.05 0.8
#> 24 2.575 16 0.05 0.8
#> 25 2.600 16 0.05 0.8
#> 26 2.625 16 0.05 0.8
#> 27 2.650 15 0.05 0.8
#> 28 2.675 15 0.05 0.8
#> 29 2.700 15 0.05 0.8
#> 30 2.725 15 0.05 0.8
#> 31 2.750 14 0.05 0.8
#(2) Power calculation
designSampleSizePTM(data=model.lf.msstatsptm, numSample=5,
desiredFC=c(2.0,2.75), FDR=0.05, power=TRUE)
#> desiredFC numSample FDR power
#> 1 2.000 5 0.05 0.01
#> 2 2.025 5 0.05 0.01
#> 3 2.050 5 0.05 0.01
#> 4 2.075 5 0.05 0.01
#> 5 2.100 5 0.05 0.01
#> 6 2.125 5 0.05 0.01
#> 7 2.150 5 0.05 0.01
#> 8 2.175 5 0.05 0.01
#> 9 2.200 5 0.05 0.01
#> 10 2.225 5 0.05 0.01
#> 11 2.250 5 0.05 0.01
#> 12 2.275 5 0.05 0.01
#> 13 2.300 5 0.05 0.01
#> 14 2.325 5 0.05 0.01
#> 15 2.350 5 0.05 0.01
#> 16 2.375 5 0.05 0.01
#> 17 2.400 5 0.05 0.01
#> 18 2.425 5 0.05 0.01
#> 19 2.450 5 0.05 0.01
#> 20 2.475 5 0.05 0.02
#> 21 2.500 5 0.05 0.02
#> 22 2.525 5 0.05 0.02
#> 23 2.550 5 0.05 0.02
#> 24 2.575 5 0.05 0.03
#> 25 2.600 5 0.05 0.03
#> 26 2.625 5 0.05 0.03
#> 27 2.650 5 0.05 0.04
#> 28 2.675 5 0.05 0.04
#> 29 2.700 5 0.05 0.05
#> 30 2.725 5 0.05 0.05
#> 31 2.750 5 0.05 0.05