Skip to content

Commit

Permalink
Allow for the filtering of aggregation plots.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Jun 17, 2024
1 parent a550261 commit 10df549
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
2 changes: 2 additions & 0 deletions R/Contrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ Contrasts <- R6::R6Class(
}else{

res <- vector(mode = "list", nrow(self$models))
pb <- progress::progress_bar$new(total = length(self$models$linear_model))
for (i in seq_along(self$models$linear_model)) {
pb$tick()
res[[i]] <- .linfct(self$models$linear_model[[i]], contrast = self$contrasts, avg = avg)
}
return(res)
Expand Down
20 changes: 14 additions & 6 deletions R/LFQDataAggregator.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,39 @@ LFQDataAggregator <- R6::R6Class(
private$.topN(N = N, .func = sum_f)
},
#' @description
#' creates aggreation plots
#' creates aggregation plots
#' @param subset create plots for a subset of the data only, e.g. proteins with more then 2 peptides.
#' @param show.legend default FALSE
#' @return data.frame
#'
plot = function(show.legend = FALSE){
plot = function(subset = NULL, show.legend = FALSE){
if (is.null(self$lfq_agg)) {
stop("please aggregate the data first")
}

if (!is.null(subset)) {
lfqagg <- self$lfq_agg$get_subset(subset)
}else {
lfqagg <- self$lfq_agg
}
df <- prolfqua::plot_estimate(
self$lfq$data,
self$lfq$config,
self$lfq_agg$data,
self$lfq_agg$config,
lfqagg$data,
lfqagg$config,
show.legend = show.legend)
invisible(df)
},
#' @description
#' writes plots to folder
#'
#' @param qcpath qcpath
#' @param show.legend legend
#' @param width figure width
#' @param height figure height
#' @return file path
write_plots = function(qcpath, show.legend = FALSE, width = 6, height = 6){
pl <- self$plot()
write_plots = function(qcpath, subset = NULL, show.legend = FALSE, width = 6, height = 6){
pl <- self$plot(subset)
pb <- progress::progress_bar$new(total = nrow(pl))
filepath <- file.path(qcpath, paste0(self$prefix, "_aggregation_plot.pdf"))
pdf(filepath , width = width, height = height)
Expand Down
4 changes: 4 additions & 0 deletions R/tidyMS_R6Model.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ build_model <- function(data,
subject_Id = subject_Id))
}





#' Summarize modelling and error reporting
#' @param mod model table see \code{\link{build_model}}
#' @keywords internal
Expand Down
9 changes: 5 additions & 4 deletions R/tidyMS_R6_Modelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,11 @@ get_complete_model_fit <- function(modelProteinF){
#' subject_Id = x$config$table$hierarchy_keys_depth())
#' stopifnot(nrow(get_complete_model_fit(mr$modelProtein)) == 6)
#'
model_analyse <- function(pepIntensity,
model_strategy,
subject_Id = "protein_Id",
modelName = "Model")
model_analyse <- function(
pepIntensity,
model_strategy,
subject_Id = "protein_Id",
modelName = "Model")
{
pepIntensity |>
dplyr::group_by(!!!syms(subject_Id)) |>
Expand Down
6 changes: 5 additions & 1 deletion R/tidyMS_aggregation.R
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,11 @@ estimate_intensity <- function(data, config, .func)
#' stopifnot("ggplot" %in% class(tmpRob$plots[[2]]))
#'
#'
plot_estimate <- function(data, config, data_aggr, config_reduced, show.legend= FALSE ){
plot_estimate <- function(data,
config,
data_aggr,
config_reduced,
show.legend = FALSE ){
hierarchy_ID <- "hierarchy_ID"
xnested <- data |> group_by(!!!syms(config$table$hierarchy_keys_depth())) |> nest()
xnested <- xnested |> tidyr::unite(hierarchy_ID , !!!syms(config$table$hierarchy_keys_depth()))
Expand Down
7 changes: 5 additions & 2 deletions man/LFQDataAggregator.Rd

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

0 comments on commit 10df549

Please sign in to comment.