diff NmrNormalization_script.R @ 6:221cbd549c40 draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 4bbd4d65e954192aff1a4d210001deb625667136
author workflow4metabolomics
date Tue, 30 Jul 2019 09:43:57 -0400
parents 966fcf7ae66e
children
line wrap: on
line diff
--- a/NmrNormalization_script.R	Tue Oct 02 12:14:47 2018 -0400
+++ b/NmrNormalization_script.R	Tue Jul 30 09:43:57 2019 -0400
@@ -96,12 +96,22 @@
     # Recuperation spectres individus controle
     control.spectra <- data.normalized[,sampleMetadata[,pqnFactor]==nomControl]
     spectrum.ref <- apply(control.spectra,1,median)
+    for (j in 1:length(spectrum.ref))
+    {
+      if (spectrum.ref[j] == 0)
+        spectrum.ref[j] <- mean(control.spectra[j, ])
+      if (spectrum.ref[j] == 0)
+        spectrum.ref[j] <- 10^(-24)
+    }
 
     # Ratio between normalized and reference spectra
     data.normalized.ref <- data.normalized/spectrum.ref
 
     # Median ratio
     data.normalized.ref.median <- apply(data.normalized.ref,1,median)
+    for (j in 1:length(data.normalized.ref.median))
+      if (data.normalized.ref.median[j] == 0 | is.na(data.normalized.ref.median[j]) | data.normalized.ref.median == "NaN" | data.normalized.ref.median == "NA")
+        data.normalized.ref.median[j] <- mean(data.normalized.ref[j, ])
 
     # Normalization
     data.normalizedPQN <- data.normalized[,1]/data.normalized.ref.median
@@ -145,3 +155,4 @@
   return(list(NormalizedBucketedSpectra))
 
 }
+