comparison 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
comparison
equal deleted inserted replaced
5:3d00a98974b7 6:221cbd549c40
94 94
95 # Reference spectrum 95 # Reference spectrum
96 # Recuperation spectres individus controle 96 # Recuperation spectres individus controle
97 control.spectra <- data.normalized[,sampleMetadata[,pqnFactor]==nomControl] 97 control.spectra <- data.normalized[,sampleMetadata[,pqnFactor]==nomControl]
98 spectrum.ref <- apply(control.spectra,1,median) 98 spectrum.ref <- apply(control.spectra,1,median)
99 for (j in 1:length(spectrum.ref))
100 {
101 if (spectrum.ref[j] == 0)
102 spectrum.ref[j] <- mean(control.spectra[j, ])
103 if (spectrum.ref[j] == 0)
104 spectrum.ref[j] <- 10^(-24)
105 }
99 106
100 # Ratio between normalized and reference spectra 107 # Ratio between normalized and reference spectra
101 data.normalized.ref <- data.normalized/spectrum.ref 108 data.normalized.ref <- data.normalized/spectrum.ref
102 109
103 # Median ratio 110 # Median ratio
104 data.normalized.ref.median <- apply(data.normalized.ref,1,median) 111 data.normalized.ref.median <- apply(data.normalized.ref,1,median)
112 for (j in 1:length(data.normalized.ref.median))
113 if (data.normalized.ref.median[j] == 0 | is.na(data.normalized.ref.median[j]) | data.normalized.ref.median == "NaN" | data.normalized.ref.median == "NA")
114 data.normalized.ref.median[j] <- mean(data.normalized.ref[j, ])
105 115
106 # Normalization 116 # Normalization
107 data.normalizedPQN <- data.normalized[,1]/data.normalized.ref.median 117 data.normalizedPQN <- data.normalized[,1]/data.normalized.ref.median
108 for (i in 2:ncol(data)) 118 for (i in 2:ncol(data))
109 data.normalizedPQN <- cbind(data.normalizedPQN,data.normalized[,i]/data.normalized.ref.median) 119 data.normalizedPQN <- cbind(data.normalizedPQN,data.normalized[,i]/data.normalized.ref.median)
143 153
144 ## OUTPUTS 154 ## OUTPUTS
145 return(list(NormalizedBucketedSpectra)) 155 return(list(NormalizedBucketedSpectra))
146 156
147 } 157 }
158