Skip to content

Commit 3a09433

Browse files
committed
Remove LFQDataWriter, lfq_write_table, and unused dependency imports
- Delete R/LFQDataWriter.R and R/tidyMS_write.R (removed writexl, DT, htmlwidgets, readr dependencies) - Remove conflicted::conflict_prefer usage from vignettes, use library(dplyr) instead - Replace GSEA code section in Comparing2Groups vignette with descriptive text and links to clusterProfiler documentation - Clean up unused @importFrom directives across R source files - Regenerate NAMESPACE and man/ pages
1 parent c898259 commit 3a09433

31 files changed

Lines changed: 94 additions & 542 deletions

NAMESPACE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export(LFQDataStats)
2020
export(LFQDataSummariser)
2121
export(LFQDataToSummarizedExperiment)
2222
export(LFQDataTransformer)
23-
export(LFQDataWriter)
2423
export(LR_test)
2524
export(MissingHelpers)
2625
export(Model)
@@ -77,7 +76,6 @@ export(level_specific_contrasts)
7776
export(lfq_power_t_test_proteins)
7877
export(lfq_power_t_test_quantiles)
7978
export(lfq_power_t_test_quantiles_V2)
80-
export(lfq_write_table)
8179
export(linfct_all_possible_contrasts)
8280
export(linfct_factors_contrasts)
8381
export(linfct_from_model)
@@ -196,7 +194,6 @@ import(dplyr)
196194
import(ggplot2)
197195
importFrom(MASS,rlm)
198196
importFrom(UpSetR,upset)
199-
importFrom(conflicted,conflict_prefer)
200197
importFrom(dplyr,across)
201198
importFrom(dplyr,all_of)
202199
importFrom(dplyr,anti_join)
@@ -246,7 +243,6 @@ importFrom(graphics,plot)
246243
importFrom(graphics,rect)
247244
importFrom(graphics,text)
248245
importFrom(gridExtra,grid.arrange)
249-
importFrom(htmlwidgets,saveWidget)
250246
importFrom(methods,is)
251247
importFrom(pheatmap,pheatmap)
252248
importFrom(plotly,ggplotly)

R/A_dataset_docu.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#' @importFrom conflicted conflict_prefer
21
#' @importFrom forcats fct_relevel
32
#' @importFrom dplyr across all_of anti_join arrange bind_cols bind_rows case_when count desc distinct filter group_by
43
#' @importFrom dplyr inner_join left_join mutate nest_by
@@ -13,7 +12,6 @@
1312
#' @importFrom graphics par rect hist
1413
#' @importFrom graphics abline pairs plot text
1514
#' @importFrom grDevices colorRampPalette dev.off pdf png rainbow
16-
#' @importFrom htmlwidgets saveWidget
1715
#' @importFrom pheatmap pheatmap
1816
#' @importFrom plotly ggplotly
1917
#' @importFrom purrr map map2 map2_dbl map_lgl map_chr map_dbl reduce map_if map_dfc map_int map_df

