masscube 1.2.1__tar.gz → 1.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {masscube-1.2.1 → masscube-1.2.2}/PKG-INFO +1 -1
  2. {masscube-1.2.1 → masscube-1.2.2}/pyproject.toml +1 -1
  3. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/alignment.py +2 -1
  4. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/annotation.py +3 -0
  5. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/feature_detection.py +8 -4
  6. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/params.py +1 -6
  7. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/raw_data_utils.py +4 -1
  8. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/utils_functions.py +1 -1
  9. {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/PKG-INFO +1 -1
  10. {masscube-1.2.1 → masscube-1.2.2}/LICENSE +0 -0
  11. {masscube-1.2.1 → masscube-1.2.2}/README.md +0 -0
  12. {masscube-1.2.1 → masscube-1.2.2}/setup.cfg +0 -0
  13. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/__init__.py +0 -0
  14. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/classifier_builder.py +0 -0
  15. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/feature_evaluation.py +0 -0
  16. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/feature_grouping.py +0 -0
  17. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/mzpkl.py +0 -0
  18. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/network.py +0 -0
  19. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/normalization.py +0 -0
  20. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/stats.py +0 -0
  21. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/visualization.py +0 -0
  22. {masscube-1.2.1 → masscube-1.2.2}/src/masscube/workflows.py +0 -0
  23. {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/SOURCES.txt +0 -0
  24. {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/dependency_links.txt +0 -0
  25. {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/entry_points.txt +0 -0
  26. {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/requires.txt +0 -0
  27. {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: masscube
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: Accurate and fast data processing for metabolomics
5
5
  Author-email: Huaxu Yu <yhxchem@outlook.com>
6
6
  Maintainer-email: Huaxu Yu <yhxchem@outlook.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "masscube"
7
- version = "1.2.1"
7
+ version = "1.2.2"
8
8
  authors = [
9
9
  { name="Huaxu Yu", email="yhxchem@outlook.com" },
10
10
  ]
@@ -122,7 +122,8 @@ def feature_alignment(path: str, params: Params):
122
122
  # remove those files from names
123
123
  names = [names[i] for i in range(len(names)) if params.sample_names[i] not in not_found_files]
124
124
  # remove those files from sample metadata
125
- params.sample_metadata = params.sample_metadata[~params.sample_metadata['sample_name'].isin(not_found_files)]
125
+ params.sample_metadata = params.sample_metadata[~params.sample_metadata.iloc[:,1].isin(not_found_files)]
126
+ params.sample_names = list(params.sample_metadata.iloc[:, 0])
126
127
 
127
128
  # find anchors for retention time correction
128
129
  if params.correct_rt:
@@ -177,6 +177,9 @@ def load_ms2_db(path):
177
177
  elif ext.lower() == '.pkl':
178
178
  entropy_search = pickle.load(open(path, 'rb'))
179
179
  print("\tMS2 database has been loaded.")
180
+ # check if intensity_weight is an attribute
181
+ if not hasattr(entropy_search, 'intensity_weight'):
182
+ raise ValueError("Please new MS/MS database is required for MassCube ver. 1.2 or later. Please download from: https://zenodo.org/records/14991522.")
180
183
  return entropy_search
181
184
 
182
185
  elif ext.lower() == '.json':
@@ -267,7 +267,7 @@ def detect_features(d):
267
267
 
268
268
 
269
269
  def segment_feature(feature, sigma=1.2, prominence_ratio=0.05, distance=10, peak_height_tol=1000,
270
- length_tol=5, sse_tol=0.5):
270
+ length_tol=5, sse_tol=0.6):
271
271
  """
272
272
  Function to segment a feature into multiple features based on the edge detection.
273
273
 
@@ -297,15 +297,19 @@ def segment_feature(feature, sigma=1.2, prominence_ratio=0.05, distance=10, peak
297
297
  return [feature]
298
298
 
299
299
  # correction for peak with limited scan number
300
- if len(feature.signals) < 10:
300
+ peak_tmp = feature.signals[:,1]
301
+ if np.sum(peak_tmp > peak_height_tol) < 12:
301
302
  sigma = 0.5*sigma
302
303
  distance = 3
303
304
 
304
- ss = gaussian_filter1d(feature.signals[:,1], sigma=sigma)
305
- feature.sse = squared_error_to_smoothed_curve(original_signal=feature.signals[:,1], fit_signal=ss)
305
+ # add zero to the front and the end of the signal to facilitate the edge detection
306
+ peak_tmp = np.concatenate(([0], peak_tmp, [0]))
307
+ ss = gaussian_filter1d(peak_tmp, sigma=sigma)
308
+ feature.sse = squared_error_to_smoothed_curve(original_signal=peak_tmp, fit_signal=ss)
306
309
  if feature.sse > sse_tol:
307
310
  return [feature]
308
311
  peaks, _ = find_peaks(ss, prominence=np.max(ss)*prominence_ratio, distance=distance)
312
+ peaks = peaks - 1 # correct the index
309
313
 
310
314
  # the resulting peaks should have a height larger than peak_height_tol
311
315
  peaks = peaks[feature.signals[peaks,1] > peak_height_tol]
@@ -245,12 +245,7 @@ class Params:
245
245
  available_files = [f for f in os.listdir(self.sample_dir) if not f.startswith(".") and
246
246
  (f.lower().endswith(".mzml") or f.lower().endswith(".mzxml"))]
247
247
  # find the absolute paths of the raw MS data in order
248
- self.sample_abs_paths = [None] * len(self.sample_names)
249
- for i, name in enumerate(self.sample_names):
250
- for f in available_files:
251
- if name in f:
252
- self.sample_abs_paths[i] = os.path.join(self.sample_dir, f)
253
- break
248
+ self.sample_abs_paths = [os.path.join(self.sample_dir, f) for f in available_files]
254
249
  # find the start time of the raw MS data
255
250
  self.sample_metadata['time'] = [get_start_time(path) for path in self.sample_abs_paths]
256
251
  self.sample_metadata['analytical_order'] = 0
@@ -290,7 +290,10 @@ class MSData:
290
290
  Number of iterations to segment features.
291
291
  """
292
292
 
293
- distance = int(0.05/np.mean(np.diff(self.ms1_time_arr)))
293
+ distance = 0.05/np.mean(np.diff(self.ms1_time_arr))
294
+
295
+ if distance < 1:
296
+ distance = 1
294
297
 
295
298
  for _ in range(iteration):
296
299
  self.features = [segment_feature(feature, peak_height_tol=self.params.ms1_abs_int_tol*3, distance=distance) for feature in self.features]
@@ -50,7 +50,7 @@ def generate_sample_table(path=None, output=True):
50
50
  file_names = [os.path.splitext(f)[0] for f in os.listdir(path_data) if f.lower().endswith('.mzml') or f.lower().endswith('.mzxml')]
51
51
  file_names = [f for f in file_names if not f.startswith(".")] # for Mac OS
52
52
  file_names = sorted(file_names)
53
- sample_table = pd.DataFrame({'Sample': file_names, "is_qc": [None]*len(file_names), "is_blank": [None]*len(file_names)})
53
+ sample_table = pd.DataFrame({'sample_name': file_names, "is_qc": [None]*len(file_names), "is_blank": [None]*len(file_names)})
54
54
  else:
55
55
  raise FileNotFoundError(f"The path {path_data} does not exist.")
56
56
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: masscube
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: Accurate and fast data processing for metabolomics
5
5
  Author-email: Huaxu Yu <yhxchem@outlook.com>
6
6
  Maintainer-email: Huaxu Yu <yhxchem@outlook.com>
File without changes
File without changes
File without changes
File without changes
File without changes