Skip to content

Commit

Permalink
move to simulated data for LFQDataStats examples, fix stats_wide() fu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
wolski committed May 7, 2024
1 parent d4a6af2 commit c8bdc35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
20 changes: 5 additions & 15 deletions R/LFQDataStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#' stopifnot(is.null(x$power_t_test_quantiles()))
#' }
#' }
#' istar <- prolfqua_data('data_ionstar')$filtered()
#' istar$config <- old2new(istar$config)
#' data <- istar$data |> dplyr::filter(protein_Id %in% sample(protein_Id, 100))
#' bb <- prolfqua::sim_lfq_data_peptide_config()
#' istar$config <- bb$config
#' data <-bb$data
#' lfqdata <- LFQData$new(data, istar$config)
#' lfqstats <- lfqdata$get_Stats()
#' lfqstats$stats_wide()
Expand All @@ -39,24 +39,14 @@
#'
#' #study variance of normalized data
#'
#' istar <- prolfqua_data('data_ionstar')$normalized()
#' istar$config <- old2new(istar$config)
#' istar$config$table$is_response_transformed
#' data <- istar$data |> dplyr::filter(protein_Id %in% sample(protein_Id, 100))
#'
#' lfqdata <- LFQData$new(data, istar$config)
#' lfqdata$is_transformed(TRUE)
#' lfqstats <- lfqdata$get_Stats()
#' runallfuncs(lfqstats)
#'
#' #Slightly different dataset
#'
#' bb <- prolfqua_data('data_ionstar')$filtered()
#' bb$config <- old2new(bb$config)
#' stopifnot(nrow(bb$data) == 25780)
#' config <- bb$config$clone(deep = TRUE)
#' analysis <- bb$data
#'
#' lfqdata <- LFQData$new(analysis, config)
#'
#' # estimates statistics for all samples
#' lfqstats <- lfqdata$get_Stats(stats = "all")
Expand Down Expand Up @@ -110,7 +100,7 @@ LFQDataStats <- R6::R6Class(
res <- tidyr::pivot_wider(
self$statsdf,id_cols = self$lfq$config$table$hierarchy_keys() ,
names_from = self$lfq$config$table$factor_keys_depth(),
values_from = tidyselect::any_of( c("n", "not_na", "sd", "var", "mean", "CV")))
values_from = tidyselect::any_of( c("nrReplicates", "nrMeasured", "sd", "var", "meanAbundance","medianAbundance", "CV")))
return(res)
},
#' @description
Expand Down
2 changes: 1 addition & 1 deletion R/tidyMS_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ summarize_stats <- function(pdata, config, factor_key = config$table$factor_keys
var = stats::var(!!intsym, na.rm = TRUE),
meanAbundance = mean(!!intsym, na.rm = TRUE),
medianAbundance = median(!!intsym, na.rm = TRUE),
.groups = "drop_last") |> dplyr::ungroup()
.groups = "drop") |> dplyr::ungroup()

hierarchyFactor <- hierarchyFactor |>
dplyr::mutate(dplyr::across(all_of(factor_key), as.character))
Expand Down
18 changes: 4 additions & 14 deletions man/LFQDataStats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8bdc35

Please sign in to comment.