Browse code

Merge pull request #265 from jorainer/master

feat: pwiz returns peak matrices with column names

Steffen Neumann authored on 20/03/2022 18:20:40 • GitHub committed on 20/03/2022 18:20:40
Showing4 changed files

... ...
@@ -2,7 +2,7 @@ Package: mzR
2 2
 Type: Package
3 3
 Title: parser for netCDF, mzXML, mzData and mzML and mzIdentML files
4 4
        (mass spectrometry data)
5
-Version: 2.29.4
5
+Version: 2.29.5
6 6
 Author: Bernd Fischer, Steffen Neumann, Laurent Gatto, Qiang Kou, Johannes Rainer
7 7
 Authors@R: c(
8 8
     person("Steffen", "Neumann", email="sneumann@ipb-halle.de", role=c("aut","cre")),
... ...
@@ -1,3 +1,7 @@
1
+CHANGES IN VERSION 2.27.5
2
+-------------------------
3
+ o `peaks` method for pwiz backend sets colnames on returned matrices.
4
+
1 5
 CHANGES IN VERSION 2.29.4
2 6
 -------------------------
3 7
  o Re-apply fix for compile error on clang by Kurt Hornik, closes #263
... ...
@@ -11,6 +11,7 @@ test_mzXML <- function() {
11 11
     checkTrue(is.matrix(peaks(mzxml,1)))
12 12
     pks <- peaks(mzxml, 2:3)
13 13
     checkTrue(length(pks) == 2)
14
+    checkEquals(colnames(pks[[1L]]), c("mz", "intensity"))
14 15
     peaksCount(mzxml)
15 16
     hdr <- header(mzxml)
16 17
     checkTrue(any(colnames(hdr) == "spectrumId"))
... ...
@@ -39,6 +40,7 @@ test_mzML <- function() {
39 40
     pks <- peaks(mzml)
40 41
     pks <- peaks(mzml,1)
41 42
     pks <- peaks(mzml,2:3)
43
+    checkEquals(colnames(pks[[1L]]), c("mz", "intensity"))
42 44
     peaksCount(mzml)
43 45
     hdr <- header(mzml)
44 46
     checkTrue(any(colnames(hdr) == "spectrumId"))
... ...
@@ -401,6 +401,7 @@ Rcpp::List RcppPwiz::getPeakList(Rcpp::IntegerVector whichScan) {
401 401
     std::vector<double> data;
402 402
     Rcpp::NumericVector data_matrix;
403 403
     Rcpp::List res(n_want);
404
+    Rcpp::CharacterVector cn = Rcpp::CharacterVector::create("mz", "intensity");
404 405
     for (size_t i = 0; i < n_want; i++) {
405 406
       current_scan = whichScan[i];
406 407
       if (current_scan < 1 || current_scan > n_scans) {
... ...
@@ -414,6 +415,7 @@ Rcpp::List RcppPwiz::getPeakList(Rcpp::IntegerVector whichScan) {
414 415
       ints = sp->getIntensityArray();
415 416
       if (!mzs.get() || !ints.get()) {
416 417
 	Rcpp::NumericMatrix pks(0, 2);
418
+	Rcpp::colnames(pks) = cn;
417 419
 	res[i] = pks;
418 420
 	continue;
419 421
       }
... ...
@@ -423,6 +425,7 @@ Rcpp::List RcppPwiz::getPeakList(Rcpp::IntegerVector whichScan) {
423 425
       data.insert(data.end(), ints->data.begin(), ints->data.end());
424 426
       data_matrix = Rcpp::wrap(data);
425 427
       data_matrix.attr("dim") = Rcpp::Dimension(ints->data.size(), 2);
428
+      Rcpp::colnames(data_matrix) = cn;
426 429
       res[i] = data_matrix;
427 430
     }
428 431
     return res;