R/AnalysisConfiguration.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ setup_analysis <- function(data, configuration, cc = TRUE, from_factors = FALSE
468468
#'
469469
#'
470470
#' @export
471-
#' @seealso \code{\link{lfq_write_table}}
472471
#' @param data data.frame
473472
#' @param config AnlalysisConfiguration
474473
#' @family configuration

R/ContrastsPlotter.R

Lines changed: 25 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -218,45 +218,9 @@ ContrastsPlotter <- R6::R6Class(
218218
#' @param rank default FALSE, if TRUE then rank of avgAbd is used.
219219
#' @return ggplot
220220
ma_plot = function(fc, colour, legend = TRUE, rank = TRUE){
221-
if ( missing(fc))
222-
fc <- self$fcthresh
223-
if (missing(colour)) {
224-
colour <- self$modelName
225-
}
226-
contrastDF <- self$contrastDF
227-
if (!is.null(contrastDF[[self$avg.abundance]])) {
228-
# pdf version
229-
if (rank) {
230-
rankcol <- paste0("rank_", self$avg.abundance)
231-
232-
contrastDF <- contrastDF |>
233-
dplyr::group_by(!!sym(self$contrast)) |>
234-
mutate(!!rankcol := rank(!!sym(self$avg.abundance)))
235-
236-
#contrastDF[[ rankcol ]] <- rank(contrastDF[[self$avg.abundance]])
237-
fig <- private$.ma_plot(
238-
contrastDF,
239-
rankcol,
240-
self$diff,
241-
self$contrast,
242-
fc,
243-
colour = colour,
244-
legend = legend )
245-
}else{
246-
fig <- private$.ma_plot(
247-
contrastDF,
248-
self$avg.abundance,
249-
self$diff,
250-
self$contrast,
251-
fc,
252-
colour = colour,
253-
legend = legend)
254-
}
255-
}else{
256-
warning("no group_1 group_2 columns can't generate MA")
257-
fig <- NULL
258-
}
259-
return(fig)
221+
if (missing(fc)) fc <- self$fcthresh
222+
if (missing(colour)) colour <- self$modelName
223+
private$.ma_fig(self$contrastDF, fc, colour, legend, rank)
260224
},
261225
#' @description
262226
#' ma plotly
@@ -266,49 +230,11 @@ ContrastsPlotter <- R6::R6Class(
266230
#' @param rank default FALSE, if TRUE then rank of avgAbd is used.
267231
#' @return list of ggplots
268232
ma_plotly = function(fc, colour, legend = TRUE, rank = FALSE){
269-
# html version
270-
if (missing(fc))
271-
fc <- self$fcthresh
272-
if (missing(colour))
273-
colour <- self$modelName
274-
contrastDF <- self$contrastDF
275-
if (!is.null(contrastDF[[self$avg.abundance]])) {
276-
if (rank) {
277-
rankcol <- paste0("rank_", self$avg.abundance)
278-
contrastDF <- contrastDF |>
279-
dplyr::group_by(!!sym(self$contrast)) |>
280-
mutate(!!rankcol := rank(!!sym(self$avg.abundance)))
281-
282-
fig <- private$.ma_plot(
283-
contrastDF,
284-
rankcol,
285-
self$diff,
286-
self$contrast,
287-
fc,
288-
colour = colour,
289-
legend = legend
290-
)
291-
} else {
292-
contrastDF <- contrastDF |>
293-
plotly::highlight_key(~subject_Id)
294-
fig <- private$.ma_plot(
295-
contrastDF,
296-
self$avg.abundance,
297-
self$diff,
298-
self$contrast,
299-
fc,
300-
colour = colour,
301-
legend = legend
302-
)
303-
}
304-
305-
fig_plotly <- fig |>
306-
plotly::ggplotly(tooltip = "subject_Id")
307-
308-
return(fig_plotly)
309-
}else{
310-
return(NULL)
311-
}
233+
if (missing(fc)) fc <- self$fcthresh
234+
if (missing(colour)) colour <- self$modelName
235+
fig <- private$.ma_fig(self$contrastDF, fc, colour, legend, rank, plotly_mode = TRUE)
236+
if (!is.null(fig)) fig <- fig |> plotly::ggplotly(tooltip = "subject_Id")
237+
fig
312238
},
313239
#' @description
314240
#' plot a score against the log2 fc e.g. t-statistic
@@ -383,6 +309,23 @@ ContrastsPlotter <- R6::R6Class(
383309
}
384310
),
385311
private = list(
312+
.ma_fig = function(contrastDF, fc, colour, legend, rank, plotly_mode = FALSE) {
313+
if (is.null(contrastDF[[self$avg.abundance]])) {
314+
if (!plotly_mode) warning("no group_1 group_2 columns can't generate MA")
315+
return(NULL)
316+
}
317+
xcol <- self$avg.abundance
318+
if (rank) {
319+
xcol <- paste0("rank_", self$avg.abundance)
320+
contrastDF <- contrastDF |>
321+
dplyr::group_by(!!sym(self$contrast)) |>
322+
dplyr::mutate(!!xcol := rank(!!sym(self$avg.abundance)))
323+
} else if (plotly_mode) {
324+
contrastDF <- contrastDF |> plotly::highlight_key(~subject_Id)
325+
}
326+
private$.ma_plot(contrastDF, xcol, self$diff, self$contrast, fc,
327+
colour = colour, legend = legend)
328+
},
386329
.volcano = function(contrasts,
387330
scores,
388331
colour = NULL,

R/ContrastsProDA.R

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,5 @@ ContrastsProDA <- R6::R6Class(
115115
columns = c("diff", columns),
116116
contrast = 'contrast')
117117
return(contrasts_wide)
118-
},
119-
#' @description write results
120-
#' @param path directory
121-
#' @param filename file to write to
122-
#' @param format default xlsx \code{\link{lfq_write_table}}
123-
write = function(path, filename, format = "xlsx"){
124-
filename <- if (missing(filename)) {self$modelName} else (filename )
125-
lfq_write_table(self$get_contrasts(),
126-
path = path,
127-
name = paste0("Contrasts_",filename),
128-
format = format)
129118
}
130119
))

R/LFQData.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
#'
33
#' LFQData R6 class
44
#'
5+
#' @section Missing Data Assumptions:
6+
#' The filtering and imputation methods in this package assume that
7+
#' missing values are Missing Completely At Random (MCAR) or Missing At
8+
#' Random (MAR). Abundance-dependent missingness (MNAR), which is common
9+
#' in DDA proteomics, is not modelled. Users should be aware that MNAR
10+
#' can bias fold-change estimates and inflate false discovery rates.
11+
#'
512
#' @export
613
#' @family LFQData
714
#' @examples

R/LFQDataImp.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function_lod_quantile <- function(data_matrix, percent = 10) {
7474
#' "GBM", "SQ", "BL", or "CZM" (passed to zCompositions)
7575
#' @param lod limit of detection strategy, either "global" or "quantile"
7676
#' @return the modified LFQData object (lfqdata), with imputed values
77+
#' @note This function assumes that missing values are Missing Completely
78+
#' At Random (MCAR) or Missing At Random (MAR). If missingness is
79+
#' abundance-dependent (MNAR, common in proteomics DDA), the imputed
80+
#' values and downstream statistics may be biased. For MNAR-aware
81+
#' analysis, consider packages such as proDA or DEqMS.
7782
#' @export
7883
#'
7984
#' @examples

R/LFQDataSummariser.R

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,19 @@ LFQDataSummariser <- R6::R6Class(
101101
#' Computes the percent abundance of proteins overall and within each group
102102
#' @return data frame
103103
percentage_abundance = function(){
104-
# roll up to protein intensities
105-
# compute protein level summaries
106-
107104
dall <- prolfqua::summarize_stats_all(self$lfq$data, self$lfq$config)
108105
dfac <- prolfqua::summarize_stats_factors(self$lfq$data, self$lfq$config)
109-
110106
all <- dplyr::bind_rows(dfac, dall)
111-
nested <- all |> dplyr::group_by(!!sym("interaction")) |> tidyr::nest()
112-
for (i in seq_len(nrow(nested))) {
113-
nested$data[[i]] <- nested$data[[i]] |>
114-
dplyr::arrange(.data$meanAbundance) |>
115-
dplyr::mutate(id = dplyr::row_number()) |>
116-
dplyr::mutate(abundance_percent = meanAbundance/sum(meanAbundance, na.rm = TRUE)*100 ) |>
117-
dplyr::mutate(abundance_percent_cumulative = cumsum(ifelse(is.na(abundance_percent), 0, abundance_percent)) + abundance_percent*0) |>
118-
dplyr::mutate(percent_prot = id / max(id) * 100)
119-
}
120-
res <- tidyr::unnest(nested, cols = "data")
107+
res <- all |>
108+
dplyr::group_by(!!sym("interaction")) |>
109+
dplyr::arrange(.data$meanAbundance, .by_group = TRUE) |>
110+
dplyr::mutate(
111+
id = dplyr::row_number(),
112+
abundance_percent = meanAbundance / sum(meanAbundance, na.rm = TRUE) * 100,
113+
abundance_percent_cumulative = cumsum(ifelse(is.na(abundance_percent), 0, abundance_percent)) + abundance_percent * 0,
114+
percent_prot = id / max(id) * 100
115+
) |>
116+
dplyr::ungroup()
121117
return(res)
122118
}
123119

R/LFQDataWriter.R

Lines changed: 0 additions & 72 deletions
This file was deleted.

R/Model.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,6 @@ Model <- R6::R6Class(
109109
return(dplyr::ungroup(Model_Anova))
110110
},
111111

112-
#' @description
113-
#' writes model coefficients to file
114-
#' @param path folder to write to
115-
#' @param format default xlsx \code{\link{lfq_write_table}}
116-
write_coefficients = function(path, format = "xlsx"){
117-
lfq_write_table(self$get_coefficients(),
118-
path = path,
119-
name = paste0("Coef_",self$modelName),
120-
format = format)
121-
},
122112
#' @description
123113
#' histogram of model coefficient
124114
coef_histogram = function(){

0 commit comments

Comments
 (0)