Composite strain detection method based on combination of Raman spectrum time sequence analysis and machine learning
By combining Raman spectral timing analysis and machine learning, wavelet transformation and LSTM models are used to perform preliminary separation of complex bacterial species, and then carefully classified through the SNG-DBSCAN algorithm, the existing complex bacterial species detection methods are solved. The problem of cumbersome and low efficiency of existing complex bacterial species detection methods is solved. , achieving rapid and highly accurate bacterial strain detection.
Patent Information
- Application Number
- CN202411588944.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing complex bacterial strain detection methods are cumbersome, time-consuming and inefficient. The single bacterial strain detection methods based on Raman spectrum cannot achieve rapid detection and effective distinction between bacterial strain differences.
Using a composite bacterial strain detection method based on Raman spectral timing analysis and machine learning, the Raman spectral data is converted into timing data through wavelet transformation, and the LSTM model is used for timing analysis, and the complex bacterial strain is initially isolated, and then the SNG-DBSCAN algorithm is used. Classify the isolated monocytogenes.
It improves the efficiency and accuracy of the detection of compound bacterial strains, can quickly isolate and distinguish different bacterial strains, reduces the consumption of artificial experiments, and improves the credibility and accuracy of the detection.
Smart Images

Figure CN119474980A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of composite bacterial strain detection, and in particular to a composite bacterial strain detection method based on the combination of Raman spectroscopy time series analysis and machine learning. Background Art
[0002] The traditional detection process of composite bacterial strains is often very cumbersome and requires multiple steps to obtain results. The complexity of its operation not only prolongs the entire detection cycle, but also increases the requirements for the professional skills of the operator. The separation process is time-consuming, inefficient, and costly, especially in the face of complex ecological environments or large sample demand scenarios. Raman spectroscopy, as a molecular vibration spectroscopy technology, can provide information about molecular structure and chemical bonds. By analyzing the vibration frequency of specific chemical bonds in cells and the vibration characteristics of cell molecules, the molecular structure information of cells can be obtained to achieve rapid identification and separation of different bacterial strains. However, the existing Raman spectroscopy technology based on the construction of a specific bacterial strain model to predict the single bacterial strain detection method in unknown samples cannot achieve rapid detection, and cannot effectively distinguish the differences between bacterial strains, and has certain limitations in the detection of composite bacterial strains. The detection method based on the combination of machine learning and Raman spectroscopy can avoid the consumption of a large amount of energy, financial resources and time in traditional manual experimental screening, and is currently a hot research direction for the separation of composite bacterial strains. However, due to the aggregation of composite bacterial strains, various bacteria are stacked together, which easily causes overlapping, agglomeration and other problems that are difficult to distinguish. Summary of the invention
[0003] The purpose of the present invention is to propose a composite bacterial strain detection method based on the combination of Raman spectroscopy time series analysis and machine learning to solve the problems existing in the above-mentioned prior art.
[0004] To achieve the above object, the present invention provides the following solutions:
[0005] The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning includes:
[0006] Collect Raman spectral data of composite bacteria;
[0007] The Raman spectrum data of the composite bacteria are converted into time series data by wavelet transformation;
[0008] Use the LSTM model to perform time series analysis on the time series data, and preliminarily separate the composite strains into different single strains;
[0009] The preset SNG-DBSCAN algorithm was used to classify the separated single bacterial species and obtain the bacterial species category.
[0010] Optionally, the method of converting the Raman spectrum data of the composite bacteria into time series data using wavelet transform is:
[0011]
[0012] Among them, W f,α,β (t) represents the result of continuous wavelet transform of function f(t) with specific scale parameter α and translation parameter β through specific wavelet function ψ(t). represents the square root of the scale parameter α, f(τ) represents the time domain signal to be analyzed, It represents the conjugate of the wavelet function, α represents the scale parameter, which is used to determine the width or duration of the wavelet function, β represents the translation parameter, which is used to determine the position of the wavelet function on the time axis, t represents the specific time point of the analysis signal feature to be obtained, and τ represents the integral variable.
[0013] Optionally, the method of performing time series analysis on the time series data using the LSTM model is:
[0014] i t =σ(W ix x t +W ih h t-1 +b i )
[0015] f t =σ(W fx x t +W fh h t-1 +b f )
[0016] o t =σ(W ox x t +W oh h t-1 +b o )
[0017] h t =o t ⊙tanh(C t )
[0018] C t =f t ⊙C t-1 +i t ⊙tanh(W cx x t +W ch h t-1 +b c )
[0019] Among them, i t represents the input gate at time t, σ represents the nonlinear activation function, Wix and W ih Both represent the weight matrix input to the input gate, h t-1 represents the hidden state of the previous time step, x t represents the vector of wavenumber and intensity in the Raman spectrum data of the bacterial species, b i represents the bias of the input gate, f t Represented as a specific wave number or intensity in Raman spectroscopy data, W fx is the weight matrix of the forget gate, b f is the bias term of the forget gate, o t Indicates the specific wave number or intensity in Raman spectroscopy data, W ox and W oh Both represent the weight matrix of the output gate, b o represents the bias term of the output gate, tanh represents the hyperbolic tangent function, C t represents the update unit state, W cx Indicates that the input x t The weight matrix mapped to the cell state space; W ch Indicates that the hidden state h of the previous time step is t-1 The weight matrix mapped to the cell state space; b c represents the bias term of the cell state, and ⊙ represents element-wise multiplication.
[0020] Optionally, using a preset SNG-DBSCAN algorithm, classifying the separated single bacterial species includes:
[0021] Preprocess the Raman spectral data of the isolated single bacterial species;
[0022] Perform uniformly segmented grid search on the preprocessed data to extract the optimal parameter combination;
[0023] Based on the optimal parameter combination, SNG-DBSCAN cluster analysis was performed on the pre-processed data to distinguish different bacterial species.
[0024] Optionally, preprocessing the Raman spectrum data of the separated single bacterial species includes:
[0025] Linear interpolation and mean filling were used to make up for the missing values in the Raman spectral data of the separated single bacterial species, and the data were standardized.
[0026] Optionally, performing a uniformly segmented grid search on the preprocessed data includes:
[0027] Define parameter space;
[0028] Based on the parameter space, dividing the preprocessed data into grids;
[0029] Search the divided grid and the initial parameter combination;
[0030] The optimal parameter combination is obtained by comparing the performance of all grid points.
[0031] Optionally, based on the optimal parameter combination, performing SNG-DBSCAN cluster analysis on the preprocessed data includes:
[0032] Constructing sub-sampling neighborhood graph data for the pre-processed data;
[0033] Based on the optimal parameter combination, the sub-sampling neighborhood graph data is clustered to obtain bacterial species types.
[0034] Optionally, for the optimal parameter combination, constructing sub-sampling neighborhood graph data includes:
[0035] defining data points for the preprocessed data, and constructing domain data for the data points;
[0036] Performing density-based kernel density estimation on the domain data to determine the density value of each of the data points, and then selecting sample data points according to the density value;
[0037] The sub-sampled neighborhood graph data is constructed for the sample data points, and the sub-sampled neighborhood graph data is reduced in dimension to obtain Laplace data of the neighborhood graph.
[0038] Optionally, clustering the sub-sampling neighborhood graph data to obtain bacterial species types includes:
[0039] Input the optimal parameter combination into the SNG-DBSCAN algorithm;
[0040] Based on the SNG-DBSCAN algorithm after inputting the optimal parameter combination, the Laplace data of the neighborhood graph is divided into core bacterial species and boundary bacterial species using the Laplace matrix; wherein the core bacterial species are bacterial species that can form core points after core point discrimination, and the boundary bacterial species represent bacterial species at the edge of core point discrimination;
[0041] Based on the core strain data and the boundary strain data, the data points of the same strain are grouped into the same cluster using the density accessibility between the core points to obtain the strain type.
[0042] The beneficial effects of the present invention are:
[0043] The composite strain detection method combining Raman spectroscopy time series analysis with machine learning has shown excellent performance and high accuracy in rapid strain separation and detection. Raman spectroscopy technology is used to improve the efficiency of strain detection and reduce time cost in response to the problem of detection speed; time series analysis is used to provide an effective solution to the problem of strain overlap or superposition, accurately analyze strain data, enhance the credibility of strain data, and greatly improve the accuracy of detection; machine learning algorithms are used to build a classification model, obtain strain classification results, and visualize strain clustering effect diagrams, which can efficiently and accurately distinguish the differences between different strains. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0045] Figure 1 It is a schematic diagram of the overall process of the composite bacterial strain detection method based on the combination of Raman spectroscopy time series analysis and machine learning according to an embodiment of the present invention;
[0046] Figure 2 Schematic diagram of average Raman spectra of Staphylococcus epidermidis and Staphylococcus pseudintermedius according to an embodiment of the present invention; wherein, Figure (a) is Staphylococcus epidermidis, and Figure (b) is Staphylococcus pseudintermedius;
[0047] Figure 3 A schematic diagram of the LSTM model construction process of an embodiment of the present invention;
[0048] Figure 4 This is a schematic diagram of the complete structure flow of SNG-DBSCAN according to an embodiment of the present invention;
[0049] Figure 5 It is a flow chart of a method for extracting feature parameters based on uniformly segmented grid search according to an embodiment of the present invention;
[0050] Figure 6 This is a flowchart of core point determination in an embodiment of the present invention;
[0051] Figure 7 This is a graph showing the clustering results of bacterial species Raman spectroscopy data using the SNG-DBSCAN algorithm of an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0054] The application of wavelet transform can significantly distinguish the types of strains by converting raw data into time series data, capturing the key characteristic wavenumbers and characteristic peaks in Raman spectral data. This paper applies the strain separation model of LSTM time series analysis to further transform the composite strains into multiple single strains, thereby improving the accuracy of strain separation. In addition, analysis of the collected Raman spectral data shows that the distribution of strains is generally irregular in shape, such as spherical or elliptical. Therefore, this embodiment uses the DBSCAN (Subsampled Neighborhood Graph Density Clustering of Applications with Noise, a density space clustering algorithm based on subsampled neighborhood graph) algorithm improved for strain clustering applications to perform cluster analysis on strain data to solve the problem of irregular distribution of strains and speed up the clustering process. SNG-DBSCAN can identify clusters of any shape and automatically determine the number of clusters based on the density of the data, which is very useful for complex data distribution and unclear number of clusters.
[0055] This embodiment proposes a composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning, including:
[0056] Collect Raman spectral data of composite bacteria;
[0057] The Raman spectrum data of the composite bacteria are converted into time series data by wavelet transformation;
[0058] Use the LSTM model to perform time series analysis on the time series data, and preliminarily separate the composite strains into different single strains;
[0059] The preset SNG-DBSCAN algorithm was used to classify the separated single bacterial species and obtain the bacterial species category.
[0060] Specifically, this embodiment proposes a composite bacterial strain detection method based on the combination of Raman spectroscopy time series analysis and machine learning. Figure 1As shown in the figure, firstly, the strain samples are prepared, data is collected, and the data is preprocessed to obtain the original Raman spectrum data. Then, the original data is converted into time series data using wavelet transform, and then the data features are extracted. Then, the LSTM model is used for time series analysis to separate the composite strains and preliminarily obtain different strains. In addition, the data is analyzed using uniform segmentation grid search to obtain the optimal parameter combination. On this basis, SNG-DBSCAN (Subsampled Neighborhood Graph Density Clustering of Applications with Noise, a density space clustering algorithm based on subsampled neighborhood graph) clustering analysis is used to further distinguish different strains, and the silhouette coefficient and Davies-Bouldin index are used to judge the clustering effect. Finally, PCA dimensionality reduction is used to achieve the purpose of strain classification and finally determine the strain category.
[0061] Specifically, in this embodiment, before collecting the Raman spectrum data of the composite bacteria, the following steps are also included: sampling of a single bacteria species;
[0062] The method of single bacterial species sampling can be used to initialize the data set. After the data set has some bacterial species, the scope of separation and classification of composite bacterial species can be framed, and then the target bacterial species in the data set can be locked, and unknown bacterial species outside the data set can also be obtained to achieve the purpose of accurate separation.
[0063] The steps of single strain sampling mainly include:
[0064] (1) Use culture dishes or culture media to multiply the bacterial strains. When the bacterial strains reach a certain size, sample the strains and make a suspension for spectral collection.
[0065] (2) One of the simplest methods for separating solid particles from liquid is filtration. After filtration, differential centrifugation and density gradient centrifugation can be used to obtain a pure and representative sample from the sample.
[0066] (3) Set the parameters of the Raman spectrometer, such as laser wavelength, power, integration time, resolution, etc. to ensure sufficient quality and accuracy.
[0067] (4) Place the prepared bacterial sample in the detection area of the Raman spectrometer, adjust the laser focus of the Raman spectrometer to ensure that it is accurately irradiated on the sample, and calibrate the instrument to eliminate system errors. Start the spectrum acquisition program, and the instrument will record the Raman spectrum signal scattered by the sample. Finally, Raman spectrum data can be obtained, and these obtained Raman spectra are regarded as a data set. In this way, a preliminary list of various bacterial species is obtained.
[0068] (5) The Raman spectrum data of various bacterial species are plotted into an average Raman spectrum. By plotting the average Raman spectrum, the differences in wavenumber and peak value between bacterial species can be accurately determined. The difference in wavenumber can be used to determine the chemical bond vibration and specific chemical groups of a specific bacterial species; the difference in wave peaks can be used to determine the characteristic information of biological macromolecules such as proteins, nucleic acids, lipids, and carbohydrates of a specific bacterial species. Taking Staphylococcus epidermidis and Staphylococcus pseudintermedius as examples, the effect diagram drawn based on the collected Raman spectrum data is shown below. Figure 2 As shown, Figure 2 (a) is the average Raman spectrum of Staphylococcus epidermidis. Figure 2 (b) is the average Raman spectrum of Staphylococcus pseudintermedius, where the horizontal axis is the wave number and the vertical axis is the intensity.
[0069] In this embodiment, the Raman spectrum data of the composite bacteria species are collected including:
[0070] Taking into account the overlap of complex bacterial species in patient tissue sampling during actual clinical testing, this study also needs to sample and collect complex bacterial species data when constructing the data set.
[0071] The steps of composite strain sampling mainly include:
[0072] (1) Use culture medium and culture dishes to expand the number of bacterial species first, process the sample to remove background interference substances, such as cell debris, culture medium components, etc., ensure that the main component is the target bacterial species, and ensure that the sample is evenly distributed to obtain consistent Raman spectral data.
[0073] (2) The expanded single strain samples are mixed together in pairs or three-by-three combinations to obtain composite strain samples.
[0074] (3) Continue to use the Raman spectrometer to process the sample and obtain sample data of the composite bacterial species. By collecting the Raman spectral data of a single bacterial species, a training model for composite bacterial species detection is constructed using the Raman spectral data of several bacterial species, and the Raman spectral data of the bacterial species are input into the model to obtain basic information.
[0075] Taking into account the problem that composite bacterial species may overlap, making it difficult to detect composite bacterial species, we will introduce wavelet transform to process the raw data to achieve the separation of composite bacterial species.
[0076] Specifically, in this embodiment, the composite strain separation includes:
[0077] Data transformation and feature extraction:
[0078] Since there may be overlaps in bacterial species, it is necessary to separate the composite bacterial species from each other, and this effect can be achieved through wavelet transform. According to the characteristics of the average Raman spectral data, the original data is first converted into time series data using wavelet transform, and then the features of the original data are extracted. The extracted features can be used as the basis for the separation of composite bacterial species, and the overlapping or superimposed bacterial species can be separated more accurately. Wavelet transform is an important time-frequency analysis tool that overcomes the limitations of traditional Fourier transform in processing non-stationary signals. Using wavelet transform to extract features of data sets at different scales can solve the impact of similar bacterial species data on model accuracy. The wavelet transform processing process mainly includes:
[0079] First, this embodiment selects Daubechies wavelet to transform the original strain Raman spectrum data into time series data, and then segments the data to further obtain features. f,α,β (t) represents the wavelet transform of a Raman spectrum data at scale α and position β, where α is the scale factor used to control the scaling of the wavelet function; β is the translation factor used to control the translation of the wavelet function. represents the complex conjugate of the wavelet function, which is used for orthogonality test to ensure the accuracy and efficiency of the transformation; f(τ) is the original signal, where τ is another representation of the time variable. As shown in formula (1).
[0080]
[0081] Among them, W f,α,β (t) represents the result of continuous wavelet transform of function f(t) with specific scale parameter α and translation parameter β through specific wavelet function ψ(t). represents the square root of the scale parameter α. f(τ) represents the time domain signal to be analyzed. represents the conjugate of the wavelet function. α represents the scale parameter, which is used to determine the width or duration of the wavelet function. β represents the translation parameter, which is used to determine the position of the wavelet function on the time axis. t represents the specific time point at which the analysis signal characteristics are to be obtained. τ represents the integral variable.
[0082] After decomposing the signal into multiple sub-bands, threshold denoising is applied to each sub-band, and the time-frequency localization characteristics of the wavelet transform are used to accurately locate the occurrence time of the high-frequency local features and reflect the overall characteristics of the low-frequency part to obtain the characteristic peaks and wavenumber bands of a certain type of bacteria in the original data. Finally, this embodiment obtains the time series data after wavelet transform and extracts the key features in the data.
[0083] LSTM (Long Short-Term Memory Network) timing analysis:
[0084] After the sample data is preprocessed by wavelet transform, this embodiment will obtain a series of time series data. Since the data of the strain samples at different times are different, the time series model can analyze the strain data according to time.
[0085] The LSTM (Long Short-Term Memory) model is a special recurrent neural network architecture in deep learning, which is mainly used to process time series data. The gating mechanism of the LSTM model input gate, forget gate and output gate is used to capture the characteristics of the wavenumber and intensity of the Raman spectrum of the strains, and to perform classification and regression prediction. The results obtained are the accuracy of separating the composite strains into different single strains, which preliminarily indicates the state of the composite strains after separation and is also used to verify the feasibility of the sample. The LSTM model construction process is as follows Figure 3 As shown, the main process includes:
[0086] LSTM uses a nonlinear activation function σ and an input gate to determine which strain information will update the state of the unit, as shown in formula (2). t represents the input gate at time t, x t is the vector of wavenumber and intensity in the Raman spectrum data of the strain, h t-1 represents the hidden state of the previous time step, W ix and W ih It represents the weight matrix input to the input gate, b i Represents the bias of the input gate, allowing the network to perform some basic memory operations even when there is no input signal.
[0087] i t =σ(W ix x t +W ih h t-1 +b i ) (2)
[0088] Similarly, the forget gate is used to determine which old strain information should be forgotten. t W is a specific wave number or intensity in the Raman spectroscopy data, which is not important for the current task; fx is the weight matrix of the forget gate, which is used to transform the input x t and the hidden state h at the previous time step t-1 Mapped to the output space of the forget gate; b f is the bias term of the forget gate, as shown in formula (3).
[0089] f t =σ(W fx x t +W fh h t-1 +b f) (3)
[0090] Similarly, the output gate is used to determine which strain feature information should be output or used for subsequent analysis. t Represents a specific wave number or intensity in Raman spectroscopy data, which is critical for classification or recognition tasks; W o is the weight matrix of the output gate, divided into W ox and W oh . Where W ox Used to convert the input x of the current time step t , mapped to the output gate space, and W oh Used to convert the hidden state h of the previous time step t-1 , mapped to the output gate space; b o is the bias term of the output gate; tanh is the hyperbolic tangent function, which is used to map the input to the range of -1 to 1. As shown in formulas (4) and (5).
[0091] o t =σ(W ox x t +W oh h t-1 +b o ) (4)
[0092] h t =o t ⊙tanh(C t ) (5)
[0093] LSTM also stores information through cell state, using the updated cell state C t , based on the decisions of the forget gate and the input gate, the cell state is updated in time, important strain information is stored in the cell state, and this information can be read when needed; W cx is to input x t The weight matrix mapped to the cell state space; W ch is to convert the hidden state h of the previous time step t-1 The weight matrix mapped to the cell state space; b c is the bias term of the cell state, as shown in formula (6).
[0094] C t =f t ⊙C t-1 +i t ⊙tanh(W cx x t +W ch h t-1 +b c ) (6)
[0095] Among them, it represents the input gate at time t, σ represents the nonlinear activation function, W ix and W ih Both represent the weight matrix input to the input gate, h t-1 represents the hidden state of the previous time step, x t represents the vector of wavenumber and intensity in the Raman spectrum data of the bacterial species, b i represents the bias of the input gate, f t Represented as a specific wave number or intensity in Raman spectroscopy data, W fx is the weight matrix of the forget gate, b f is the bias term of the forget gate, o t Indicates the specific wave number or intensity in Raman spectroscopy data, W ox and W oh Both represent the weight matrix of the output gate, b o represents the bias term of the output gate, tanh represents the hyperbolic tangent function, C t represents the update unit state, W cx Indicates that the input x t The weight matrix mapped to the cell state space; W ch Indicates that the hidden state h of the previous time step is t-1 The weight matrix mapped to the cell state space; b c represents the bias term of the cell state, and ⊙ represents element-wise multiplication.
[0096] Evaluation of composite bacterial strain isolation:
[0097] In order to further determine the correctness of the composite bacterial species separation results, this model also uses the data collected from single bacterial species to match and verify the composite bacterial species separation.
[0098] This embodiment divides the data set collected from a single strain, with most of the data used for model training and a small part of the data used for model testing to ensure that the data can be used reasonably. During the data testing process, in order to prevent data overfitting, this embodiment uses a callback function to optimize the model accuracy. Finally, by calculating the confusion matrix and classification report, the accuracy and recall rate of the model are obtained to evaluate the accuracy of the model, verify whether the strain forms the main single strain, and check the separation of the composite strain.
[0099] Based on the main single bacteria obtained by the model, the obtained data is formed into a data set, and each data sample is labeled to facilitate the subsequent clustering of bacterial species data using the SNG-DBSCAN algorithm.
[0100] Furthermore, the preset SNG-DBSCAN algorithm is used to classify the separated single bacterial species, including:
[0101] Preprocess the Raman spectral data of the isolated single bacterial species;
[0102] Perform uniformly segmented grid search on the preprocessed data to extract the optimal parameter combination;
[0103] Based on the optimal parameter combination, SNG-DBSCAN cluster analysis was performed on the pre-processed data to distinguish different bacterial species.
[0104] Furthermore, preprocessing the Raman spectrum data of the separated single bacterial species includes:
[0105] Linear interpolation and mean filling were used to make up for the missing values in the Raman spectral data of the separated single bacterial species, and the data were standardized.
[0106] Furthermore, the preprocessed data is subjected to uniform segmentation grid search including:
[0107] Define parameter space;
[0108] Based on the parameter space, dividing the preprocessed data into grids;
[0109] Search the divided grid and the initial parameter combination;
[0110] The optimal parameter combination is obtained by comparing the performance of all grid points.
[0111] The optimal parameter combination here includes parameters such as neighborhood radius and minimum sample points. Taking the minimum sample point as an example, assuming that the minimum sample point is 14, the sum of the number of all data points within a certain range must reach 14 to meet the basic conditions for cluster formation and form clusters. Taking the neighborhood radius as an example, assuming that the neighborhood radius is 2, then with each data point as the core and the sum of the number of other data points contained in the circle with a radius of 2 can meet the minimum number of sample points, then the set composed of these points is considered to be of the same type and can form clusters of the strain. More parameter indicators can more accurately reflect the state after cluster formation and can also make more thorough use of data. It should be noted that in the SNG-DBSCAN algorithm, the neighborhood radius and the minimum number of sample points are the main parameter indicators, and other parameter indicators are supplements to the algorithm to achieve a refined effect, so these parameter indicators are collectively referred to as the optimal parameter combination.
[0112] Further, based on the optimal parameter combination, performing SNG-DBSCAN cluster analysis on the preprocessed data includes:
[0113] Constructing sub-sampling neighborhood graph data for the pre-processed data;
[0114] Based on the optimal parameter combination, the sub-sampling neighborhood graph data is clustered to obtain bacterial species types.
[0115] Further, constructing sub-sampling neighborhood graph data for the preprocessed data includes:
[0116] defining data points for the preprocessed data, and constructing domain data for the data points;
[0117] Performing density-based kernel density estimation on the domain data to determine the density value of each of the data points, and then selecting sample data points according to the density value;
[0118] The sub-sampled neighborhood graph data is constructed for the sample data points, and the sub-sampled neighborhood graph data is reduced in dimension to obtain Laplace data of the neighborhood graph.
[0119] Furthermore, clustering the sub-sampling neighborhood graph data to obtain bacterial species types includes:
[0120] Input the optimal parameter combination into the SNG-DBSCAN algorithm;
[0121] Based on the SNG-DBSCAN algorithm after inputting the optimal parameter combination, the Laplace data of the neighborhood graph is divided into core bacterial species and boundary bacterial species using the Laplace matrix; wherein the core bacterial species are bacterial species that can form core points after core point discrimination, and the boundary bacterial species represent bacterial species at the edge of core point discrimination;
[0122] Based on the core strain data and the boundary strain data, the data points of the same strain are grouped into the same cluster using the density accessibility between the core points to obtain the strain type.
[0123] This embodiment inputs the optimal parameter combination as a whole into the SNG-DBSCAN algorithm. SNG-DBSCAN will use key parameter indicators such as the minimum number of sample points and the neighborhood radius to give priority to constructing a general clustering effect diagram, and then use other parameter indicators to further optimize the clustering effect diagram. Each optimal parameter indicator used will affect the size of the clusters in the final strain type, the amount of data in the clusters, and the relationship between the boundary data points. The optimal parameter index is a key link in determining the final strain type. These clustering indicators must be input into the algorithm so that the algorithm can complete the final clustering. In addition, when the SNG-DBSCAN algorithm believes that certain data points do not meet the optimal parameter indicators, these data points will be classified as noise points, which are gray points from the intuitive PCA dimensionality reduction diagram.
[0124] Among them, data points of the same strain belong to the same cluster and are considered core points. Core points constitute core strains, and core strains confirm a strain; data points of different strains do not belong to the same cluster and are considered boundary points. Boundary points constitute boundary strains, and these points eventually become part of the core strain or are considered noise points. In the algorithm, each data point of the same strain can be called a core point, because these data points have been confirmed to constitute a specific strain, and the set of these points is called the core strain. In addition, the set of data points that cannot be confirmed and are outside the core point judgment is called the boundary strain. These data points need to be judged repeatedly, and the final result is either a core point or a noise point (data points whose strain category cannot be determined).
[0125] Specifically, in this embodiment, the classification of composite bacteria includes:
[0126] Different from the composite strain separation which only conducts a rough analysis of different strains, the composite strain classification emphasizes the identification of the specific attributes of the strains to achieve the true determination of the strain type. After analyzing the Raman spectral data of the strains in this embodiment, it was found that the amount of data was relatively large, the calculation process was relatively complicated, and the traditional DBSCAN clustering time was too long. In addition, traditional DBSCAN is not easy to handle data sets with overlapping neighborhoods, especially for data sets with high strain similarity. In order to better combine the actual application background and better apply the DBSCAN algorithm to the strain classification model, this embodiment improves the traditional DBSCAN algorithm based on the data characteristics and is named the SNG-DBSCAN algorithm. Using SNG-DBSCAN, the data set can be divided into multiple subsets, and its calculation process can be easily parallelized, which further accelerates the execution speed of the algorithm, which is more advantageous than traditional algorithms. The complete structure flow chart of SNG-DBSCAN is shown below. Figure 4 shown.
[0127] According to the flow chart, this embodiment lists the specific steps into the following parts.
[0128] Data preprocessing for clustering:
[0129] The data preprocessing in this part is for the original Raman spectral data obtained from the patient. In order to test the patient more conveniently and quickly, this experiment proposes uploading the original Raman spectral data collected by the Raman spectrometer to the cloud platform to build a complete database. Doctors can upload the Raman spectral test results of urine tests, blood tests, etc. of patients to the cloud platform, and return the Raman spectral data after data preprocessing to the doctor through the retrieval of relevant bacterial species data to enhance the detection accuracy. Since the amount of data collected by the Raman spectral data may be inconsistent, this embodiment uses linear interpolation and mean filling to make up for possible missing values, and standardizes the data so that the optimal parameter combination in the data set can be extracted using a uniformly segmented grid search in the future.
[0130] Evenly split grid search:
[0131] When using the SNG-DBSCAN algorithm, the Raman spectral low-dimensional data set composed of wavenumber and intensity needs to obtain the optimal parameter features such as the optimal neighborhood radius and the minimum number of sample points. The optimal parameter features can be accurately obtained by uniformly splitting the grid search to ensure that there will be no overfitting problems after clustering. Based on this, this study uses uniformly split grid search to focus on extracting the neighborhood radius and the minimum number of sample points, distinguishing noise points and forming accurate cluster areas. The strain Raman spectral data is input into the grid search to find the optimal field radius and the minimum number of sample points. The main process is:
[0132] First, define the parameter space as shown in formula (7). It is the parameter space, representing parameters such as the radius of the component domain and the minimum number of sample points. Each parameter has a possible range of values; a i is the i-th component p i The lower bound of p i The minimum value that can be taken; b i is the i-th component p i The upper bound of p i The maximum value that can be taken.
[0133]
[0134] Next, the grid is divided as shown in formula (8). The parameters such as neighborhood radius and minimum sample point are expressed as p1, p2, …, p n , and divide its value range evenly into M i There are equally spaced subintervals, k = 0, 1, ..., M i ;x i,k represents the kth split point of the ith parameter.
[0135]
[0136] Then a grid search is performed to evaluate the model parameters using the loss function and obtain the optimal parameter combination, such as Figure 5 As shown. Each grid point p is an n-dimensional vector, represents the kth split point of the i-th parameter; where k j is the index of the jth parameter, that is:
[0137]
[0138] Finally, this embodiment sets different parameters corresponding to different segmentation intervals to obtain sufficient segmentation points to ensure accurate grid search, and then uses the loss function to evaluate the performance of the SNG-DBSCAN model under this parameter. The performance can be expressed by the loss function L(p (k) ), namely:
[0139]
[0140] Finally, the optimal parameter combination is obtained, as shown in formulas (11) and (12). By comparing the performance of all grid points, this embodiment can find the optimal parameter combination p * .
[0141]
[0142] The optimal parameter combination is the indicator of SNG-DBSCAN clustering, which determines the shape and size of the cluster.
[0143] After obtaining the optimal parameter combination, this embodiment can use SNG-DBSCAN to perform clustering analysis of composite strains. However, in order to obtain the clustering results more accurately and efficiently, the following will use the subsampling neighborhood graph construction method as the core of the SNG-DBSCAN improvement.
[0144] Sub-sampling neighborhood graph construction:
[0145] Sub-sampling neighborhood graph is a method for data dimensionality reduction and visualization, which combines the idea of local linear embedding and sub-sampling technology. Sub-sampling neighborhood graph is an approximation of the original data, which can process data faster. Sub-sampling neighborhood graph aims to approximate the neighborhood structure of the original high-dimensional data by constructing a low-dimensional graph, thereby helping to understand and analyze the intrinsic structure of the data. This can be used to disassemble and analyze a large number of bacterial species Raman spectroscopy data to speed up the formation of clustering results. The main process is as follows:
[0146] First, this embodiment uses composite bacterial strain data to define data points. Define data set D = {x1, x2, ..., x n}, where n = 0, 1, 2…n, each xi is an n-dimensional vector.
[0147] Then, this embodiment constructs the neighborhood. i Based on the Euclidean distance metric, this embodiment defines its neighborhood N i , neighborhood N i Contains x i The nearest neighbor of .
[0148] Next, this embodiment starts to subsample the composite strain data. In order to reduce the computational complexity and noise impact, this embodiment performs subsampling on the neighborhood N i Density-based kernel density estimation is performed to determine the density of each data point, and then samples are selected based on these density values. As shown in formula (13). h (x i ,x j ) is the kernel function, h is the bandwidth, which determines the smoothness of the kernel function. Data points are selected according to the density value. For each data point x i , calculate the probability p of being selected i As shown in formula (14). Where max(ρ(x)) is the maximum value of all data point density values. Randomly select data points from the data set, each data point x i The probability of being selected and its density value p i Directly proportional.
[0149]
[0150] In addition, this embodiment also needs to construct a neighborhood graph. i ′ YesN i A subset of, for any two points x i ,x j , if they contain each other in the sub-sampling neighborhood, an edge is constructed to connect them. As shown in formula (15). The weight of the edge is defined as w ij , exp represents a function that applies a natural exponential, and σ is a parameter that controls the decay speed of the weight. In this way, the present embodiment constructs a basic neighborhood graph.
[0151]
[0152] Finally, this embodiment reduces the dimension of the neighborhood graph. Through spectral graph theory, this embodiment can perform eigendecomposition on the Laplacian matrix of the graph and find a low-dimensional embedding. First, construct the Laplacian matrix matrix It is obtained by subtracting the adjacency matrix A from the degree matrix D. As shown in formula (16). Then, this embodiment solves the eigenvalues and eigenvectors of the Laplacian matrix L. As shown in formulas (17) and (18). After that, this embodiment selects k eigenvectors and performs low-dimensional embedding, where k is the dimension after dimensionality reduction that this embodiment hopes to achieve.
[0153]
[0154]
[0155] After constructing the sub-sampling neighborhood graph for the composite bacterial species data, the local structural information of the data is finally retained, which can provide assistance for the subsequent composite bacterial species clustering.
[0156] SNG-DBSCAN composite bacterial species clustering:
[0157] The construction of the sub-sampling neighborhood graph will initially connect the relationship between each data point in the data set. By analyzing the relationship between the data points, SNG-DBSCAN is used to accurately cluster the data points to achieve the purpose of intuitive visualization after the classification of the composite bacterial species. After the visualization results are presented, the size and shape of the clusters formed by the clustering, the density of the data points, etc. are analyzed, and the percentage of composite bacterial species in different bacterial species is statistically calculated. The statistical results are reported to the doctor, and finally a comprehensive diagnosis is made. SNG-DBSCAN is a density-based clustering algorithm that can detect the noise of the data set. Based on this, the clusters formed by core points, boundary points and noise points can be used to distinguish various bacterial species on low-dimensional data.
[0158] According to the characteristics of the SNG-DBSCAN algorithm, this embodiment divides the data set into core species and boundary species. The core species refers to the species that can form core points after core point discrimination, and the boundary species refers to the species at the edge of the core point discrimination, which cannot accurately form the core point. These points need to be further discriminated through the density reachable relationship.
[0159] The core point identification process is as follows: Figure 6 As shown, the main process includes:
[0160] First, in this embodiment, the range of clustering data points is defined as shown in formulas (19) and (20). Where D represents the strain data set, x1, x2, ..., x n , n=0,1,…,n represents the data point corresponding to each bacterial species data, ∈ represents the neighborhood radius range, d(x i ,x j ) is the point x in the metric space i and x jAccording to the parameters of the optimal neighborhood radius obtained, the data density can be controlled so that preliminary connections can be established between data points to a certain extent.
[0161] D={x1,x2,…,x n} (19)
[0162] N ∈ (x i ,∈)={x j ∈D|d(x i ,x j )<∈} (20)
[0163] Secondly, this embodiment uses the minimum number of sample points to identify the core point. If there are other data points within the neighborhood radius of the data point that are greater than the minimum number of sample points, that is, in is a natural number, then the data point is considered to be the core point, that is:
[0164] |N ∈ (x i ,∈)|>MinPts (21)
[0165] Similarly, a boundary point indicates that there are other data points within the neighborhood radius of the data point that are equal to the minimum number of sample points; a noise point indicates that there are other data points within the neighborhood radius of the data point that are less than the minimum number of sample points, that is:
[0166] |N ∈ (x i ,∈)|=MinPts (22)
[0167] |N ∈ (x i ,∈)| <MinPts (23)
[0168] Finally, in order to make the data points form clusters of specific strains, based on the density accessibility between core points, it can be judged that the data points of the same strain belong to the same cluster. As shown in formula (24), P and Q are data points, and R is the core point. That is, if P and Q are connected by a common core point R, then they belong to the same cluster.
[0169] This embodiment uses the Euclidean formula to calculate the distance between two points to determine the density accessibility between data points, as shown in formula (25). Where a and b are the coordinate vectors of the two points; a i and b i They represent the value of the i-th dimension in the coordinate vector; n represents the dimension of the coordinate vector; d(a,b) represents the distance between data point a and data point b.
[0170]
[0171] As long as any two sample points are density-reachable, the two sample points are classified into the same cluster. Finally, PCA dimensionality reduction is used to form a visual image, and the bacterial species type is intuitively obtained.
[0172] Bacteria type determination and visualization:
[0173] Since different strains have different names, this example first labels the strains after clustering with corresponding names, then calculates the silhouette coefficient and Davies-Bouldin index, and uses visualization graphics to intuitively present the effect of strain classification. Taking 16 strains for single strain separation and composite strain clustering as an example, the final effect diagram is as follows: Figure 7 shown.
[0174] In summary, this embodiment takes 16 strains for single strain separation and composite strain clustering as an example. According to the collected 110566 sample data, the experimental data is first preprocessed, and then the raw data is converted into time series data through wavelet transform, and the data is feature extracted. Then, 80% of the data is divided as a training set and 20% as a test set. The evaluation model accuracy is about 90%, which proves that the single strain separation has a high accuracy. After that, the neighborhood radius and the minimum sample point values are obtained by uniformly splitting the grid search to be 0.8 and 9 respectively. SNG-DBSCAN clustering is mainly based on these two values, and the final visualized image is obtained. After clustering is completed, the values of the silhouette coefficient and the Davies-Bouldin index are calculated, and the values are 0.507 and 0.718 respectively, to analyze the results of strain clustering. The clustering results show that the clustering effect is good, and this method can be used for the discrimination and diagnosis of composite strains. Doctors can make a comprehensive diagnosis of the specific pathogens obtained by the patient based on the percentage of strains presented at the end of the experiment and their medical knowledge. Based on the above conclusions, the composite bacterial strain detection method combining Raman spectroscopy time series analysis with machine learning showed excellent performance and high accuracy in the rapid separation and detection of bacterial strains, providing a feasible and effective solution for the efficient detection and separation of composite bacterial strains, which has broad prospects and promotion value.
[0175] The composite bacterial strain detection method combining Raman spectroscopy time series analysis with machine learning has shown excellent performance and high accuracy in rapid separation and detection of bacterial strains. Using Raman spectroscopy technology, the problem of detection speed is addressed, the efficiency of bacterial strain detection is improved, and the time cost loss is reduced; using time series analysis, an effective solution is provided for the problem of overlapping or superimposed bacterial strains, so that the bacterial strain data can be accurately analyzed, the reliability of bacterial strain data is enhanced, and the accuracy of detection is greatly improved; using machine learning algorithms, a visual bacterial strain clustering effect diagram is obtained for the problem of bacterial strain classification, the bacterial strain clustering model is optimized, and the differences between different bacterial strains are efficiently distinguished. Finally, an effective report is presented through the percentage of bacterial species, which plays an auxiliary role in detecting the pathogens obtained by patients.
[0176] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning, characterized in that: include: Collect Raman spectral data of composite bacteria; The Raman spectrum data of the composite bacteria are converted into time series data by wavelet transformation; Use the LSTM model to perform time series analysis on the time series data, and preliminarily separate the composite strains into different single strains; The preset SNG-DBSCAN algorithm was used to classify the separated single bacterial species and obtain the bacterial species category.
2. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 1 is characterized in that: The method of converting the Raman spectrum data of the composite bacteria into time series data using wavelet transform is as follows: Among them, W f,α,β (t) represents the result of continuous wavelet transform of function f(t) with specific scale parameter α and translation parameter β through specific wavelet function ψ(t). represents the square root of the scale parameter α, f(τ) represents the time domain signal to be analyzed, It represents the conjugate of the wavelet function, α represents the scale parameter, which is used to determine the width or duration of the wavelet function, β represents the translation parameter, which is used to determine the position of the wavelet function on the time axis, t represents the specific time point of the analysis signal feature to be obtained, and τ represents the integral variable.
3. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 1 is characterized in that: The method of using the LSTM model to perform time series analysis on the time series data is: i t =σ(W ix x t +W ih h t-1 +b i ) f t =σ(W fx x t +W fh h t-1 +b f ) o t =σ(W ox x t +W oh h t-1 +b o )h t =o t ⊙tanh(C t ) C t =f t ⊙C t-1 +i t ⊙tanh(W cx x t +W ch h t-1 +b c ) Among them, i t represents the input gate at time t, σ represents the nonlinear activation function, W ix and W ih Both represent the weight matrix input to the input gate, h t-1 represents the hidden state of the previous time step, x t represents the vector of wavenumber and intensity in the Raman spectrum data of the bacterial species, b i represents the bias of the input gate, f t Represented as a specific wave number or intensity in Raman spectroscopy data, W fx is the weight matrix of the forget gate, b f is the bias term of the forget gate, o t Indicates the specific wave number or intensity in Raman spectroscopy data, W ox and W oh Both represent the weight matrix of the output gate, b o represents the bias term of the output gate, tanh represents the hyperbolic tangent function, C t represents the update unit state, W cx Indicates that the input x t The weight matrix mapped to the cell state space; W ch Indicates that the hidden state h of the previous time step is t-1 The weight matrix mapped to the cell state space; b c represents the bias term of the cell state, and ⊙ represents element-wise multiplication.
4. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 1 is characterized in that: Using the preset SNG-DBSCAN algorithm, the classification of the isolated single bacterial species includes: Preprocess the Raman spectral data of the isolated single bacterial species; Perform uniformly segmented grid search on the preprocessed data to extract the optimal parameter combination; Based on the optimal parameter combination, SNG-DBSCAN cluster analysis was performed on the pre-processed data to distinguish different bacterial species.
5. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 4 is characterized in that: The preprocessing of Raman spectral data of isolated single bacterial species includes: Linear interpolation and mean filling were used to make up for the missing values in the Raman spectral data of the separated single bacterial species, and the data were standardized.
6. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 4 is characterized in that: For the preprocessed data, the uniform segmentation grid search includes: Define parameter space; Based on the parameter space, dividing the preprocessed data into grids; Search the divided grid and the initial parameter combination; The optimal parameter combination is obtained by comparing the performance of all grid points.
7. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 4 is characterized in that: Based on the optimal parameter combination, the SNG-DBSCAN cluster analysis of the preprocessed data includes: Constructing sub-sampling neighborhood graph data for the pre-processed data; Based on the optimal parameter combination, the sub-sampling neighborhood graph data is clustered to obtain bacterial species types.
8. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 7 is characterized in that: For the preprocessed data, constructing sub-sampling neighborhood graph data includes: defining data points for the preprocessed data, and constructing domain data for the data points; Performing density-based kernel density estimation on the domain data to determine the density value of each of the data points, and then selecting sample data points according to the density value; The sub-sampled neighborhood graph data is constructed for the sample data points, and the sub-sampled neighborhood graph data is reduced in dimension to obtain Laplace data of the neighborhood graph.
9. The composite bacterial strain detection method based on Raman spectroscopy time series analysis combined with machine learning according to claim 8, characterized in that: Clustering the sub-sampling neighborhood graph data to obtain bacterial species types includes: Input the optimal parameter combination into the SNG-DBSCAN algorithm; Based on the SNG-DBSCAN algorithm after inputting the optimal parameter combination, the Laplace data of the neighborhood graph is divided into core bacterial species and boundary bacterial species using the Laplace matrix; wherein the core bacterial species are bacterial species that can form core points after core point discrimination, and the boundary bacterial species represent bacterial species at the edge of core point discrimination; Based on the core strain data and the boundary strain data, the data points of the same strain are grouped into the same cluster using the density accessibility between the core points to obtain the strain type.