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.
- {masscube-1.2.1 → masscube-1.2.2}/PKG-INFO +1 -1
- {masscube-1.2.1 → masscube-1.2.2}/pyproject.toml +1 -1
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/alignment.py +2 -1
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/annotation.py +3 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/feature_detection.py +8 -4
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/params.py +1 -6
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/raw_data_utils.py +4 -1
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/utils_functions.py +1 -1
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/PKG-INFO +1 -1
- {masscube-1.2.1 → masscube-1.2.2}/LICENSE +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/README.md +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/setup.cfg +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/__init__.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/classifier_builder.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/feature_evaluation.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/feature_grouping.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/mzpkl.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/network.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/normalization.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/stats.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/visualization.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube/workflows.py +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/SOURCES.txt +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/dependency_links.txt +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/entry_points.txt +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/requires.txt +0 -0
- {masscube-1.2.1 → masscube-1.2.2}/src/masscube.egg-info/top_level.txt +0 -0
|
@@ -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[
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
305
|
-
|
|
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 = [
|
|
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 =
|
|
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({'
|
|
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
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|