Decorates LFQData with methods to compute statistics of interactions
Source:R/LFQDataStats.R
LFQDataStats.Rdcompute stdv, mean and CV per peptide or protein and condition.
Methods
LFQDataStats$new()
create analyse variances and CV
Usage
LFQDataStats$new(lfqdata, stats = c("everything", "interaction", "all"))Arguments
lfqdataLFQData object with the data and its configuration
statsif
interaction, compute within-group stats; ifall, compute overall CV; ifpooled, use pooled variance with grouping information
LFQDataStats$stats_quantiles()
Determine CV or sd for the quantiles
Usage
LFQDataStats$stats_quantiles(probs = c(0.1, 0.25, 0.5, 0.75, 0.9))LFQDataStats$density()
plots density or ecdf
Usage
LFQDataStats$density(ggstat = c("density", "ecdf"))LFQDataStats$density_median()
plot density or ecdf of CV or sd for the 50% of low intensity data and 50% of high intensity data
Usage
LFQDataStats$density_median(ggstat = c("density", "ecdf"))LFQDataStats$violin_median()
plot violinplot of CV or sd for the 50% of low intensity data and 50% of high intensity data
LFQDataStats$power_t_test_quantiles()
compute sample size for entire dataset
Arguments
probsnumeric vector of probabilities in [0, 1]: the quantiles of the sd for which sample sizes are computed
deltanumeric vector of positive effect sizes (differences on the response scale)
powerone number in (0, 1), the power of the test
sig.levelone number in (0, 1), the significance level
LFQDataStats$power_t_test()
compute sample for each protein
Usage
LFQDataStats$power_t_test(delta = c(0.59, 1, 2), power = 0.8, sig.level = 0.05)LFQDataStats$power_fdr_pilot()
Plan balanced two-group sample size from pooled within-group pilot
variances; see power_fdr_prior_n() for assumptions and returned values.
Grouping and feature identities follow the current LFQData configuration,
regardless of the stats mode used to construct this decorator.
Untransformed data raise an error.
Usage
LFQDataStats$power_fdr_pilot(
delta_mean,
delta_se = 0,
fdr = 0.05,
power = 0.8,
pi0 = 0.95,
max_n = 100
)Arguments
delta_meanplanned mean difference among non-null features, on the transformed response scale
delta_sestandard deviation of true non-null differences, not an estimated mean's standard error
fdrtarget false discovery rate
powertarget average power among non-null features
pi0assumed proportion of truly null features
max_nlargest sample count per group to consider
Returns
The list returned by power_fdr_prior_n().
Examples
# study variance of not normalized data
#source("c:/Users/wewol/prog/prolfqua/R/LFQData.R")
runallfuncs <- function(x){
stopifnot("data.frame" %in% class(x$stats()))
stopifnot("data.frame" %in% class(x$stats_wide()))
stopifnot(c("long", "wide") %in% names(x$stats_quantiles()))
stopifnot("ggplot" %in% class(x$density()))
stopifnot("ggplot" %in% class(x$density_median()))
stopifnot("ggplot" %in% class(x$density("ecdf")))
stopifnot("ggplot" %in% class(x$density_median("ecdf")))
stopifnot("ggplot" %in% class(x$violin()))
stopifnot("ggplot" %in% class(x$violin_median()))
stopifnot("ggplot" %in% class(x$stdv_vs_mean(size = 400)))
# the power methods need transformed data and raise an error otherwise
if (x$lfq$is_transformed()) {
stopifnot(is.list(x$power_fdr_pilot(delta_mean = 0.1, max_n = 20)))
}
}
bb <- prolfqua::sim_lfq_data_peptide_config()
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, mean, N, avg_peptide_abd, Replicate.
#> setup_analysis: added 36 rows with NA response for feature and sample combinations absent from the input.
lfqdata <- LFQData$new(bb$data, bb$config)
lfqstats <- lfqdata$get_Stats()
stopifnot(ncol(lfqstats$stats_wide()) == 30)
lfqstats$violin()
runallfuncs(lfqstats)
x <- lfqstats
#study variance of normalized data
lfqdata <- LFQData$new(bb$data, bb$config)
lfqdata$is_transformed(TRUE)
lfqstats <- lfqdata$get_Stats()
stopifnot(ncol(lfqstats$stats_wide()) == 26)
runallfuncs(lfqstats)
#Slightly different dataset
# estimates statistics for all samples
lfqstats <- lfqdata$get_Stats(stats = "all")
stopifnot(ncol(lfqstats$stats_wide()) == 8)
runallfuncs(lfqstats)
lfqstats <- lfqdata$get_Stats(stats = "interaction")
stopifnot(ncol(lfqstats$stats_wide()) == 20)
runallfuncs(lfqstats)
# Group size 1
bb <- prolfqua::sim_lfq_data_peptide_config(n_per_group = 1)
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, mean, N, avg_peptide_abd, Replicate.
#> setup_analysis: added 8 rows with NA response for feature and sample combinations absent from the input.
lfq1 <- LFQData$new(bb$data, bb$config)
lfq1$factors()
#> # A tibble: 3 × 3
#> sample sampleName group_
#> <chr> <chr> <chr>
#> 1 A_V1 A_V1 A
#> 2 B_V1 B_V1 B
#> 3 Ctrl_V1 Ctrl_V1 Ctrl
lfqdata <- LFQData$new(bb$data, bb$config)
lfqstats <- lfqdata$get_Stats()
# stopifnot(ncol(lfqstats$stats_wide()) == 30)
lfqstats$violin()
runallfuncs(lfqstats)