Ejemplo n.º 1
0
 def test_sum_relative_intensity(self):
     z = np.array([100, 200, 300])
     correct = np.array([100 / 600, 200 / 600, 300 / 600])
     res = normalise_intensity(z)
     self.assertIsNone(
         np.testing.assert_array_equal(np.round(res, 3),
                                       np.round(correct, 3)))
Ejemplo n.º 2
0
 def test_max_relative_intensity(self):
     z = np.array([100, 200, 300])
     correct = np.array([100 / 300, 200 / 300, 300 / 300])
     res = normalise_intensity(z, norm_method='max')
     self.assertIsNone(
         np.testing.assert_array_equal(np.round(res, 3),
                                       np.round(correct, 3)))
Ejemplo n.º 3
0
 def test_normalise_ordination(self):
     x = [
         'C13H14O5', 'C13H14N2O4S2', 'C36H45ClN6O12', 'C9H11NO2',
         'C9H11NO3', 'C11H12N2O2', 'C5H7NO3', 'C5H9NO3', 'C6H12N2O4S2',
         'C6H11NO3S'
     ]
     x2 = [
         'C13H14O5', 'C13H14N2O4S2', 'C36H45ClN6O12', 'C9H11NO2',
         'C9H31NO3', 'C11H12N1O2', 'C5H73O3', 'C5H9NO3', 'C6H12N2O4S2',
         'C6H11NO3S'
     ]
     z = np.array(
         [1000, 2432, 3000, 4201, 2000, 5990, 1000, 6520, 8000, 9001])
     z2 = np.array(
         [1000, 2432, 3000, 4201, 2000, 5990, 1000, 6520, 8000, 9001])
     ores = ordination_matrix(molecular_formulas=[x, x2],
                              peak_intensities=[z, z2])
     n1res = normalise_intensity(ores)
     n2res = normalise_intensity(ores,
                                 norm_subset='PPP',
                                 norm_method='binary')
     n3res = normalise_intensity(ores,
                                 norm_subset='LOS',
                                 p_L=3,
                                 norm_method='minmax')
     n4res = normalise_intensity(ores,
                                 norm_subset='PPP',
                                 p_P=0.73,
                                 norm_method='zscore')
     n5res = normalise_intensity(ores,
                                 norm_subset='PPP',
                                 p_P=0.02,
                                 norm_method='mean')
     n6res = normalise_intensity(ores,
                                 norm_subset='LOS',
                                 p_P=0.02,
                                 norm_method='mean',
                                 p_L=1000)
     n7res = normalise_intensity(ores,
                                 norm_subset='LOS',
                                 p_P=0.02,
                                 norm_method='mean',
                                 p_L=1000,
                                 log=True)
     n8res = normalise_intensity(ores,
                                 norm_subset='ALL',
                                 p_P=0.02,
                                 norm_method='none',
                                 p_L=1000,
                                 log=True)
Ejemplo n.º 4
0
 def test_binary_relative_intensity(self):
     z = np.array([100, 0, 300, 400, 21, 321, 0, 543])
     res = normalise_intensity(z, norm_method='binary')
     self.assertEqual(sum(res), 6)
Ejemplo n.º 5
0
 def test_median_relative_intensity(self):
     z = np.array([100, 200, 300, 400, 21, 321, 342, 543])
     res = normalise_intensity(z, norm_method='median')
     self.assertEqual(np.round(np.median(res), 3), 0.00)
Ejemplo n.º 6
0
 def test_minmax_relative_intensity(self):
     z = np.array([100, 200, 300, 400, 21, 321, 342, 543])
     res = normalise_intensity(z, norm_method='minmax')
     self.assertEqual(min(res), 0)
     self.assertEqual(max(res), 1)
Ejemplo n.º 7
0
 def test_zscore_relative_intensity(self):
     z = np.array([100, 200, 300, 400, 21, 321, 342, 543])
     res = normalise_intensity(z, norm_method='zscore')
     self.assertEqual(np.round(np.mean(res), 3), 0.00)
     self.assertEqual(np.round(np.std(res), 3), 1.00)
Ejemplo n.º 8
0
 def test_unit_relative_intensity(self):
     z = np.array([100, 200, 300])
     res = normalise_intensity(z, norm_method='unit_vector')
     self.assertEqual(np.round(sum(res**2), 3), 1.00)