Mass spectrometry gas source analysis method and system based on k-means clustering algorithm
The mass spectrometry gas source analysis method using K-means clustering algorithm solves the problems of baseline drift and noise interference in mass spectrometry data, and achieves accurate extraction and classification of features of multiple pollution sources, ensuring the accuracy and stability of data analysis.
Patent Information
- Application Number
- CN202511460517.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-14
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-10-14
AI Technical Summary
Existing mass spectrometry data suffers from problems such as baseline drift, instrument noise, and signal interference in pollution source analysis, resulting in insufficient accuracy and reliability of data analysis and making it difficult to accurately extract and classify the characteristics of various pollution sources from complex mass spectrometry data.
A mass spectrometry gas source analysis method based on K-means clustering algorithm is adopted, including data preprocessing, feature engineering optimization, clustering algorithm processing and pollution source fingerprint matching. Pollution source matching is performed by baseline correction, noise filtering, peak alignment, coefficient of variation screening and weighted principal component analysis, combined with an improved cosine similarity algorithm.
It effectively eliminates baseline drift and noise interference, ensures signal accuracy, solves the time offset problem between different samples, preserves the key features of mass spectrometry signals, and achieves accuracy and stability of clustering results through adaptive K-means clustering.
Smart Images

Figure CN120929865B_ABST
Abstract
Description
Technical Field
[0001] This disclosure belongs to the field of mass spectrometry data analysis technology, and specifically relates to a method and system for mass spectrometry gas source analysis based on K-means clustering algorithm. Background Technology
[0002] Mass spectrometry (MS) is widely used in chemical analysis, environmental monitoring, and biomarker identification, playing a particularly important role in pollution source analysis and environmental monitoring. Mass spectrometry analysis helps researchers identify the types and concentrations of molecules in a sample by measuring the mass-to-charge ratio (m / z) of ions and the corresponding signal intensity. However, raw mass spectrometry data often contains various interfering factors, such as baseline drift, instrument noise, and inter-signal interference. These factors can distort the data, thus affecting the accuracy and reliability of the analysis.
[0003] When conducting pollution source analysis, especially when it is necessary to match and identify the characteristics of multiple pollution sources, accurately extracting useful features from complex mass spectrometry data and effectively classifying them has become a core technical challenge. Summary of the Invention
[0004] To address the aforementioned problems, this disclosure provides a method for mass spectrometry gas source analysis based on the K-means clustering algorithm, the method comprising:
[0005] The raw mass spectrometry time series data were acquired and preprocessed to obtain the normalized mass spectrometry matrix;
[0006] The feature engineering optimization of the standardized mass spectrometry matrix yields a low-dimensional feature space matrix.
[0007] The low-dimensional feature space matrix is processed by a clustering algorithm to obtain cluster label vectors and centroid feature vectors;
[0008] Based on a pollution source database, pollution source fingerprint matching and analysis are performed using cluster label vectors and centroid feature vectors. This includes: employing an improved cosine similarity algorithm to calculate the cluster label vectors and centroid feature vectors, obtaining the similarity between the cluster centroids and each pollution source in the pollution source database; setting a similarity threshold and constructing a matching matrix based on the threshold; and calculating the contribution of each pollution source based on the matching matrix. The similarity calculation includes: ;in, , represents the eigenvector of the cluster centroid, where It is the signal intensity of the cluster centroid at the t-th m / z peak; This represents the feature vector of a pollution source in the pollution source feature database, where It represents the signal intensity of the pollution source at the t m / z peaks; k represents the dimension of the eigenvector, i.e., the number of m / z peaks; This represents the weight of t m / z peaks; the calculation of the contribution includes: ;in, The elements in the matching matrix indicate whether cluster i and pollution source j match; This represents the number of samples in cluster i; This represents the similarity between cluster i and pollution source j.
[0009] According to some embodiments of this disclosure, the raw mass spectrometry time-series data is preprocessed, including: performing baseline correction, noise filtering, and peak alignment sequentially on the raw mass spectrometry time-series data;
[0010] The raw mass spectrometry time-series data includes the mass-to-charge ratio (m / z), signal intensity, and timestamp.
[0011] According to some embodiments of this disclosure, baseline correction is performed on raw mass spectrometry time-series data, including:
[0012] The original mass spectrometry time-series data are traversed, and the baseline is fitted using the least squares method to obtain the objective function;
[0013] Minimize the objective function and obtain the target baseline through a numerical optimization algorithm;
[0014] The original mass spectrometry time series data were baseline corrected using the target baseline to obtain the first signal.
[0015] According to some embodiments of this disclosure, the objective function is:
[0016] ;
[0017] in, Indicates the smoothing parameter; This represents the weight at each time point; The second derivative of the baseline is represented by , and the rate of change of the baseline is represented by . This represents the signal after correction at time point i.
[0018] According to some embodiments of this disclosure, noise filtering is performed on the first signal, including:
[0019] Set the window range;
[0020] By using a filter and combining it with a window range, the target signal is smoothed to obtain the second signal.
[0021] According to some embodiments of this disclosure, setting a window range includes:
[0022] The first signal is subjected to a Fourier transform to obtain the observed frequency spectrum;
[0023] Predict noise frequency based on observed frequency spectrum;
[0024] The peak width is determined based on the first signal;
[0025] The window range is determined by weighting the noise frequency and peak width.
[0026] According to some embodiments of this disclosure, determining the window range by weighting noise frequency and peak width includes:
[0027] ;
[0028] in, Indicates the weighting coefficient; and This represents a constant chosen based on actual circumstances; Indicates peak width; M represents the noise frequency; M represents the window range.
[0029] According to some embodiments of this disclosure, a second signal is obtained by smoothing the target signal using a filter and combining it with a window range, including:
[0030] ;
[0031] in, This represents the filtered signal value, i.e., the second signal; t represents the timestamp. The weight coefficients are calculated by polynomial fitting and depend on the window range M and the order of the polynomial; N represents the normalization constant. Indicates the corrected number One signal.
[0032] According to some embodiments of this disclosure, peak alignment of the second signal includes:
[0033] The m / z value corresponding to the second signal is divided into a reference sample and a sample to be aligned.
[0034] The distance matrix between the m / z values of the sample to be aligned and the m / z values of the reference sample is calculated using the dynamic time warping algorithm.
[0035] The target alignment path is determined using dynamic programming recursion.
[0036] The m / z values of the samples to be aligned are adjusted using the target alignment path to obtain the normalized mass spectrometry matrix.
[0037] According to some embodiments of this disclosure, the dynamic programming recursive method is as follows:
[0038] ;
[0039] in, This represents the minimum alignment distance between the i-th m / z of sample 1 and the j-th m / z of sample 2; This represents the distance metric used to calculate the deviation of the m / z value, specifically using Euclidean distance.
[0040] According to some embodiments of this disclosure, the feature engineering optimization of the standardized mass spectrometry matrix yields a low-dimensional feature space matrix, including:
[0041] Determine the coefficient of variation;
[0042] Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix;
[0043] Assign weights to the variant m / z peaks in the first matrix;
[0044] Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
[0045] According to some embodiments of this disclosure, the coefficient of variation is determined, including:
[0046] ;
[0047] in, This represents the standard deviation of the i-th m / z peak; This represents the mean of the i-th m / z peak; This represents the coefficient of variation of the i-th m / z peak.
[0048] According to some embodiments of this disclosure, weights are assigned to the varied m / z peaks in the first matrix, including:
[0049] ;
[0050] in, This represents the weight of feature i.
[0051] According to some embodiments of this disclosure, based on weights, the dimension of the first matrix is compressed to obtain a low-dimensional feature space matrix, including:
[0052] Construct a weighted covariance matrix based on the weights;
[0053] The eigenvalues and eigenvectors of the weighted covariance matrix are determined by the weighted covariance matrix.
[0054] The eigenvalues and eigenvectors are traversed, sorted, and projected to determine the low-dimensional feature space matrix.
[0055] According to some embodiments of this disclosure, the weighted covariance matrix is:
[0056] ;
[0057] in, This represents the weighted covariance matrix with dimension n. n (i.e., the characteristic number) (Eigenvalues); X is the weighted mass spectrum matrix with dimension m. n (i.e., the number of samples) (Number of features); W represents the diagonal weight matrix with dimension n. n, whose diagonal elements are the weights of each feature. ;therefore .
[0058] According to some embodiments of this disclosure, determining the eigenvalues and eigenvectors of a weighted covariance matrix using the weighted covariance matrix includes:
[0059] ;
[0060] in, Represents eigenvalues; This represents the corresponding feature vector.
[0061] According to some embodiments of this disclosure, a clustering algorithm is used to process the low-dimensional feature space matrix to obtain cluster label vectors and centroid feature vectors, including:
[0062] The k-means++ algorithm is used to select multiple centroids for the low-dimensional feature space matrix;
[0063] The target number of clusters is determined by the silhouette coefficient;
[0064] The k-means++ algorithm is used to iteratively calculate the data using weighted Euclidean distance as the metric until the change in centroid is less than a set threshold, thus obtaining the cluster label vector and the centroid feature vector.
[0065] According to some embodiments of this disclosure, the k-means++ algorithm is used to select multiple centroids for the low-dimensional feature space matrix, including:
[0066] Randomly select a data point in the low-dimensional feature space matrix as the first centroid, and repeat the following steps iteratively;
[0067] Calculate the distance from the remaining data points to the first centroid;
[0068] The second centroid is selected using a distance-weighted method.
[0069] The iteration stops when the number of selected centroids reaches the threshold.
[0070] This disclosure also provides a mass spectrometry gas source apportionment system based on the K-means clustering algorithm, the system comprising:
[0071] The preprocessing module is used to acquire and preprocess the raw mass spectrometry time-series data to obtain a normalized mass spectrometry matrix;
[0072] The optimization module is used to optimize the feature engineering of the standardized mass spectrometry matrix to obtain a low-dimensional feature space matrix;
[0073] The clustering module is used to process the low-dimensional feature space matrix through clustering algorithms to obtain cluster label vectors and centroid feature vectors;
[0074] The matching module is used to perform pollution source fingerprint matching and analysis based on a pollution source database using cluster label vectors and centroid feature vectors. This includes: employing an improved cosine similarity algorithm to calculate the cluster label vectors and centroid feature vectors, obtaining the similarity between the cluster centroids and each pollution source in the pollution source database; setting a similarity threshold and constructing a matching matrix based on the similarity threshold; and calculating the contribution of each pollution source based on the matching matrix. The similarity calculation includes: ;in, , represents the eigenvector of the cluster centroid, where It is the signal intensity of the cluster centroid at the t-th m / z peak; This represents the feature vector of a pollution source in the pollution source feature database, where It represents the signal intensity of the pollution source at the t m / z peaks; k represents the dimension of the eigenvector, i.e., the number of m / z peaks; This represents the weight of t m / z peaks; the calculation of the contribution includes: ;in, The elements in the matching matrix indicate whether cluster i and pollution source j match; This represents the number of samples in cluster i; This represents the similarity between cluster i and pollution source j.
[0075] According to some embodiments of this disclosure, an optimization module is used to optimize the feature engineering of a normalized mass spectrometry matrix to obtain a low-dimensional feature space matrix, including:
[0076] The optimization module is used to determine the coefficient of variation;
[0077] Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix;
[0078] Assign weights to the variant m / z peaks in the first matrix;
[0079] Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
[0080] According to some embodiments of this disclosure, a clustering module is used to process a low-dimensional feature space matrix using a clustering algorithm to obtain cluster label vectors and centroid feature vectors, including:
[0081] The clustering module is used to select multiple centroids by applying the k-means++ algorithm to the low-dimensional feature space matrix;
[0082] The target number of clusters is determined by the silhouette coefficient;
[0083] The k-means++ algorithm is used to iteratively calculate the data using weighted Euclidean distance as the metric until the change in centroid is less than a set threshold, thus obtaining the cluster label vector and the centroid feature vector.
[0084] This disclosure has the following beneficial effects:
[0085] This disclosure employs asymmetric least squares for baseline correction, eliminating baseline drift and background noise interference to ensure signal accuracy. A Savitzky-Golay filter smooths the data, removing high-frequency noise and preserving key features of the mass spectrometry signal. Dynamic time warping is used for peak alignment, resolving time shift issues between different samples and ensuring correct feature peak alignment. Features with high variability are selected using the coefficient of variation (CV), and dimensionality reduction is performed using weighted principal component analysis (WPCA), preserving the most informative features and reducing data dimensionality. Finally, an adaptive K-means clustering algorithm with initial centroid optimization is used, employing weighted Euclidean distance to measure sample similarity, ensuring the accuracy and stability of the clustering results.
[0086] Other features and advantages of this disclosure will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the disclosure. The objects and other advantages of this disclosure may be realized and obtained by means of the structures pointed out in the description and the accompanying drawings. Attached Figure Description
[0087] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0088] Figure 1 This diagram illustrates the mass spectrometry gas source analysis method based on the K-means clustering algorithm in this embodiment of the present disclosure.
[0089] Figure 2 This invention discloses a detailed flowchart of the mass spectrometry gas source analysis method in an embodiment of the present invention.
[0090] Figure 3A diagram of a mass spectrometry gas source analysis system based on the K-means clustering algorithm is shown in an embodiment of this disclosure. Detailed Implementation
[0091] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0092] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware units or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0093] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0094] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein.
[0095] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or device that includes a series of steps or sub-modules is not necessarily limited to those steps or sub-modules that are explicitly listed, but may include other steps or sub-modules that are not explicitly listed or that are inherent to such process, method, product, or device.
[0096] This invention provides a mass spectrometry gas source analysis method based on the K-means clustering algorithm, which solves the technical problem of how to accurately extract useful features from complex mass spectrometry data and effectively classify them when matching and identifying the features of multiple pollution sources.
[0097] like Figure 1 As shown, this disclosure provides a method for mass spectrometry gas source analysis based on the K-means clustering algorithm, the method comprising:
[0098] The raw mass spectrometry time series data were acquired and preprocessed to obtain the normalized mass spectrometry matrix;
[0099] The feature engineering optimization of the standardized mass spectrometry matrix yields a low-dimensional feature space matrix.
[0100] The low-dimensional feature space matrix is processed by a clustering algorithm to obtain cluster label vectors and centroid feature vectors;
[0101] Based on the pollution source database, pollution source fingerprint matching and analysis are performed by clustering label vectors and centroid feature vectors.
[0102] Specifically, the raw mass spectrometry time-series data is preprocessed, including: performing baseline correction, noise filtering, and peak alignment sequentially on the raw mass spectrometry time-series data;
[0103] The raw mass spectrometry time-series data includes the mass-to-charge ratio (m / z), signal intensity, and timestamp.
[0104] Specifically, baseline correction is performed on the raw mass spectrometry time-series data, including:
[0105] The original mass spectrometry time-series data are traversed, and the baseline is fitted using the least squares method to obtain the objective function;
[0106] Minimize the objective function and obtain the target baseline through a numerical optimization algorithm;
[0107] The original mass spectrometry time series data were baseline corrected using the target baseline to obtain the first signal.
[0108] Specifically, the objective function is:
[0109] ;
[0110] in, Indicates the smoothing parameter; This represents the weight at each time point; The second derivative of the baseline is represented by , and the rate of change of the baseline is represented by . This represents the signal after correction at time point i.
[0111] Specifically, noise filtering of the first signal includes:
[0112] Set the window range;
[0113] By using a filter and combining it with a window range, the target signal is smoothed to obtain the second signal.
[0114] Specifically, setting the window range includes:
[0115] The first signal is subjected to a Fourier transform to obtain the observed frequency spectrum;
[0116] Predict noise frequency based on observed frequency spectrum;
[0117] The peak width is determined based on the first signal;
[0118] The window range is determined by weighting the noise frequency and peak width.
[0119] Specifically, the window range is determined by weighting the noise frequency and peak width, including:
[0120] ;
[0121] in, Indicates the weighting coefficient; and This represents a constant chosen based on actual circumstances; Indicates peak width; M represents the noise frequency; M represents the window range.
[0122] Specifically, the target signal is smoothed using a filter and a window range to obtain a second signal, including:
[0123] ;
[0124] in, This represents the filtered signal value, i.e., the second signal; t represents the timestamp. The weight coefficients are calculated by polynomial fitting and depend on the window range M and the order of the polynomial; N represents the normalization constant. Indicates the corrected number One signal.
[0125] Specifically, peak alignment of the second signal includes:
[0126] The m / z value corresponding to the second signal is divided into a reference sample and a sample to be aligned.
[0127] The distance matrix between the m / z values of the sample to be aligned and the m / z values of the reference sample is calculated using the dynamic time warping algorithm.
[0128] The target alignment path is determined using dynamic programming recursion.
[0129] The m / z values of the samples to be aligned are adjusted using the target alignment path to obtain the normalized mass spectrometry matrix.
[0130] Specifically, the dynamic programming recursive method is as follows:
[0131] ;
[0132] in, This represents the minimum alignment distance between the i-th m / z of sample 1 and the j-th m / z of sample 2; This represents the distance metric used to calculate the deviation of the m / z value, specifically using Euclidean distance.
[0133] Specifically, the feature engineering optimization of the standardized mass spectrometry matrix yields a low-dimensional feature space matrix, including:
[0134] Determine the coefficient of variation;
[0135] Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix;
[0136] Assign weights to the variant m / z peaks in the first matrix;
[0137] Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
[0138] Specifically, determining the coefficient of variation includes:
[0139] ;
[0140] in, This represents the standard deviation of the i-th m / z peak; This represents the mean of the i-th m / z peak; This represents the coefficient of variation of the i-th m / z peak.
[0141] Specifically, weights are assigned to the varied m / z peaks in the first matrix, including:
[0142] ;
[0143] in, This represents the weight of feature i.
[0144] Specifically, based on the weights, the dimension of the first matrix is compressed to obtain a low-dimensional feature space matrix, including:
[0145] Construct a weighted covariance matrix based on the weights;
[0146] The eigenvalues and eigenvectors of the weighted covariance matrix are determined by the weighted covariance matrix.
[0147] The eigenvalues and eigenvectors are traversed, sorted, and projected to determine the low-dimensional feature space matrix.
[0148] Specifically, the weighted covariance matrix is:
[0149] ;
[0150] in, This represents the weighted covariance matrix with dimension n. n (i.e., the characteristic number) (Eigenvalues); X is the weighted mass spectrum matrix with dimension m. n (i.e., the number of samples) (Number of features); W represents the diagonal weight matrix with dimension n. n, whose diagonal elements are the weights of each feature. ;therefore .
[0151] Specifically, the eigenvalues and eigenvectors of the weighted covariance matrix are determined through the weighted covariance matrix, including:
[0152] ;
[0153] in, Represents eigenvalues; This represents the corresponding feature vector.
[0154] Specifically, the low-dimensional feature space matrix is processed by a clustering algorithm to obtain cluster label vectors and centroid feature vectors, including:
[0155] The k-means++ algorithm is used to select multiple centroids for the low-dimensional feature space matrix;
[0156] The target number of clusters is determined by the silhouette coefficient;
[0157] The k-means++ algorithm is used to iteratively calculate the data using weighted Euclidean distance as the metric until the change in centroid is less than a set threshold, thus obtaining the cluster label vector and the centroid feature vector.
[0158] Specifically, the k-means++ algorithm is used to select multiple centroids for the low-dimensional feature space matrix, including:
[0159] Randomly select a data point in the low-dimensional feature space matrix as the first centroid, and repeat the following steps iteratively;
[0160] Calculate the distance from the remaining data points to the first centroid;
[0161] The second centroid is selected using a distance-weighted method.
[0162] The iteration stops when the number of selected centroids reaches the threshold.
[0163] Specifically, based on a pollution source database, pollution source fingerprint matching and analysis are performed using clustered label vectors and centroid feature vectors, including:
[0164] An improved cosine similarity algorithm is used to calculate the cluster label vector and centroid feature vector, and obtain the similarity between the cluster centroid and each pollution source in the pollution source database.
[0165] Set a similarity threshold and construct a matching matrix based on the similarity threshold;
[0166] The contribution of each pollution source is calculated based on the matching matrix.
[0167] Specifically, the similarity calculation includes:
[0168] ;
[0169] in, , represents the eigenvector of the cluster centroid, where It is the signal intensity of the cluster centroid at the t-th m / z peak; This represents the feature vector of a pollution source in the pollution source feature database, where It represents the signal intensity of the pollution source at the t m / z peaks; k represents the dimension of the eigenvector (i.e., the number of m / z peaks). This represents the weight of the t m / z peaks.
[0170] Specifically, the calculation of the contribution includes:
[0171] ;
[0172] in, The elements in the matching matrix indicate whether cluster i and pollution source j match; This represents the number of samples in cluster i; This represents the similarity between cluster i and pollution source j.
[0173] like Figure 2 As shown, the detailed technical content of this method is as follows:
[0174] Preprocessing of raw mass spectrometry time series data:
[0175] The raw mass spectrometry time series data are in CSV file format;
[0176] The raw mass spectrometry time series data includes the following:
[0177] m / z value: Represents the mass-to-charge ratio, which is the ratio of the mass to the charge of an ion in mass spectrometry analysis;
[0178] Signal intensity: The signal intensity related to the concentration or quantity of ions in the sample;
[0179] Timestamp: Measurement time, used to identify the time sequence of data collection.
[0180] Baseline correction: The baseline portion of the data is fitted using the least squares method, where the asymmetric term allows for a higher tolerance for errors at signal peaks. After correction, the removed baseline portion is separated from the original signal, resulting in data with baseline drift removed.
[0181] The original signal is generated based on the original mass spectrometry time-series data. Assume the original signal is... Where t represents the timestamp, The signal strength at that time point is represented by the following data column: t: timestamp, with a length of n; Signal strength, length n1;
[0182] Assuming the original signal By baseline and mass spectrometry signal Composition; optimization is performed using the least squares method to minimize the difference between the baseline and the original signal, while constraining the smoothness of the baseline, i.e., the objective function is as follows:
[0183] ;
[0184] In the formula: Indicates the smoothing parameter; This represents the weight at the i-th time point; Indicates baseline The second derivative represents the rate of change of the baseline; Indicates the first The original signal at each time point; Indicates the first Baselines at each time point; This represents the signal after correction at time point i;
[0185] By minimizing the above objective function, a numerical optimization algorithm (such as the quasi-Newton method or gradient descent method) is used to solve for the baseline. Based on the baseline obtained from the solution The corrected mass spectrometry signal is obtained by combining the original signal with the corrected mass spectrometry signal. That is, subtracting the baseline from the original signal. The corrected mass spectrometry signal is then obtained. ;
[0186] Noise filtering: The mass spectrum signal was filtered using a Savitzky-Golay filter. Smoothing is performed by setting the window size and polynomial order to perform moving average and polynomial fitting, and smoothing the baseline-corrected signal.
[0187] The formula for calculating the filter is:
[0188] ;
[0189] In the formula: This represents the filtered signal value; t represents the timestamp. The weight coefficients are calculated by polynomial fitting and depend on the window size M and the order of the polynomial; N represents the normalization constant. Indicates the corrected number One signal;
[0190] Assuming the window size is M, where M is the cardinality, indicating that the signal values of the current signal point and its neighborhood are taken into account; the filter calculates the weighted average of all data points within the window, and calculates the new value of each data point by fitting a polynomial, where the window size is selected based on the noise frequency of the signal and the data characteristics, and the order d of the polynomial is chosen to be 2.
[0191] The steps to select the window size are as follows:
[0192] Estimating noise frequencies: for mass spectrum signals Perform a fast Fourier transform to obtain the observed frequency spectrum, and estimate the noise frequency based on the observed spectrum. The frequency is represented by the main peak region of high-frequency noise.
[0193] Calculate peak width: for mass spectrum signals The location of the maximum peak is detected, the position of half the height of the peak is found, and the time difference between this position and the center of the peak is determined as the width of the peak.
[0194] Weighted calculation window size: The final window size M is selected by weighted averaging based on the relative importance of noise frequency and peak width.
[0195] ;
[0196] In the formula: Indicates the weighting coefficient; and This represents a constant chosen based on actual circumstances; Indicates peak width; Indicates the noise frequency;
[0197] By combining noise frequency and signal peak width, a weighted average method is used to select the window size, which balances noise smoothing and signal feature preservation. The appropriate window size can be flexibly selected according to the noise characteristics and signal morphology of the actual data.
[0198] Peak alignment: Based on the m / z sequences of different samples, the optimal alignment path is calculated using a dynamic time warping algorithm to minimize the differences between different time points; the m / z value of each sample is adjusted to align it with the m / z sequence of the reference sample.
[0199] The Dynamic Time Warping (DTW) algorithm calculates the minimum distance between two time series. In mass spectrometry data, each time series is regarded as a pair of m / z values and signal intensities of different samples.
[0200] For the m / z sequences of the two samples and (Assuming there are n data points), the DTW calculation is based on the differences between signal strengths, and taking into account the offset of the m / z value, the recursive relationship is defined as follows:
[0201] ;
[0202] in: This represents the minimum alignment distance between the i-th m / z of sample 1 and the j-th m / z of sample 2; This represents the distance metric used to calculate the deviation of the m / z value, specifically using Euclidean distance.
[0203] In recursion, This indicates leftward expansion, meaning expansion occurs only along the m / z axis of the first sample;
[0204] This indicates the expansion on the upper side, meaning that the expansion only occurs along the m / z axis of the second sample;
[0205] This means considering the expansion of two sequences simultaneously and selecting the path with the smallest expansion.
[0206] When calculating the distance, an m×n matrix is constructed, where m represents the length of the m / z sequence of sample 1, and n represents the length of the m / z sequence of sample 2; each element in the matrix... Both represent the minimum cumulative distance required to align the i-th and j-th m / z values;
[0207] Recursive initialization:
[0208] initialization ;
[0209] Boundary conditions:
[0210] ;
[0211] ;
[0212] The optimal alignment path is calculated using dynamic programming, that is, based on the minimum DTW distance, backtracking to find the path from... arrive The path corresponds to the optimal alignment of sample 1 and sample 2 on the time axis. Based on the optimal alignment path, the m / z sequences of sample 1 and sample 2 are adjusted so that the same components are aligned in different samples. According to the alignment information calculated by DTW, the m / z values of the samples are adjusted to a common reference system. In this invention, it is a multi-sample alignment. Therefore, we select a reference sample and align the m / z sequences of other samples with the m / z sequence of the reference sample. For each sample, the DTW distance is calculated using the above formula, and the sample m / z sequence is adjusted.
[0213] In this disclosure, the DTW algorithm provides an effective peak alignment method in mass spectrometry data by calculating the minimum distance and dynamically planning the alignment path. It takes into account nonlinear variations and can accurately align the m / z peaks in different samples, laying the foundation for subsequent analysis.
[0214] Based on the above preprocessing steps, a cleaned and normalized mass spectrometry matrix will be obtained: an m A matrix of n, where m represents the number of samples and n represents the feature dimension (i.e., the m / z number for each sample).
[0215] Feature engineering optimization:
[0216] Feature selection was performed based on the cleaned and normalized mass spectrometry matrix, and the selection was based on the coefficient of variation of each m / z peak:
[0217] ;
[0218] In the formula: This represents the standard deviation of the i-th m / z peak; This represents the mean of the i-th m / z peak; This represents the coefficient of variation of the i-th m / z peak;
[0219] After calculating the coefficient of variation for each m / z peak, only m / z peaks with a coefficient of variation greater than 0.3 are retained.
[0220] Weighting: Different weights are assigned based on the degree of variation of the m / z peaks, so that features with greater information content dominate in subsequent analysis.
[0221] ;
[0222] In the formula: The weight of feature i is represented; This represents the coefficient of variation of the i-th m / z peak;
[0223] As can be seen from the above, features with high variability will be given higher weight.
[0224] Dimensionality reduction: This method reduces the dimensionality of the feature space, improving computational efficiency, avoiding the curse of dimensionality, while preserving the main information of the data; dimensionality reduction is achieved by using weighted principal component analysis.
[0225] Construct a weighted covariance matrix, where the weights of the features serve as the weights of the covariance matrix; assume the weight of each feature i is... The constructed weighted covariance matrix is as follows:
[0226] ;
[0227] In the formula: Let X represent the weighted covariance matrix, with dimensions n×n (i.e., number of features × number of features); let W represent the weighted mass spectrometry matrix, with dimensions m×n (i.e., number of samples × number of features); and let W represent the diagonal weight matrix, with dimensions n×n, where the diagonal elements are the weights of each feature. ;
[0228] therefore ;
[0229] Calculate the eigenvalues and eigenvectors of the weighted covariance matrix, and select the principal components:
[0230] ;
[0231] In the formula: Represents the weighted covariance matrix; This represents the i-th eigenvalue; This represents the i-th eigenvector;
[0232] Calculate all eigenvalues and their corresponding eigenvectors, sort them, and select the eigenvectors corresponding to the k largest eigenvalues as the principal components after dimensionality reduction.
[0233] The data is projected onto the first 3 to 5 principal components to form a new low-dimensional feature space. Specifically, assuming the first k principal components are selected, their feature vectors are... ;
[0234] ;
[0235] In the formula: This represents a weighted mass spectrum matrix with dimensions m×n; This represents a matrix consisting of the first k eigenvectors, with dimensions n×k; Let m be the projected data matrix, with dimensions m×k, representing the data after dimensionality reduction.
[0236] Based on the mini-sorting of eigenvalues, the top k principal components (eigenvectors) are selected for dimensionality reduction. When selecting the value of k, the outgoing components with a cumulative variance contribution rate of 95% are selected to ensure that sufficient variation information is still retained after dimensionality reduction.
[0237] The formula for calculating the cumulative variance contribution rate is as follows:
[0238] ;
[0239] In the formula: This represents the i-th eigenvalue; Represents the sum of all eigenvalues;
[0240] The cumulative variance contribution rate is the proportion of the total variance explained by the principal components after selecting the first k principal components, relative to the total variance of the original data.
[0241] ;
[0242] The low-dimensional data matrix obtained based on the above steps That is, the weighted feature space matrix, with dimensions m×k, where m is the number of samples and k is the feature dimension after dimensionality reduction. ).
[0243] WPCA not only preserves the maximum variation information between samples, but also, through the weighted covariance matrix, makes the features with larger weights in the dimensionality reduction process have a greater impact on the final result. Furthermore, after dimensionality reduction, it can retain as many key features as possible that are relevant to the analysis, such as sample classification and pattern recognition.
[0244] Adaptive k-means clustering:
[0245] Initial centroid optimization: The k-means++ algorithm is used to optimize the selection of initial centroids. By selecting points that are far away from the previously selected centroids as new centroids, the clustering quality is improved.
[0246] Initialize the first centroid: Randomly select a data point as the first centroid. ;
[0247] Calculate the distance from each point to the selected centroid: For each remaining data point, calculate its distance to the selected centroid.
[0248] ;
[0249] In the formula: This indicates the j-th centroid that has been selected; This represents the i-th data point;
[0250] Choosing a new centroid: The next centroid is selected based on a weighted probability calculated using the square of the distance. Specifically, the point is selected. It is proportional to the square of its distance to the nearest centroid:
[0251] ;
[0252] Repeat the above steps until k centroids are selected;
[0253] Cluster number determination: Calculate the silhouette coefficient under different cluster numbers, and select the largest cluster number with a silhouette coefficient greater than 0.6 as the optimal cluster number;
[0254] ;
[0255] In the formula: Represents the silhouette coefficient of sample i; This represents the average distance from sample i to other samples within the same cluster;
[0256] ;
[0257] in The average distance from sample i to all samples in its nearest other cluster:
[0258] ;
[0259] Choosing the optimal number of clusters: For each number of clusters with k, calculate the average silhouette coefficient for all samples:
[0260] ;
[0261] Select the cluster with the largest silhouette coefficient that is greater than 0.6;
[0262] Iterative clustering: The k-means++ algorithm is used to cluster the data, with weighted Euclidean distance as the metric. The specific steps are as follows:
[0263] Calculate the weighted Euclidean distance: for each sample and cluster center Calculate the weighted Euclidean distance:
[0264] ;
[0265] In the formula: Indicates sample To the cluster center The weighted Euclidean distance; Indicates sample The value of the t-th feature; Representing cluster centers The values on t features; k represents the number of dimensions of the features; Let represent the weight of the t-th feature; where Determined based on the variance or coefficient of variation of the feature:
[0266] ;
[0267] In the formula: The variance of feature t is represented. The coefficient of variation (the ratio of standard deviation to mean) represents feature t; a larger weight indicates that the feature is more important in the clustering.
[0268] Each feature of each sample is assigned a different weight based on its variability or variance. Features with large variance are assigned smaller weights, which reduces the impact of noisy features.
[0269] Each sample is assigned to the nearest cluster center based on its calculated weighted Euclidean distance, assuming there are currently k cluster centers. For each sample Calculate its weighted Euclidean distance to all cluster centers and assign it to the nearest cluster center;
[0270] Each cluster center is updated to the mean of all samples currently belonging to that cluster. For the j-th cluster, its centroid... Update to the feature mean of all samples belonging to this cluster;
[0271] The clustering process continues to iterate until the clustering results converge, i.e., the change in centroid is less than the set threshold.
[0272] Based on adaptive k-means clustering, cluster label vectors and centroid feature vectors are obtained. The cluster label vector is an m×1 vector, where each element is the cluster label of the sample; the centroid feature vector is a c×k matrix, where c is the number of clusters and k is the feature dimension.
[0273] Contaminated fingerprint matching:
[0274] Based on cluster label vectors and centroid feature vectors, as well as a mass spectrometry database of known pollution sources, pollution source fingerprint matching is performed. The known pollution source fingerprint database includes the m / z values and corresponding feature signals of different pollution sources.
[0275] Similarity calculation: An improved cosine similarity algorithm is used to evaluate the similarity between the cluster centroid and each pollution source in the pollution source feature library. The calculated similarity values are sorted and the pollution source with the highest similarity is selected.
[0276] Since conventional cosine similarity assesses similarity by measuring the angle between two vectors, this method ignores the differences in signal intensity, resulting in some important mass spectral peaks not receiving sufficient attention in the similarity calculation. Therefore, by weighting and adjusting the signal intensity of each m / z peak, a more accurate matching result can be obtained.
[0277] That is, by introducing a weighted processing of the signal intensity of each m / z peak, we make stronger peaks contribute more to the similarity calculation:
[0278] ;
[0279] In the formula: The eigenvectors representing the centroids of the clusters, where It is the signal intensity of the cluster centroid at the t-th m / z peak; This represents the feature vector of a pollution source in the pollution source feature database, where It represents the signal intensity of the pollution source at the t m / z peaks; k represents the dimension of the eigenvector (i.e., the number of m / z peaks). The weights of the t m / z peaks are calculated based on the signal strength of each peak.
[0280] ;
[0281] In the formula: This represents the signal intensity of the t-th m / z peak. This weight is the normalized weight, meaning the sum of all weights is 1. The larger the weight, the stronger the signal of the peak, and the greater its impact on similarity calculation.
[0282] In this invention, by weighting the signal intensity of each peak, the similarity between the cluster centroid and the pollution source features can be evaluated more accurately, avoiding the neglect of mass spectrum peaks with stronger signals; mass spectrum peaks with weaker signals are given lower weights, thereby reducing the interference of noise or irrelevant features on the matching results.
[0283] Source resolution: Based on the similarity value between each cluster centroid and the pollution source, sort them from high to low similarity, and select a similarity threshold, such as 0.85; when the similarity between the cluster centroid and the pollution source is greater than the threshold, they are considered to be matched;
[0284] Based on the similarity screening results, a centroid-pollution source matching matrix M is constructed, with a size of c×p, where c represents the number of clusters and p represents the number of pollution sources.
[0285] In the matching matrix, each row represents a cluster, and each column represents a pollution source. If the similarity between cluster i and pollution source j is greater than a threshold, then the cluster i is considered a cluster. Then the matrix This indicates that cluster i matches pollution source j; otherwise... ;
[0286] If the similarity between a cluster centroid and multiple pollution sources is greater than a threshold If the centroid of the cluster may match multiple pollution sources, it is marked as multiple pollution sources. Therefore, a row of matrix M contains multiple elements with a value of 1.
[0287] Contribution assessment: Based on the distribution of samples in each cluster and the similarity between the cluster centroid and the pollution source, the contribution of pollution source j to that cluster is calculated; the number of samples in each cluster... The similarity to this cluster will affect the contribution of the pollution source to the sample:
[0288] ;
[0289] In the formula: The elements in the matching matrix indicate whether cluster i and pollution source j match; This represents the number of samples in cluster i; This represents the similarity between cluster i and pollution source j;
[0290] By normalizing the contribution of all pollution sources, the relative contribution percentage of each pollution source is obtained.
[0291] Based on this, a source apportionment report is obtained, including the type of pollution source, similarity, and contribution percentage.
[0292] like Figure 3 As shown, this disclosure also provides a mass spectrometry gas source apportionment system based on the K-means clustering algorithm, the system comprising:
[0293] The preprocessing module is used to acquire and preprocess the raw mass spectrometry time-series data to obtain a normalized mass spectrometry matrix;
[0294] The optimization module is used to optimize the feature engineering of the standardized mass spectrometry matrix to obtain a low-dimensional feature space matrix;
[0295] The clustering module is used to process the low-dimensional feature space matrix through clustering algorithms to obtain cluster label vectors and centroid feature vectors;
[0296] The matching module is used to perform pollution source fingerprint matching and analysis based on the pollution source database, using cluster label vectors and centroid feature vectors.
[0297] Specifically, the optimization module is used to optimize the feature engineering of the normalized mass spectrometry matrix to obtain a low-dimensional feature space matrix, including:
[0298] The optimization module is used to determine the coefficient of variation;
[0299] Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix;
[0300] Assign weights to the variant m / z peaks in the first matrix;
[0301] Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
[0302] Specifically, the optimization module is used to optimize the feature engineering of the normalized mass spectrometry matrix to obtain a low-dimensional feature space matrix, including:
[0303] The optimization module is used to determine the coefficient of variation;
[0304] Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix;
[0305] Assign weights to the variant m / z peaks in the first matrix;
[0306] Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
[0307] Specifically, the matching module is used to perform pollution source fingerprint matching and analysis based on the pollution source database, using clustered label vectors and centroid feature vectors, including:
[0308] The matching module is used to calculate the cluster label vector and centroid feature vector using an improved cosine similarity algorithm, and obtain the similarity between the cluster centroid and each pollution source in the pollution source database.
[0309] Set a similarity threshold and construct a matching matrix based on the similarity threshold;
[0310] The contribution of each pollution source is calculated based on the matching matrix.
[0311] Those skilled in the art should understand that, despite the detailed description of this disclosure with reference to the foregoing embodiments, modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure.
Claims
1. A method for mass spectrometry gas source analysis based on K-means clustering algorithm, characterized in that, The method includes: The raw mass spectrometry time-series data is acquired and preprocessed to obtain a normalized mass spectrometry matrix. The preprocessing of the raw mass spectrometry time-series data includes: baseline correction, noise filtering, and peak alignment performed sequentially on the raw mass spectrometry time-series data. The raw mass spectrometry time-series data includes the mass-to-charge ratio (m / z) value, signal intensity, and timestamp. The baseline correction of the original mass spectrometry time-series data includes: traversing the original mass spectrometry time-series data, fitting the baseline using the least squares method to obtain the objective function; minimizing the objective function and obtaining the target baseline through a numerical optimization algorithm; and using the target baseline to perform baseline correction on the original mass spectrometry time-series data to obtain the first signal; the objective function is: ;in, Indicates the smoothing parameter; This represents the weight at each time point; The second derivative of the baseline is represented by , and the rate of change of the baseline is represented by . This represents the signal after correction at time point i; Noise filtering of the first signal includes: setting a window range, including: performing a Fourier transform on the first signal to obtain the observed frequency spectrum; estimating the noise frequency based on the observed frequency spectrum; determining the peak width according to the first signal; and weighting the noise frequency and peak width to determine the window range, including: ;in, Indicates the weighting coefficient; and This represents a constant chosen based on actual circumstances; Indicates peak width; M represents the noise frequency; M represents the window range; by using a filter and combining the window range, the target signal is smoothed to obtain the second signal; Peak alignment of the second signal includes: dividing the m / z value corresponding to the second signal into reference samples and samples to be aligned; calculating the distance matrix between the m / z value of the sample to be aligned and the m / z value of the reference sample using a dynamic time warping algorithm; and determining the target alignment path using a dynamic programming recursive method; wherein the dynamic programming recursive method is: ;in, This represents the minimum alignment distance between the i-th m / z of sample 1 and the j-th m / z of sample 2; The distance metric used to calculate the deviation of the m / z value is Euclidean distance; the m / z value of the sample to be aligned is adjusted using the target alignment path to obtain the normalized mass spectrometry matrix; The feature engineering optimization of the standardized mass spectrometry matrix yields a low-dimensional feature space matrix. The low-dimensional feature space matrix is processed by a clustering algorithm to obtain cluster label vectors and centroid feature vectors; Based on a pollution source database, pollution source fingerprint matching and analysis are performed using cluster label vectors and centroid feature vectors. This includes: employing an improved cosine similarity algorithm to calculate the cluster label vectors and centroid feature vectors, obtaining the similarity between the cluster centroids and each pollution source in the pollution source database; setting a similarity threshold and constructing a matching matrix based on the threshold; and calculating the contribution of each pollution source based on the matching matrix. The similarity calculation includes: ;in, , represents the eigenvector of the cluster centroid, where It is the signal intensity of the cluster centroid at the t-th m / z peak; This represents the feature vector of a pollution source in the pollution source feature database, where It represents the signal intensity of the pollution source at the t m / z peaks; k represents the dimension of the eigenvector, i.e., the number of m / z peaks; This represents the weight of t m / z peaks; the calculation of the contribution includes: ;in, The elements in the matching matrix indicate whether cluster i and pollution source j match; This represents the number of samples in cluster i; This represents the similarity between cluster i and pollution source j.
2. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 1, characterized in that, By using a filter and combining it with a window range, the target signal is smoothed to obtain a second signal, including: ; in, This represents the filtered signal value, i.e., the second signal; t represents the timestamp. The weight coefficients are calculated by polynomial fitting and depend on the window range M and the order of the polynomial; N represents the normalization constant. Indicates the corrected number One signal.
3. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 1, characterized in that, The normalized mass spectrometry matrix is optimized through feature engineering to obtain a low-dimensional feature space matrix, including: Determine the coefficient of variation; Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix; Assign weights to the variant m / z peaks in the first matrix; Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
4. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 3, characterized in that, Determining the coefficient of variation includes: ; in, This represents the standard deviation of the i-th m / z peak; This represents the mean of the i-th m / z peak; This represents the coefficient of variation of the i-th m / z peak.
5. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 4, characterized in that, Weights are assigned to the variability of the m / z peaks in the first matrix, including: ; in, This represents the weight of feature i.
6. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 3, characterized in that, Based on the weights, the dimension of the first matrix is compressed to obtain a low-dimensional feature space matrix, including: Construct a weighted covariance matrix based on the weights; The eigenvalues and eigenvectors of the weighted covariance matrix are determined by the weighted covariance matrix. The eigenvalues and eigenvectors are traversed, sorted, and projected to determine the low-dimensional feature space matrix.
7. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 6, characterized in that, The weighted covariance matrix is: ; in, This represents the weighted covariance matrix, with dimension n representing the number of features. The number of features is n; X is a weighted mass spectrometry matrix with dimension m equal to the number of samples. n; W represents the diagonal weight matrix, with dimensions of . n n, whose diagonal elements are the weights of each feature. ;therefore .
8. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 7, characterized in that, The eigenvalues and eigenvectors of the weighted covariance matrix are determined by the weighted covariance matrix, including: ; in, This represents the i-th eigenvalue; Let i represent the i-th eigenvector.
9. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 1, characterized in that, The low-dimensional feature space matrix is processed by a clustering algorithm to obtain cluster label vectors and centroid feature vectors, including: The k-means++ algorithm is used to select multiple centroids for the low-dimensional feature space matrix; The target number of clusters is determined by the silhouette coefficient; The k-means++ algorithm is used to iteratively calculate the data using weighted Euclidean distance as the metric until the change in centroid is less than a set threshold, thus obtaining the cluster label vector and the centroid feature vector.
10. The mass spectrometry gas source analysis method based on K-means clustering algorithm according to claim 9, characterized in that, The k-means++ algorithm is used to select multiple centroids for the low-dimensional feature space matrix, including: Randomly select a data point in the low-dimensional feature space matrix as the first centroid, and repeat the following steps iteratively; Calculate the distance from the remaining data points to the first centroid; The second centroid is selected using a distance-weighted method. The iteration stops when the number of selected centroids reaches the threshold.
11. A mass spectrometry gas source apportionment system based on K-means clustering algorithm, characterized in that, The system includes: The preprocessing module is used to acquire and preprocess the raw mass spectrometry time-series data to obtain a normalized mass spectrometry matrix. The preprocessing of the raw mass spectrometry time-series data includes: performing baseline correction, noise filtering, and peak alignment on the raw mass spectrometry time-series data in sequence. The raw mass spectrometry time-series data includes the mass-to-charge ratio (m / z) value, signal intensity, and timestamp. The baseline correction of the original mass spectrometry time-series data includes: traversing the original mass spectrometry time-series data, fitting the baseline using the least squares method to obtain the objective function; minimizing the objective function and obtaining the target baseline through a numerical optimization algorithm; and using the target baseline to perform baseline correction on the original mass spectrometry time-series data to obtain the first signal; the objective function is: ;in, Indicates the smoothing parameter; This represents the weight at each time point; The second derivative of the baseline is represented by , and the rate of change of the baseline is represented by . This represents the signal after correction at time point i; Noise filtering of the first signal includes: setting a window range, including: performing a Fourier transform on the first signal to obtain the observed frequency spectrum; estimating the noise frequency based on the observed frequency spectrum; determining the peak width according to the first signal; and weighting the noise frequency and peak width to determine the window range, including: ;in, Indicates the weighting coefficient; and This represents a constant chosen based on actual circumstances; Indicates peak width; M represents the noise frequency; M represents the window range; by using a filter and combining the window range, the target signal is smoothed to obtain the second signal; Peak alignment of the second signal includes: dividing the m / z value corresponding to the second signal into reference samples and samples to be aligned; calculating the distance matrix between the m / z value of the sample to be aligned and the m / z value of the reference sample using a dynamic time warping algorithm; and determining the target alignment path using a dynamic programming recursive method; wherein the dynamic programming recursive method is: ;in, This represents the minimum alignment distance between the i-th m / z of sample 1 and the j-th m / z of sample 2; The distance metric used to calculate the deviation of the m / z value is Euclidean distance; the m / z value of the sample to be aligned is adjusted using the target alignment path to obtain the normalized mass spectrometry matrix; The optimization module is used to optimize the feature engineering of the standardized mass spectrometry matrix to obtain a low-dimensional feature space matrix; The clustering module is used to process the low-dimensional feature space matrix through clustering algorithms to obtain cluster label vectors and centroid feature vectors; A matching module is used to perform pollution source fingerprint matching and analysis based on a pollution source database using cluster label vectors and centroid feature vectors. This includes: the matching module employing an improved cosine similarity algorithm to calculate the cluster label vectors and centroid feature vectors, obtaining the similarity between the cluster centroids and each pollution source in the pollution source database; setting a similarity threshold and constructing a matching matrix based on the similarity threshold; and calculating the contribution of each pollution source based on the matching matrix. The similarity calculation includes: ;in, , represents the eigenvector of the cluster centroid, where It is the signal intensity of the cluster centroid at the t-th m / z peak; This represents the feature vector of a pollution source in the pollution source feature database, where It represents the signal intensity of the pollution source at the t m / z peaks; k represents the dimension of the eigenvector, i.e., the number of m / z peaks; This represents the weight of t m / z peaks; the calculation of the contribution includes: ;in, The elements in the matching matrix indicate whether cluster i and pollution source j match; This represents the number of samples in cluster i; This represents the similarity between cluster i and pollution source j.
12. The mass spectrometry gas source apportionment system based on K-means clustering algorithm according to claim 11, characterized in that, The optimization module is used to optimize the feature engineering of the normalized mass spectrometry matrix to obtain a low-dimensional feature space matrix, including: The optimization module is used to determine the coefficient of variation; Based on the coefficient of variation, feature filtering is performed on the standardized mass spectrometry matrix to obtain the first matrix; Assign weights to the variant m / z peaks in the first matrix; Based on the weights, the dimensions of the first matrix are compressed to obtain a low-dimensional feature space matrix.
13. The mass spectrometry gas source apportionment system based on K-means clustering algorithm according to claim 11, characterized in that, The clustering module is used to process the low-dimensional feature space matrix using a clustering algorithm to obtain cluster label vectors and centroid feature vectors, including: The clustering module is used to select multiple centroids by applying the k-means++ algorithm to the low-dimensional feature space matrix; The target number of clusters is determined by the silhouette coefficient; The k-means++ algorithm is used to iteratively calculate the data using weighted Euclidean distance as the metric until the change in centroid is less than a set threshold, thus obtaining the cluster label vector and the centroid feature vector.
Citation Information
Patent Citations
Non-targeted screening method for characteristic mass spectrum fingerprints of pollutants in water
CN119881061A
Multi-dimensional holographic data analysis method and system for hazardous waste supervision
CN120044012A