Skip to content

Commit 7ec49d1

Browse files
committed
Address CodeRabbit review feedback
1 parent 589ebb5 commit 7ec49d1

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

R/clean_MZMine.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
stop("mzmine_annotations is missing required column(s): ",
5353
paste(missing_ann, collapse = ", "), ".")
5454
}
55+
ann[, score := suppressWarnings(as.numeric(score))]
56+
if (anyNA(ann$score)) {
57+
stop("mzmine_annotations$score must be numeric (or coercible to numeric).")
58+
}
5559
data.table::setorder(ann, id, -score)
5660
ann_top <- unique(ann, by = "id")
5761
matched <- ann_top[match(mz_input[[id_col]], ann_top[["id"]]),

R/converters_MZMinetoMSstatsFormat.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
#' `row retention time`, and per-sample peak-area columns named
77
#' `"<run> Peak area"` (e.g. `"sampleA.mzML Peak area"`).
88
#' @param annotation `data.frame` with columns `Run`, `Condition`,
9-
#' `BioReplicate`. `Run` values must match the sample column names with the
10-
#' trailing `" Peak area"` stripped.
9+
#' `BioReplicate`. `Run` values must match MSstatsConvert-standardized sample
10+
#' names (after column-name normalization removes spaces and dots) with the
11+
#' trailing `"Peakarea"` suffix removed. For example, a quant-file column
12+
#' `"sampleA.mzML Peak area"` becomes `"sampleAmzML"` after standardization,
13+
#' so the corresponding `Run` value must be `sampleAmzML`.
1114
#' @param mzmine_annotations optional `data.frame` of MZMine spectral-library
1215
#' annotations with columns `id`, `compound_name`, `score`. When supplied,
1316
#' the highest-scoring `compound_name` per feature is used as `ProteinName`;
@@ -52,7 +55,7 @@ MZMinetoMSstatsFormat = function(
5255
log_file_path)
5356

5457
input = MSstatsConvert::MSstatsImport(list(input = input),
55-
"MSstats", "MZMine")
58+
"MSstats", "MZMine", ...)
5659
input = MSstatsConvert::MSstatsClean(
5760
input, mzmine_annotations = mzmine_annotations)
5861
annotation = MSstatsConvert::MSstatsMakeAnnotation(input, annotation)

inst/tinytest/test_converters_MZMinetoMSstatsFormat.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ expect_equal(ncol(output_nolib), 11)
9797
expect_equal(nrow(output_nolib), 24)
9898
expected_mz_rt = c("123.056_1.23", "245.129_3.45", "367.201_5.67",
9999
"489.334_7.89", "555.447_9.1", "123.056_1.45")
100-
expect_true(all(as.character(output_nolib_dt$ProteinName) %in% expected_mz_rt))
100+
expect_equal(
101+
sort(unique(as.character(output_nolib_dt$ProteinName))),
102+
sort(expected_mz_rt)
103+
)
101104
# Compound names from the library must not leak in
102105
expect_false(any(as.character(output_nolib_dt$ProteinName) %in%
103106
c("Caffeine", "GlucoseHigh", "GlucoseLow", "Lactate")))

man/MZMinetoMSstatsFormat.Rd

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)