From 19d6fd7d71f0cf634d092e3ea1fe3432161d233f Mon Sep 17 00:00:00 2001 From: Witold Wolski Date: Thu, 29 Aug 2024 09:30:39 +0200 Subject: [PATCH] diff --- R/LFQDataStats.R | 12 +++++++----- man/LFQDataStats.Rd | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/R/LFQDataStats.R b/R/LFQDataStats.R index 48c4ee9c..30f61a56 100644 --- a/R/LFQDataStats.R +++ b/R/LFQDataStats.R @@ -67,6 +67,8 @@ LFQDataStats <- R6::R6Class( stat = "CV", #' @field statsdf frame with statistics. statsdf = NULL, + #' @field factor_keys_depth factor columns + factor_keys_depth = character(), #' @description #' create analyse variances and CV #' @param lfqdata LFQData object @@ -77,20 +79,20 @@ LFQDataStats <- R6::R6Class( self$stat <- if (!self$lfq$is_transformed()) {"CV"} else {"sd"} tb <- table_factors_size(lfqdata$data,lfqdata$config ) - fd <- lfqdata$config$table$factor_keys_depth() + self$factor_keys_depth <- lfqdata$config$table$factor_keys_depth() if ( all(tb$n == 1) ) { - fd <- head(fd, n = length(fd) - 1) + self$factor_keys_depth <- head(self$factor_keys_depth, n = length(self$factor_keys_depth) - 1) } if (stats == "interaction" ) { - self$statsdf <- prolfqua::summarize_stats(self$lfq$data, self$lfq$config, factor_key = fd) + self$statsdf <- prolfqua::summarize_stats(self$lfq$data, self$lfq$config, factor_key = self$factor_keys_depth) } else if (stats == "all" ) { self$statsdf <- prolfqua::summarize_stats_all(self$lfq$data, self$lfq$config) } else if (stats == "everything" ) { self$statsdf <- bind_rows( - prolfqua::summarize_stats(self$lfq$data, self$lfq$config, factor_key = fd), + prolfqua::summarize_stats(self$lfq$data, self$lfq$config, factor_key = self$factor_keys_depth), prolfqua::summarize_stats_all(self$lfq$data, self$lfq$config) ) } @@ -107,7 +109,7 @@ LFQDataStats <- R6::R6Class( stats_wide = function(){ res <- tidyr::pivot_wider( self$statsdf,id_cols = self$lfq$config$table$hierarchy_keys() , - names_from = self$lfq$config$table$factor_keys_depth(), + names_from = self$factor_keys_depth, values_from = tidyselect::any_of( c("nrReplicates", "nrMeasured", "sd", "var", "meanAbundance","medianAbundance", "CV"))) return(res) }, diff --git a/man/LFQDataStats.Rd b/man/LFQDataStats.Rd index 5ee310c3..b9f2bb54 100644 --- a/man/LFQDataStats.Rd +++ b/man/LFQDataStats.Rd @@ -82,6 +82,8 @@ Other LFQData: \item{\code{stat}}{either CV or sd (if is_transformed)} \item{\code{statsdf}}{frame with statistics.} + +\item{\code{factor_keys_depth}}{factor columns} } \if{html}{\out{}} }