Browse code

updates with suggestions of jorainer and lgatto

Mar Garcia Aloy authored on 23/05/2023 13:40:26
Showing 3 changed files

... ...
@@ -1,6 +1,6 @@
1 1
 Package: MsCoreUtils
2 2
 Title: Core Utils for Mass Spectrometry Data
3
-Version: 1.11.6
3
+Version: 1.11.7
4 4
 Description: MsCoreUtils defines low-level functions for mass
5 5
     spectrometry data and is independent of any high-level data
6 6
     structures. These functions include mass spectra processing
... ...
@@ -38,6 +38,10 @@ Authors@R: c(person(given = "RforMassSpectrometry Package Maintainer",
38 38
              person(given = "Roger", family = "Gine Bertomeu",
39 39
                     email = "roger.gine@iispv.cat",
40 40
                     comment = c(ORCID = "0000-0003-0288-9619"),
41
+                    role = "ctb")),
42
+             person(given = "Mar", family = "Garcia-Aloy",
43
+                    email = "mar.garcia@fmach.it",
44
+                    comment = c(ORCID = "0000-0002-1330-6610"),
41 45
                     role = "ctb"))
42 46
 Depends:
43 47
     R (>= 3.6.0)
... ...
@@ -1,5 +1,9 @@
1 1
 # MsCoreUtils 1.11
2 2
 
3
+## MsCoreUtils 1.11.7
4
+
5
+- Add functions `entropy` and `nentropy`.
6
+  
3 7
 ## MsCoreUtils 1.11.6
4 8
 
5 9
 - Fix bug in `impute_MinDet(MARGIN = 1)` and add unit test.
... ...
@@ -2,11 +2,19 @@
2 2
 #'
3 3
 #' @description
4 4
 #'
5
-#' These functions allows to calculate entropy measurements of an MS/MS  
5
+#' These functions allow to calculate entropy measurements of an MS/MS  
6 6
 #' spectrum based on the metrics suggested by 
7 7
 #' Li et al. (https://doi.org/10.1038/s41592-021-01331-z).
8
+#' Spectral entropy and normalized entropy are used to measure the complexity 
9
+#' of an spectra.
10
+#' MassBank of North America (MoNA) defines spectra entropy as the intensity 
11
+#' weighted spectral peak number 
12
+#' (https://mona.fiehnlab.ucdavis.edu/documentation/entropy. 
13
+#' Additionally it is suggested to label as low-quality spectrums the ones 
14
+#' that have a normalized entropy higher than 0.8 and spectral entropy 
15
+#' higher than 3. 
8 16
 #'
9
-#' @param x `numeric`, intensities of the fragment ions value(s).
17
+#' @param x `numeric`, intensities of the fragment ions(s).
10 18
 #'
11 19
 #' @return `numeric`: (normalized) entropy `x`.
12 20
 #'
... ...
@@ -26,15 +34,14 @@
26 34
 #' @examples
27 35
 #' spectrum <- rbind(c(41.04, 37.16), c(69.07, 66.83), c(86.1, 999.0))
28 36
 #'
29
-#' entropy_spectral(spectrum[,2])
30
-#' entropy_normalized(spectrum[,2])
37
+#' entropy(spectrum[,2])
38
+#' nentropy(spectrum[,2])
31 39
 #' 
32
-entropy_spectral <- function(x){
40
+entropy <- function(x) {
33 41
   y <- x / sum(x)
34
-  z <- y*log(y)
35
-  return(-sum(z))
42
+  -sum(y * log(y))
36 43
 }
37 44
 
38
-entropy_normalized <- function(x){
39
-  entropy_spectral(x) / log(length(x))
45
+nentropy <- function(x) {
46
+  entropy(x) / log(length(x))
40 47
 }
41 48
\ No newline at end of file