Skip to content

Commit

Permalink
fix(dataProcessPlots): Remove duplicate log-transformation of intensi…
Browse files Browse the repository at this point in the history
…ty (#98)

* fix(dataProcessPlots): Remove duplicate log-transformation of intensity

* add unit test to verify data sent to plotting is valid
  • Loading branch information
tonywu1999 authored Sep 24, 2024
1 parent a8f5574 commit 4111c18
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
9 changes: 8 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ Depends: R (>= 4.3)
Imports: dplyr, gridExtra, stringr, stats, ggplot2, stringi,
grDevices, MSstatsTMT, MSstatsConvert, MSstats,
data.table, Rcpp, Biostrings, checkmate, ggrepel
Suggests: knitr, rmarkdown, tinytest, covr
Suggests:
knitr,
rmarkdown,
tinytest,
covr,
mockery,
testthat (>= 3.0.0)
LazyData: true
LinkingTo: Rcpp
VignetteBuilder: knitr
Expand All @@ -33,3 +39,4 @@ BugReports: https://github.com/Vitek-Lab/MSstatsPTM/issues
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Config/testthat/edition: 3
5 changes: 1 addition & 4 deletions R/utils_dataProcessPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@
## Adjust colnames to avoid repeating code
for (i in seq_along(data.list)) {
colnames(data.list[[i]]) = toupper(colnames(data.list[[i]]))
if ('INTENSITY' %in% colnames(data.list[[i]])){
data.list[[i]]$ABUNDANCE = log2(data.list[[i]]$INTENSITY)
}
setnames(data.list[[i]], c('LOGINTENSITIES', 'GROUP', 'PROTEIN',
'Protein', 'LOG2INTENSITY'),
c('ABUNDANCE', 'CONDITION', 'PROTEINNAME', 'PROTEINNAME',
Expand Down Expand Up @@ -1755,4 +1752,4 @@
if (address != FALSE) {
dev.off()
}
}
}
13 changes: 13 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(mockery)
library(MSstatsPTM)

test_check("MSstatsPTM")
19 changes: 19 additions & 0 deletions tests/testthat/test_dataProcessPlotsPTM.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
test_that("Medians are equalized in ptm data to QC plot helper function", {
mock_qc_all_plot_lf <- mock()
stub(
dataProcessPlotsPTM, ".qc.all.plot.lf",
mock_qc_all_plot_lf, depth=2
)

dataProcessPlotsPTM(summary.data,
type = 'QCPLOT',
which.PTM = "allonly",
address = FALSE)

calls <- mock_args(mock_qc_all_plot_lf)
ptm_data <- calls[[1]][[1]]
run_data = split(ptm_data, ptm_data$RUN)
for (i in 1:length(run_data)){
expect_equal(median(run_data[[i]]$ABUNDANCE, na.rm = TRUE), 22.028431)
}
})

0 comments on commit 4111c18

Please sign in to comment.