Cell type annotation method and device based on neural network, medium and equipment
By adopting a neural network-based cell type annotation method in single-cell data annotation, combining attention mechanism networks and multiple loss functions, the problems of insufficient label migration and lack of explanatory nature in the prior art are solved, and efficient, accurate and interpretable cell type annotation are achieved.
Patent Information
- Application Number
- CN202411940138.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-08
AI Technical Summary
Existing single-cell data annotation methods have problems with insufficient label migration when dealing with diversified data sets, especially in the case of strong heterogeneity and large modal differences, which lead to "zero expansion" and high noise problems of the data, and lack of explanatory nature.
The cell type annotation method based on neural network is adopted to train cell feature gene vectors through feature extractors and classifiers, and the model parameters are optimized in combination with attention mechanism networks and multiple loss functions (such as cross entropy, regularization, contrast learning, modal alignment and sparse center loss), and efficient label migration across modal and experimental conditions is achieved.
It improves the accuracy and credibility of cell type annotation, enhances the interpretability of the model, and can effectively process scRNA-seq and scATAC-seq data, significantly improving the annotation effect of data sets with strong heterogeneity and large modal differences.
Smart Images

Figure CN119785895A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the application technology of deep neural network in the field of bioinformatics cell type annotation. Background Art
[0002] With the rapid development of single-cell sequencing technology, single-cell RNA sequencing and single-cell ATAC sequencing have become important means to explore the genomic information of individual cells. These technologies allow researchers to deeply analyze gene expression patterns and chromatin accessibility, thereby revealing the functions of cells under different states and conditions. In single-cell data analysis, cell type annotation is a crucial step that directly affects the reliability of subsequent biological conclusions. Therefore, accurate annotation of cell types helps scientists to have a deeper understanding of the functions of cells and their roles in physiological and pathological processes, revealing the interactions between cells and their dynamic changes in complex systems. In addition, this is of great significance for exploring the mechanisms of disease occurrence, identifying potential biomarkers, and developing personalized treatment plans. In the field of precision medicine, accurate cell type annotation can help build more detailed disease models, thereby supporting drug development and clinical decision-making, and improving the accuracy and effectiveness of diagnosis and treatment.
[0003] There are two main strategies for single-cell annotation: 1) Clustering based on expression patterns: cluster cells according to gene expression patterns, and then assign each cluster to a known cell type based on specific marker genes; 2) Label migration based on reference datasets: migrate labels from annotated data to query datasets to achieve automated annotation. Most of the current single-cell data analysis methods, such as scGPT, scBERT, and itClust, focus on label migration of scRNA-seq data. Algorithms suitable for scATAC-seq data, such as Cellcano and EpiAnno. These methods have achieved satisfactory results in their respective tasks, but due to the heterogeneity between reference datasets and query datasets, there are still some challenges to overcome, including batch effects of scRNA-seq datasets from different protocols (cell type annotations of scRNA-seq), which often lead to "zero inflation" in scRNA-seq data; batch effects and modality differences of scATAC-seq datasets from different experiments (cell type annotations of scATAC-seq), which lead to sparsity and high noise in scATAC-seq data. Moreover, most of the current cell type annotation models are "black box" models, which use complex machine learning algorithms to generate prediction results and lack clear explanations. This leads users to doubt the credibility of the results, limits the widespread application of these models in scientific research, and thus weakens their value in research.
[0004] The latest research shows that deep metric learning maps data to an embedding space through a neural network, in which similar samples are brought closer together and samples of different types are pushed apart. The purpose of domain adaptation is to map data from source and target domains with different distributions into a feature space so that their distances in the space are as close as possible. Therefore, the objective function trained on the source domain in the feature space can be transferred to the target domain to improve the accuracy on the target domain. In this context, developing appropriate domain adaptation and deep metric learning models to reduce modal differences and batch effects of data, optimize the structure of the embedding space, and enhance interpretability to improve the accuracy of cell type annotations is of great significance for analyzing single-cell data. Summary of the invention
[0005] Problem to be solved by the present invention: Insufficiency in label migration between diverse data sets.
[0006] To solve the above problems, the solution adopted by the present invention is as follows: According to the neural network-based cell type annotation method of the present invention, the method includes a model training step and a type annotation step; the model training step is used to convert cell sequencing data of known cell types into cell characteristic gene vectors as input of the cell type annotation model to train the cell type annotation model; the type annotation step is used to convert cell sequencing data into cell characteristic gene vectors as input of the cell type annotation model, and the cell type to which the cell type to be determined belongs is marked by the cell type annotation model; The cell sequencing data is RNA sequencing data or ATAC sequencing data; The cell characteristic gene vector is a vector composed of expression values of M pre-set characteristic genes of the cell; The RNA sequencing data is converted into a cell characteristic gene vector: the expression amounts of characteristic genes are selected from the RNA sequencing data to form a cell characteristic gene vector of M dimensions; The ATAC sequencing data is converted into a cell characteristic gene vector: according to the known relationship between chromatin accessibility and gene expression, the chromatin openness state data corresponding to the characteristic gene is extracted from the ATAC sequencing data and mapped into the expression amount of the characteristic gene, thereby obtaining an M-dimensional cell characteristic gene vector; The cell type annotation model includes a feature extractor and a classifier; the feature extractor is a fully connected linear layer network with the cell feature gene vector as input and the KM-dimensional vector as output; the classifier is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the K-dimensional vector as output; the K-dimensional vector output by the classifier is used to represent the probability values of K types of cell types; The model training step includes a training model initialization step, a sample preparation step and a sample training step; The training model initialization step: initializing the training model; the training model includes a cell type annotation model and an attention mechanism network; The attention mechanism network is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the KM-dimensional vector as output; the KM-dimensional vector output by the attention mechanism network is the attention weight vector; The sample preparation step comprises: converting the cell sequencing data set of known cell types and the cell sequencing data set of unknown cell types into cell characteristic gene vectors to form a training sample set and a test sample set respectively; The sample training step includes a batch sample preparation step, a batch model execution step, and a loss calculation and model optimization adjustment step; The batch sample preparation step: randomly selecting sizeB training samples and sizeB test samples from the training sample set and the test sample set to form a training sample batch set and a test sample batch set; then calculating the corresponding positive sample and negative sample for each cell feature gene vector in the test sample batch set; wherein, The training sample batch set is represented as XR={{xr(i),yr(xr(i))}|i∈[1..sizeB]}; The test sample batch set is represented as XQ={xq(i)|i∈[1..sizeB]}; where, xr(i) represents the i-th cell feature gene vector in the training sample batch set; xq(i) represents the i-th cell characteristic gene vector in the test sample batch set; yr(xr(i)) represents the numerical label of the known cell type corresponding to the cell characteristic gene vector xr(i), ranging from 1 to K; The positive sample is the closest cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i); The negative sample is a random cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i) except the closest one; The nearest neighbors of the cell characteristic gene vector xq(i) are the neighboring cell characteristic gene vectors of the k cell characteristic gene vectors xq(i) found from the test sample batch set by the nearest neighbor algorithm; The batch model execution step: inputting each cell characteristic gene vector in the training sample batch set and the test sample batch set into the cell type annotation model for execution, and collecting intermediate data and output generated during the execution of the cell type annotation model; The loss calculation and model optimization adjustment step: according to the intermediate data and output collected during the execution of the cell type annotation model, combined with the numerical labels of the known cell types of the training samples, the loss coefficient is calculated, and then the model parameters of the cell type annotation model are adjusted by gradient descent and back propagation; wherein, The loss coefficient is calculated according to the following formula: L_Total=Lce+0.1*Lpr+a1*Lcl+a2*Lfa+a3*Lsc; L_Total is the loss coefficient; a1, a2, and a3 are balance coefficients for different loss values; Lce is the cross entropy loss value, Lpr is the regularization loss value, Lcl is the contrastive learning loss value, Lfa is the modality alignment loss value, and Lsc is the sparse center loss value; where, Lce=avg({ln(Mo(xr(i),yr(xr(i))))|i∈[1..sizeB]}); Lpr=mulinv(avg({sum({abs((To(xq(i),j)-avgTo(XQ,j))|j∈[1..KM]})|i∈[1..sizeB]}) +avg({abs(corr(To(xq(i)),To(xq(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(corr(To(xr(i)),To(xr(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(avgTo(XR,j))|j∈[1..KM]})+avg({abs(avgTo(XQ,j))|j∈[1..KM]}); Lcl=﹣avg({ln(epos(xq(j)) / (epos(xq(j))+sum({eneg(xq(i))|i∈[1..sizeB]}))) | j∈[1..sizeB]}); Lfa= -avg({cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB],cos(To(xr(i)),To(xq(j)))>hc}); Lsc = avg({sum({aw(xb(i),j)*square(To(xb(i),j)-Cx(y(xb(i)),j)))|j∈[1..KM]})|i∈[1..2*sizeB]}); in, epos(xq(j))=exp(sim(To(xq(j)),To(pos(xq(j))))) / Tv); eneg(xq(i))=exp(sim(To(xq(i)),To(neg(xq(i))))) / Tv); Cx(y(i),j)=avg({To(xb(k),j)|Mo(xb(k))=y(xb(i)), k∈[1..2*sizeB]}); where, xb(i) represents the i-th cell characteristic gene vector of the xb set; The xb set is a cell characteristic gene vector composed of each cell characteristic gene vector of the training sample batch set and each cell characteristic gene vector of the test sample batch set; avg and sum represent the mean and sum of the values in a set of values respectively; ln means natural logarithm; exp means the power of a natural constant; mulinv means reciprocal; abs means absolute value; square means square; sim represents the similarity between two vectors; cos represents the cosine similarity between two vectors; corr represents the Pearson correlation coefficient between two vectors; Mo is the functional representation of the cell type annotation model; To is the functional representation of the feature extractor; aw is the functional representation of the attention mechanism network; avgTo represents the average output of the feature extractor; Mo(xb(k)) represents the output vector after the cell characteristic gene vector xb(k) is input into the cell type annotation model; Mo(xr(i),yr(xr(i))) represents the value of the yr(xr(i))th element of the output vector after the cell characteristic gene vector xr(i) is input into the cell type annotation model for execution; To(xq(i)), To(xq(j)), To(xr(i)), To(xr(j)), To(pos(xq(j))), To(neg(xq(i))) respectively represent the vectors output by the feature extractor after the cell characteristic gene vectors xq(i), xq(j), xr(i), xr(j), pos(xq(j)), neg(xq(i)) are respectively input into the cell type annotation model for execution; To(xq(i),j), To(xb(i),j), To(xb(k),j) respectively represent the j-th element value of the vector output by the feature extractor after the cell characteristic gene vectors xq(i), xb(i), xb(k) are input into the cell type annotation model for execution; aw(xb(i),j) represents the jth component of the attention weight vector output by the attention mechanism network after the cell feature gene vector xb(k) is input into the cell type annotation model for execution; avgTo(XQ,j) and avgTo(XR,j) respectively represent the average value of the jth element of the vector output by the feature extractor after the characteristic gene vectors of each cell in the test sample batch set XQ and the training sample batch set XR are input into the cell type annotation model for execution; pos represents positive samples; neg represents negative samples; pos(xq(j)) and neg(xq(i)) represent the positive sample of the cell feature gene vector xq(j) and the negative sample of xq(i), respectively; {cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB], cos(To(xr(i)),To(xq(j)))>hc} means that after any cell feature gene vector in the training sample batch set and any cell feature gene vector in the test sample batch set are respectively input into the cell type annotation model for execution, the cosine similarity of the corresponding two vectors output by the feature extractor is greater than the cosine similarity set composed of hc; hc is a preset constant; Cx(y(xb(i)),j) represents the j-th element mean of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the cell type annotation model; {To(xb(k),j)|Mo(xb(k))=y(xb(i)),k∈[1..2*sizeB]} represents the numerical set composed of the j-th element value of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the feature gene vector of each cell in the xb set after being input into the cell type annotation model for execution; wherein, y(xb(i)) represents the numerical label of the cell type corresponding to the cell characteristic gene vector xb(i). If the cell characteristic gene vector xb(i) comes from the training sample batch set, then y(xb(i))=yr(xb(i)); otherwise, y(xb(i))=indexOfmax(Mo(xb(i))); where, indexOfmax(Mo(xb(i))) represents the index of the largest element value in the output vector after the cell characteristic gene vector xb(i) is input into the cell type annotation model for execution; In the type annotation step, the index of the largest element value in the output vector after the cell type annotation model is executed is used as the cell type to which the cell belongs.
[0007] Further, according to the cell type annotation method of the present invention, the feature extractor and the classifier are both single linear layer networks; the feature extractor uses the ReLU function as the activation function, and the classifier uses the softmax function as the activation function; the attention mechanism network includes a hidden linear layer composed of KM neurons with the Tanh function as the activation function and an output layer composed of 2*KM neurons with the softmax function as the activation function; the 2*KM-dimensional vectors output by the output layer of the attention mechanism network are arranged into a KM-dimensional double-valued vector, and then the second value of the double value of each dimension is taken from the KM-dimensional double-valued vector to form a KM-dimensional attention weight vector.
[0008] Further, according to the cell type annotation method of the present invention, the contrastive learning loss value, modal alignment loss value, and sparse center loss value are calculated only after the sample training loss calculation step and the model parameter adjustment step are executed more than the corresponding round limit, otherwise the value is 0.
[0009] Further, according to the cell type annotation method of the present invention, sim similarity calculation is calculated using the cosine similarity calculation formula.
[0010] According to the cell type annotation device based on neural network of the present invention, the device comprises a model training module and a type annotation module; the model training module is used to convert cell characteristic gene vectors into cell characteristic gene vectors as input of the cell type annotation model according to cell sequencing data of known cell types to train the cell type annotation model; the type annotation module is used to convert cell characteristic gene vectors into cell characteristic gene vectors as input of the cell type annotation model according to cell sequencing data, and the cell type to which the cell type to be determined belongs is marked by the cell type annotation model; The cell sequencing data is RNA sequencing data or ATAC sequencing data; The cell characteristic gene vector is a vector composed of expression values of M pre-set characteristic genes of the cell; The RNA sequencing data is converted into a cell characteristic gene vector: the expression amounts of characteristic genes are selected from the RNA sequencing data to form a cell characteristic gene vector of M dimensions; The ATAC sequencing data is converted into a cell characteristic gene vector: according to the known relationship between chromatin accessibility and gene expression, the chromatin openness state data corresponding to the characteristic gene is extracted from the ATAC sequencing data and mapped into the expression amount of the characteristic gene, thereby obtaining an M-dimensional cell characteristic gene vector; The cell type annotation model includes a feature extractor and a classifier; the feature extractor is a fully connected linear layer network with the cell feature gene vector as input and the KM-dimensional vector as output; the classifier is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the K-dimensional vector as output; the K-dimensional vector output by the classifier is used to represent the probability values of K types of cell types; The model training module includes a training model initialization module, a sample preparation module and a sample training module; The training model initialization module is used to: initialize the training model; the training model includes a cell type annotation model and an attention mechanism network; The attention mechanism network is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the KM-dimensional vector as output; the KM-dimensional vector output by the attention mechanism network is the attention weight vector; The sample preparation module is used to: form a training sample set and a test sample set respectively by converting the cell sequencing data set of known cell types and the cell sequencing data set of unknown cell types into cell characteristic gene vectors; The sample training module includes a batch sample preparation module, a batch model execution module, and a loss calculation and model optimization adjustment module; The batch sample preparation module is used to: randomly select sizeB training samples and sizeB test samples from the training sample set and the test sample set to form a training sample batch set and a test sample batch set; then calculate the corresponding positive sample and negative sample for each cell feature gene vector in the test sample batch set; wherein, The training sample batch set is represented as XR={{xr(i),yr(xr(i))}|i∈[1..sizeB]}; The test sample batch set is represented by XQ={xq(i)|i∈[1..sizeB]}; where, xr(i) represents the i-th cell feature gene vector in the training sample batch set; xq(i) represents the i-th cell characteristic gene vector in the test sample batch set; yr(xr(i)) represents the numerical label of the known cell type corresponding to the cell characteristic gene vector xr(i), ranging from 1 to K; The positive sample is the closest cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i); The negative sample is a random cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i) except the closest one; The nearest neighbors of the cell characteristic gene vector xq(i) are the neighboring cell characteristic gene vectors of the k cell characteristic gene vectors xq(i) found from the test sample batch set by the nearest neighbor algorithm; The batch model execution module is used to: input each cell characteristic gene vector in the training sample batch set and the test sample batch set into the cell type annotation model for execution, and collect intermediate data and output generated during the execution of the cell type annotation model; The loss calculation and model optimization adjustment module is used to: calculate the loss coefficient based on the intermediate data and output collected during the execution of the cell type annotation model, combined with the numerical labels of the known cell types of the training samples, and then adjust the model parameters of the cell type annotation model through gradient descent and back propagation; wherein, The loss coefficient is calculated according to the following formula: L_Total=Lce+0.1*Lpr+a1*Lcl+a2*Lfa+a3*Lsc; L_Total is the loss coefficient; a1, a2, and a3 are balance coefficients for different loss values; Lce is the cross entropy loss value, Lpr is the regularization loss value, Lcl is the contrastive learning loss value, Lfa is the modality alignment loss value, and Lsc is the sparse center loss value; where, Lce=avg({ln(Mo(xr(i),yr(xr(i))))|i∈[1..sizeB]}); Lpr=mulinv(avg({sum({abs((To(xq(i),j)-avgTo(XQ,j))|j∈[1..KM]})|i∈[1..sizeB]}) +avg({abs(corr(To(xq(i)),To(xq(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(corr(To(xr(i)),To(xr(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(avgTo(XR,j))|j∈[1..KM]})+avg({abs(avgTo(XQ,j))|j∈[1..KM]}); Lcl=﹣avg({ln(epos(xq(j)) / (epos(xq(j))+sum({eneg(xq(i))|i∈[1..sizeB]}))) | j∈[1..sizeB]}); Lfa= -avg({cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB],cos(To(xr(i)),To(xq(j)))>hc}); Lsc = avg({sum({aw(xb(i),j)*square(To(xb(i),j)-Cx(y(xb(i)),j)))|j∈[1..KM]})|i∈[1..2*sizeB]}); in, epos(xq(j))=exp(sim(To(xq(j)),To(pos(xq(j))))) / Tv); eneg(xq(i))=exp(sim(To(xq(i)),To(neg(xq(i))))) / Tv); Cx(y(i),j)=avg({To(xb(k),j)|Mo(xb(k))=y(xb(i)), k∈[1..2*sizeB]}); where, xb(i) represents the i-th cell characteristic gene vector of the xb set; The xb set is a cell characteristic gene vector composed of each cell characteristic gene vector of the training sample batch set and each cell characteristic gene vector of the test sample batch set; avg and sum represent the mean and sum of the values in a set of values respectively; ln means natural logarithm; exp means the power of a natural constant; mulinv means reciprocal; abs means absolute value; square means square; sim represents the similarity between two vectors; cos represents the cosine similarity between two vectors; corr represents the Pearson correlation coefficient between two vectors; Mo is the functional representation of the cell type annotation model; To is the functional representation of the feature extractor; aw is the functional representation of the attention mechanism network; avgTo represents the average output of the feature extractor; Mo(xb(k)) represents the output vector after the cell characteristic gene vector xb(k) is input into the cell type annotation model; Mo(xr(i),yr(xr(i))) represents the value of the yr(xr(i))th element of the output vector after the cell characteristic gene vector xr(i) is input into the cell type annotation model for execution; To(xq(i)), To(xq(j)), To(xr(i)), To(xr(j)), To(pos(xq(j))), To(neg(xq(i))) respectively represent the vectors output by the feature extractor after the cell characteristic gene vectors xq(i), xq(j), xr(i), xr(j), pos(xq(j)), neg(xq(i)) are respectively input into the cell type annotation model for execution; To(xq(i),j), To(xb(i),j), To(xb(k),j) respectively represent the j-th element value of the vector output by the feature extractor after the cell characteristic gene vectors xq(i), xb(i), xb(k) are input into the cell type annotation model for execution; aw(xb(i),j) represents the jth component of the attention weight vector output by the attention mechanism network after the cell feature gene vector xb(k) is input into the cell type annotation model for execution; avgTo(XQ,j) and avgTo(XR,j) respectively represent the average value of the jth element of the vector output by the feature extractor after the characteristic gene vectors of each cell in the test sample batch set XQ and the training sample batch set XR are input into the cell type annotation model for execution; pos represents positive samples; neg represents negative samples; pos(xq(j)) and neg(xq(i)) represent the positive sample of the cell feature gene vector xq(j) and the negative sample of xq(i), respectively; {cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB], cos(To(xr(i)),To(xq(j)))>hc} means that after any cell feature gene vector in the training sample batch set and any cell feature gene vector in the test sample batch set are respectively input into the cell type annotation model for execution, the cosine similarity of the corresponding two vectors output by the feature extractor is greater than the cosine similarity set composed of hc; hc is a preset constant; Cx(y(xb(i)),j) represents the j-th element mean of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the cell type annotation model; {To(xb(k),j)|Mo(xb(k))=y(xb(i)),k∈[1..2*sizeB]} represents the numerical set composed of the j-th element value of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the feature gene vector of each cell in the xb set after being input into the cell type annotation model for execution; wherein, y(xb(i)) represents the numerical label of the cell type corresponding to the cell characteristic gene vector xb(i). If the cell characteristic gene vector xb(i) comes from the training sample batch set, then y(xb(i))=yr(xb(i)); otherwise, y(xb(i))=indexOfmax(Mo(xb(i))); where, indexOfmax(Mo(xb(i))) represents the index of the largest element value in the output vector after the cell characteristic gene vector xb(i) is input into the cell type annotation model for execution; The type annotation module uses the index with the largest element value in the output vector after the cell type annotation model is executed as the cell type to which the cell belongs.
[0011] Further, according to the cell type annotation device of the present invention, the feature extractor and the classifier are both single linear layer networks; the feature extractor uses the ReLU function as the activation function, and the classifier uses the softmax function as the activation function; the attention mechanism network includes a hidden linear layer composed of KM neurons with the Tanh function as the activation function and an output layer composed of 2*KM neurons with the softmax function as the activation function; the 2*KM-dimensional vectors output by the output layer of the attention mechanism network are arranged into a KM-dimensional double-valued vector, and then the second value of the double value of each dimension is taken from the KM-dimensional double-valued vector to form a KM-dimensional attention weight vector.
[0012] Further, according to the cell type annotation device of the present invention, the contrastive learning loss value, modal alignment loss value, and sparse center loss value are calculated only after the sample training loss calculation module and the model parameter adjustment module are executed more than the corresponding round limit, otherwise the value is 0.
[0013] Further, according to the cell type annotation device of the present invention, the sim similarity calculation is calculated using the cosine similarity calculation formula, and the KM value is 64.
[0014] According to a machine-readable medium of the present invention, a program instruction set that can be read by a machine is stored in the medium. When the program instruction set stored in the medium is read and executed by a machine, the machine can implement the above-mentioned neural network-based cell type annotation method.
[0015] According to an electronic device of the present invention, the device includes a connected processor and a memory; a program instruction set is stored in the memory; when the processor loads the program instruction set stored in the memory and executes it, the device can implement the above-mentioned neural network-based cell type annotation method.
[0016] The technical effects of the present invention are as follows: The method of the present invention can be applied to different single-cell data scenarios to achieve efficient cell type annotation; Different from the traditional black box model, the method of the present invention integrates an explanatory module and uses the integral gradient method to explain the prediction results of the model, thereby improving the credibility and transparency of the model; The method of the present invention can process not only scRNA-seq data, but also scATAC-seq data, supports cross-modality and cross-experimental condition data analysis, and has wide applicability; The present invention can achieve efficient label migration, especially between data sets with strong heterogeneity and large modality differences, showing significant advantages. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 4 is a flow chart of a cell type annotation method according to an embodiment of the present invention.
[0018] Figure 2 It is a schematic structural diagram of an electronic device embodiment of the present invention. DETAILED DESCRIPTION
[0019] The present invention is further described in detail below with reference to the accompanying drawings.
[0020] FIG2 illustrates an electronic device, which is a general-purpose computer device of von Neumann type, and at least includes a connected processor 201 and a memory 202. The memory 202 is used to store a computer program instruction set and data. The processor 201 implements the neural network-based cell type annotation method referred to in the present invention by loading and executing the computer program instruction set stored in the memory 202. The memory 202 is also the machine-readable medium referred to in the present invention, which is usually a sustainable storage device, including but not limited to disks, tapes, solid-state hard drives, etc.
[0021] The neural network-based cell type annotation method of the present invention includes a model training step and a type annotation step. The model training step is used to convert cell sequencing data of known cell types into cell characteristic gene vectors as input of the cell type annotation model to train the cell type annotation model; the type annotation step is used to convert cell sequencing data into cell characteristic gene vectors as input of the cell type annotation model, and the cell type annotation model is used to execute the output as a cell type to be determined to mark the cell type to which it belongs. Figure 1 As shown, the process represented by the solid arrow is the model training step, and the process represented by the dotted arrow is the type annotation step. The input of the model training step is the cell sequencing data of the cell type to be determined; the input of the model training step is the training sample data. The training sample data includes a portion of cell sequencing data of known cell types and some cell sequencing data of unknown cell types used for training verification. The cell sequencing data here can also be referred to as gene sequencing data, which can be RNA sequencing data or ATAC sequencing data. In this embodiment, the training sample data comes from data disclosed on the Internet, such as downloaded from the 10x website https: / / www.10xgenomics.com / datasets.
[0022] Cell sequencing data needs to be Figure 1 The step S100 shown is converted into a cell characteristic gene vector. For RNA sequencing data, when the RNA sequencing data is converted into a cell characteristic gene vector, the expression amount of the characteristic gene is selected from the RNA sequencing data to form an M-dimensional cell characteristic gene vector; for ATAC sequencing data, the ATAC sequencing data is converted into a cell characteristic gene vector: according to the known relationship between chromatin accessibility and gene expression, the chromatin openness state data corresponding to the characteristic gene is extracted from the ATAC sequencing data and mapped to the expression amount of the characteristic gene, thereby obtaining an M-dimensional cell characteristic gene vector. The cell characteristic gene vector is an M-dimensional vector, which is a vector composed of the expression amounts of M pre-set characteristic genes of the cell. That is, the characteristic gene is M pre-selected genes. Therefore, M is the number of characteristic genes. Specifically in this embodiment, the highly variable genes are screened out as characteristic genes from the cell sequencing data downloaded from the Internet by the Seurat v3 algorithm. How to select characteristic genes is not the content that needs to be discussed in the present invention, and this specification does not need to be elaborated. In this embodiment, the number of characteristic genes M is preferably 2000. In other optional implementations, the number of characteristic genes M may also be other numbers, for example, M may be 4000 or 5000.
[0023] In order to make the cell characteristic gene vector better match the input of the cell type annotation model. In this embodiment, when the cell sequencing data is converted into the cell characteristic gene vector, the gene expression is also normalized and log1p processed. The normalization and log1p processing are achieved by calling the normalize_total function and log1p function of the scanpy tool.
[0024] The cell type annotation model is a deep neural network, namely Figure 1 SM0 in the example includes a feature extractor SM01 and a classifier SM02. The feature extractor is a fully connected linear layer network with a cell characteristic gene vector as input and a KM-dimensional vector as output. The feature extractor inputs an M-dimensional cell characteristic gene vector, and the output KM-dimensional vector is called a coded feature vector. The classifier is a fully connected linear layer network with a K-dimensional vector output by the feature extractor as input and a K-dimensional vector as output. The classifier inputs a KM-dimensional coded feature vector, and the output is a K-dimensional vector used to represent the probability values of K cell types as cell type probability data.
[0025] In this embodiment, both the feature extractor and the classifier are single-linear layer networks. That is, the feature extractor is a fully connected linear layer including KM neural units, and the classifier is a fully connected linear layer including K neurons. The full connection here means that the input of each neural unit is the output of the previous layer. The feature extractor uses the ReLU function as the activation function, and the classifier uses the softmax function as the activation function. The dimension number KM of the encoded feature vector is 64. The number of cell types K output by the classifier is 12. In another optional embodiment, the feature extractor and the classifier are also configured as a multi-layer structure. For example, the feature extractor is configured as a two-layer full linear network: a hidden layer including 512 neurons and an output layer including 128 neurons. At this time, the dimension number KM of the encoded feature vector output by the feature extractor is 128; the classifier is also configured as a two-layer full linear layer network: a hidden layer including 48 neurons and an output layer including 16 neurons. At this time, the classifier outputs a 16-dimensional vector corresponding to 16 cell types. The number of cell types K output by the classifier usually depends on the number of existing known cell types. Taking into account the possible existence of some unknown types of cell types, the number of cell types K output by the classifier may also be greater than the number of currently known cell types.
[0026] The type annotation step includes the model initialization step, the cell characteristic gene vector conversion step, the model execution step and the cell type determination step, which correspond to Figure 1 The steps SN0, SN1, SN2 and SN3 are: Step SN0: Initialize the cell type annotation model and load the trained model parameter data during initialization; Step SN1: when cell sequencing data of a cell type to be determined is received, the received cell sequencing data is converted into a cell gene feature vector through the aforementioned step S100; Step SN2: Input the cell gene feature vector converted in step SN1 into the cell type annotation model for execution, and output cell type probability data; Step SN3: Determine the cell type based on the cell type probability data output by the cell type annotation model.
[0027] In step SN3, the method for determining the cell type can be expressed as a mathematical formula: typeOfCell(xi)=indexOfmax(Mo(xi)); where typeOfCell(xi) represents the cell type of the cell gene feature vector xi; Mo is a functional representation of the cell type annotation model; Mo(xi) is a K-dimensional vector representing cell type probability data output after the cell gene feature vector xi is input into the cell type annotation model for execution; indexOfmax represents the index with the largest element value in a vector or set. For example, Mo(xi) can be represented as the set {pt(i)|i∈[1..K]}, where pt(i) represents the probability value of cell type i. If the maximum value in the set {pt(i)|i∈[1..K]} is pt(m) and the index is m, then indexOfmax({pt(i)|i∈[1..K]})=m.
[0028] The model training steps include training initialization step and sample training step, corresponding to Figure 1 Steps ST1 and ST2 in the training. The training initialization step includes a training model initialization step and a sample preparation step, which correspond to Figure 1 Steps ST11 and ST12 in .
[0029] Step ST11: Initialize the training model; the training model includes a cell type annotation model and an attention mechanism network; Step ST12: Based on the cell sequencing data set of known cell types and the cell sequencing data set of unknown cell types, the cell sequencing data are converted into cell characteristic gene vectors to form a training sample set and a test sample set respectively.
[0030] The attention mechanism network is Figure 1SM2 in the figure is connected to the feature extractor, and is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the KM-dimensional vector as output. Specifically in this embodiment, the attention mechanism network includes a hidden linear layer composed of KM neurons with the Tanh function as the activation function and an output layer composed of 2*KM neurons with the softmax function as the activation function. The 2*KM-dimensional vectors output by the output layer of the attention mechanism network are arranged into a KM-dimensional double-valued vector, and then the second value of the double value of each dimension is taken from the KM-dimensional double-valued vector to form a KM-dimensional attention weight vector.
[0031] The cell type annotation model is connected to the attention mechanism network during training to calculate the loss coefficient and optimize the convergence direction and convergence speed of the model parameters. In order to optimize the convergence process of the cell type annotation model training, in addition to connecting the attention mechanism network, each linear layer in the cell type annotation model is also added with batch normalization and Dropout processing.
[0032] In the present invention, the data samples for model training are divided into training samples and test samples. Among them, the training samples are cell sequencing data with known cell types; and the test samples are cell sequencing data with unknown cell types. In this embodiment, the cell sequencing data of known cell types comes from RNA sequencing data, and the cell sequencing data of unknown cell types comes from ATAC sequencing data. The training samples constitute the training sample set, and the test samples constitute the test sample set.
[0033] The sample training step is a loop step, including the training loop control step and the round training step in the loop body. Figure 1 The training cycle control step controls the number of round training step executions by counting the number of round training step executions by a counter. More specifically, the training cycle control step stops when the number of round training step executions exceeds a preset limit. The preset limit is also referred to as the number of rounds of cyclic training. In this embodiment, the number of rounds of cyclic training is preferably 20,000. The round training step includes a batch sample preparation step, a batch model execution step, and a loss calculation and model optimization adjustment step, which correspond to Figure 1 Steps ST21, ST22 and ST23 in: Step ST21: randomly select sizeB training samples and sizeB test samples from the training sample set and the test sample set to form a training sample batch set and a test sample batch set; then calculate the corresponding positive sample and negative sample for each cell feature gene vector in the test sample batch set; Step ST22: inputting each cell characteristic gene vector in the training sample batch set and the test sample batch set into the cell type annotation model for execution, and collecting the intermediate data and output generated during the execution of the cell type annotation model; Step ST23: Based on the intermediate data and output collected during the execution of the cell type annotation model, combined with the numerical labels of the known cell types of the training samples, the loss coefficient is calculated, and then the model parameters of the cell type annotation model are adjusted through gradient descent and back propagation.
[0034] In the present invention, the training sample batch set and the test sample batch set are respectively represented as XR={{xr(i),yr(xr(i))}|i∈[1..sizeB]} and XQ={xq(i)|i∈[1..sizeB]}. Where, XR represents the training sample batch set; XQ represents the test sample batch set; xr(i) represents the i-th cell feature gene vector in the training sample batch set; xq(i) represents the i-th cell characteristic gene vector in the test sample batch set; yr(xr(i)) represents the numerical label of the known cell type corresponding to the cell characteristic gene vector xr(i), ranging from 1 to K.
[0035] In the training sample batch set, {xr(i), yr(xr(i))} constitutes the training sample; in the test sample batch set, xq(i) is the test sample. In this embodiment, sizeB is preferably 512. Those skilled in the art will appreciate that sizeB may also be set to other values, such as 256, 128, etc.
[0036] Both positive samples and negative samples are cell characteristic gene vectors. Among them, the positive sample is the closest cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i); the negative sample is a random cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i) except the closest one. The neighbors of the cell characteristic gene vector xq(i) are the neighboring cell characteristic gene vectors of the k cell characteristic gene vectors xq(i) found from the test sample batch set by the nearest neighbor algorithm. It should be pointed out that the calculation of positive and negative samples in this embodiment is limited to the calculation of the test sample batch set. In the present invention, positive and negative samples are represented by pos and neg: pos(xq(i)) represents the positive sample of the cell characteristic gene vector xq(i); neg(xq(i)) represents the negative sample of the cell characteristic gene vector xq(i).
[0037] In step ST23, the loss coefficient is calculated according to the following formula: L_Total=Lce+0.1*Lpr+a1*Lcl+a2*Lfa+a3*Lsc; L_Total is the loss coefficient; a1, a2, and a3 are balance coefficients for different loss values; Lce is the cross entropy loss value, Lpr is the regularization loss value, Lcl is the contrastive learning loss value, Lfa is the modality alignment loss value, and Lsc is the sparse center loss value; where, Lce=avg({ln(Mo(xr(i),yr(xr(i))))|i∈[1..sizeB]}); Lpr=mulinv(avg({sum({abs((To(xq(i),j)-avgTo(XQ,j))|j∈[1..KM]})|i∈[1..sizeB]}) +avg({abs(corr(To(xq(i)),To(xq(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(corr(To(xr(i)),To(xr(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(avgTo(XR,j))|j∈[1..KM]})+avg({abs(avgTo(XQ,j))|j∈[1..KM]}); Lcl=﹣avg({ln(epos(xq(j)) / (epos(xq(j))+sum({eneg(xq(i))|i∈[1..sizeB]}))) | j∈[1..sizeB]}); Lfa= -avg({cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB],cos(To(xr(i)),To(xq(j)))>hc}); Lsc = avg({sum({aw(xb(i),j)*square(To(xb(i),j)-Cx(y(xb(i)),j)))|j∈[1..KM]})|i∈[1..2*sizeB]}); in, epos(xq(j))=exp(sim(To(xq(j)),To(pos(xq(j))))) / Tv); eneg(xq(i))=exp(sim(To(xq(i)),To(neg(xq(i))))) / Tv); Cx(y(i),j)=avg({To(xb(k),j)|Mo(xb(k))=y(xb(i)), k∈[1..2*sizeB]}); where, xb(i) represents the i-th cell characteristic gene vector of the xb set; The xb set is a cell feature gene vector composed of each cell feature gene vector of the training sample batch set and each cell feature gene vector of the test sample batch set; avg and sum represent the mean and sum of the values in a set of values respectively; ln means natural logarithm; exp means the power of a natural constant; mulinv means reciprocal; abs means absolute value; square means square; sim represents the similarity between two vectors; cos represents the cosine similarity between two vectors; corr represents the Pearson correlation coefficient between two vectors; Mo is the functional representation of the cell type annotation model; To is the functional representation of the feature extractor; aw is the functional representation of the attention mechanism network; avgTo represents the average output of the feature extractor; Mo(xb(k)) represents the output vector after the cell characteristic gene vector xb(k) is input into the cell type annotation model; Mo(xr(i),yr(xr(i))) represents the value of the yr(xr(i))th element of the output vector after the cell characteristic gene vector xr(i) is input into the cell type annotation model; To(xq(i)), To(xq(j)), To(xr(i)), To(xr(j)), To(pos(xq(j))), To(neg(xq(i))) respectively represent the cell characteristic gene vectors xq(i), xq(j), xr(i), xr(j), pos(xq(j)), neg(xq(i)) which are respectively input into the cell type annotation model and then output by the feature extractor; To(xq(i),j), To(xb(i),j), To(xb(k),j) respectively represent the j-th element value of the vector output by the feature extractor after the cell feature gene vectors xq(i), xb(i), xb(k) are input into the cell type annotation model for execution; aw(xb(i),j) represents the jth component of the attention weight vector output by the attention mechanism network after the cell feature gene vector xb(k) is input into the cell type annotation model; avgTo(XQ,j) and avgTo(XR,j) respectively represent the average value of the jth element of the vector output by the feature extractor after the characteristic gene vectors of each cell in the test sample batch set XQ and the training sample batch set XR are input into the cell type annotation model for execution; pos(xq(j)) and neg(xq(i)) represent the positive sample of the cell feature gene vector xq(j) and the negative sample of xq(i), respectively; {cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB], cos(To(xr(i)),To(xq(j)))>hc} means that after any cell feature gene vector in the training sample batch set and any cell feature gene vector in the test sample batch set are respectively input into the cell type annotation model for execution, the cosine similarity of the corresponding two vectors output by the feature extractor is greater than the cosine similarity set composed of hc; hc is a preset constant; Cx(y(xb(i)),j) represents the j-th element mean of the feature extractor output vector corresponding to the cell type y(xb(i)) output by the cell type annotation model; {To(xb(k),j)|Mo(xb(k))=y(xb(i)),k∈[1..2*sizeB]} represents the numerical set composed of the j-th element value of the feature extractor output vector corresponding to the cell type y(xb(i)) output by the cell type annotation model after the characteristic gene vectors of each cell in the xb set are input to the cell type annotation model for execution; wherein, y(xb(i)) represents the numerical label of the cell type corresponding to the cell characteristic gene vector xb(i). If the cell characteristic gene vector xb(i) comes from the training sample batch set, then y(xb(i))=yr(xb(i)); otherwise, y(xb(i))=indexOfmax(Mo(xb(i))); where indexOfmax(Mo(xb(i))) represents the index with the largest element value in the output vector after the cell characteristic gene vector xb(i) is input into the cell type annotation model and executed.
[0038] According to the method of the present invention, after the cell type annotation model is trained, the cell type annotation has a high accuracy. Through testing on PBMC, HFA_50K, HFA_100K, HFA_200K, CITE and other data sets, the accuracy is respectively: PBMC, 90.0% HFA_50K, 87.0% HFA_100K, 86.2% HFA_200K, 85.6% CITE, 96.0% It is significantly higher than the methods such as Seurat and GLUE in the prior art. In addition, it should be pointed out that the neural network-based cell type annotation device referred to in the present invention is a virtual device implemented by executing computer program instructions, and the modules it contains correspond to the steps in the neural network-based cell type annotation method one by one, and no further elaboration is required.
Claims
1. A cell type annotation method based on a neural network, characterized in that: The method comprises a model training step and a type annotation step; the model training step is used to convert cell sequencing data of known cell types into cell characteristic gene vectors as input of the cell type annotation model to train the cell type annotation model; the type annotation step is used to convert cell sequencing data into cell characteristic gene vectors as input of the cell type annotation model, and the cell type to which the cell type to be determined is marked by the cell type annotation model; The cell sequencing data is RNA sequencing data or ATAC sequencing data; The cell characteristic gene vector is a vector composed of expression values of M pre-set characteristic genes of the cell; The RNA sequencing data is converted into a cell characteristic gene vector: the expression amounts of characteristic genes are selected from the RNA sequencing data to form a cell characteristic gene vector of M dimensions; The ATAC sequencing data is converted into a cell characteristic gene vector: according to the known relationship between chromatin accessibility and gene expression, the chromatin openness state data corresponding to the characteristic gene is extracted from the ATAC sequencing data and mapped into the expression amount of the characteristic gene, thereby obtaining an M-dimensional cell characteristic gene vector; The cell type annotation model includes a feature extractor and a classifier; the feature extractor is a fully connected linear layer network with the cell feature gene vector as input and the KM-dimensional vector as output; the classifier is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the K-dimensional vector as output; the K-dimensional vector output by the classifier is used to represent the probability values of K types of cell types; The model training step includes a training model initialization step, a sample preparation step and a sample training step; The training model initialization step: initializing the training model; the training model includes a cell type annotation model and an attention mechanism network; The attention mechanism network is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the KM-dimensional vector as output; the KM-dimensional vector output by the attention mechanism network is the attention weight vector; The sample preparation step comprises: converting the cell sequencing data set of known cell types and the cell sequencing data set of unknown cell types into cell characteristic gene vectors to form a training sample set and a test sample set respectively; The sample training step includes a batch sample preparation step, a batch model execution step, and a loss calculation and model optimization adjustment step; The batch sample preparation step: randomly selecting sizeB training samples and sizeB test samples from the training sample set and the test sample set to form a training sample batch set and a test sample batch set; then calculating the corresponding positive sample and negative sample for each cell feature gene vector in the test sample batch set; wherein, The training sample batch set is represented as XR={{xr(i),yr(xr(i))}|i∈[1..sizeB]}; The test sample batch set is represented by XQ={xq(i)|i∈[1..sizeB]}; where, xr(i) represents the i-th cell feature gene vector in the training sample batch set; xq(i) represents the i-th cell characteristic gene vector in the test sample batch set; yr(xr(i)) represents the numerical label of the known cell type corresponding to the cell characteristic gene vector xr(i), ranging from 1 to K; The positive sample is the closest cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i); The negative sample is a random cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i) except the closest one; The nearest neighbors of the cell characteristic gene vector xq(i) are the neighboring cell characteristic gene vectors of the k cell characteristic gene vectors xq(i) found from the test sample batch set by the nearest neighbor algorithm; The batch model execution step: inputting each cell characteristic gene vector in the training sample batch set and the test sample batch set into the cell type annotation model for execution, and collecting intermediate data and output generated during the execution of the cell type annotation model; The loss calculation and model optimization adjustment step: according to the intermediate data and output collected during the execution of the cell type annotation model, combined with the numerical labels of the known cell types of the training samples, the loss coefficient is calculated, and then the model parameters of the cell type annotation model are adjusted by gradient descent and back propagation; wherein, The loss coefficient is calculated according to the following formula: L_Total=Lce+0.1*Lpr+a1*Lcl+a2*Lfa+a3*Lsc; L_Total is the loss coefficient; a1, a2, and a3 are balance coefficients for different loss values; Lce is the cross entropy loss value, Lpr is the regularization loss value, Lcl is the contrastive learning loss value, Lfa is the modality alignment loss value, and Lsc is the sparse center loss value; where, Lce=avg({ln(Mo(xr(i),yr(xr(i))))|i∈[1..sizeB]}); Lpr=mulinv(avg({sum({abs((To(xq(i),j)-avgTo(XQ,j))|j∈[1..KM]})|i∈[1..sizeB]}) +avg({abs(corr(To(xq(i)),To(xq(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(corr(To(xr(i)),To(xr(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(avgTo(XR,j))|j∈[1..KM]})+avg({abs(avgTo(XQ,j))|j∈[1..KM]}); Lcl=﹣avg({ln(epos(xq(j)) / (epos(xq(j))+sum({eneg(xq(i))|i∈[1..sizeB]})))| j∈[1..sizeB]}); Lfa= -avg({cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB],cos(To(xr(i)),To(xq(j)))>hc}); Lsc = avg({sum({aw(xb(i),j)*square(To(xb(i),j)-Cx(y(xb(i)),j)))|j∈[1..KM]})|i∈[1..2*sizeB]}); in, epos(xq(j))=exp(sim(To(xq(j)),To(pos(xq(j))))) / Tv); eneg(xq(i))=exp(sim(To(xq(i)),To(neg(xq(i))))) / Tv); Cx(y(i),j)=avg({To(xb(k),j)|Mo(xb(k))=y(xb(i)), k∈[1..2*sizeB]}); where, xb(i) represents the i-th cell characteristic gene vector of the xb set; The xb set is a cell characteristic gene vector composed of each cell characteristic gene vector of the training sample batch set and each cell characteristic gene vector of the test sample batch set; avg and sum represent the mean and sum of the values in a set of values respectively; ln means natural logarithm; exp means the power of a natural constant; mulinv means reciprocal; abs means absolute value; square means square; sim represents the similarity between two vectors; cos represents the cosine similarity between two vectors; corr represents the Pearson correlation coefficient between two vectors; Mo is the functional representation of the cell type annotation model; To is the functional representation of the feature extractor; aw is the functional representation of the attention mechanism network; avgTo represents the average output of the feature extractor; Mo(xb(k)) represents the output vector after the cell characteristic gene vector xb(k) is input into the cell type annotation model; Mo(xr(i),yr(xr(i))) represents the value of the yr(xr(i))th element of the output vector after the cell characteristic gene vector xr(i) is input into the cell type annotation model for execution; To(xq(i)), To(xq(j)), To(xr(i)), To(xr(j)), To(pos(xq(j))), To(neg(xq(i))) respectively represent the vectors output by the feature extractor after the cell characteristic gene vectors xq(i), xq(j), xr(i), xr(j), pos(xq(j)), neg(xq(i)) are respectively input into the cell type annotation model for execution; To(xq(i),j), To(xb(i),j), To(xb(k),j) respectively represent the j-th element value of the vector output by the feature extractor after the cell characteristic gene vectors xq(i), xb(i), xb(k) are input into the cell type annotation model for execution; aw(xb(i),j) represents the jth component of the attention weight vector output by the attention mechanism network after the cell feature gene vector xb(k) is input into the cell type annotation model for execution; avgTo(XQ,j) and avgTo(XR,j) respectively represent the average value of the jth element of the vector output by the feature extractor after the characteristic gene vectors of each cell in the test sample batch set XQ and the training sample batch set XR are input into the cell type annotation model for execution; pos represents positive samples; neg represents negative samples; pos(xq(j)) and neg(xq(i)) represent the positive sample of the cell feature gene vector xq(j) and the negative sample of xq(i), respectively; {cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB], cos(To(xr(i)),To(xq(j)))>hc} means that after any cell feature gene vector in the training sample batch set and any cell feature gene vector in the test sample batch set are respectively input into the cell type annotation model for execution, the cosine similarity of the corresponding two vectors output by the feature extractor is greater than the cosine similarity set composed of hc; hc is a preset constant; Cx(y(xb(i)),j) represents the j-th element mean of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the cell type annotation model; {To(xb(k),j)|Mo(xb(k))=y(xb(i)),k∈[1..2*sizeB]} represents the numerical set composed of the j-th element value of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the feature gene vector of each cell in the xb set after being input into the cell type annotation model for execution; wherein, y(xb(i)) represents the numerical label of the cell type corresponding to the cell characteristic gene vector xb(i). If the cell characteristic gene vector xb(i) comes from the training sample batch set, then y(xb(i))=yr(xb(i)); otherwise, y(xb(i))=indexOfmax(Mo(xb(i))); where, indexOfmax(Mo(xb(i))) represents the index of the largest element value in the output vector after the cell characteristic gene vector xb(i) is input into the cell type annotation model for execution; In the type annotation step, the index of the largest element value in the output vector after the cell type annotation model is executed is used as the cell type to which the cell belongs.
2. The cell type annotation method according to claim 1, characterized in that: The feature extractor and classifier are both single linear layer networks; the feature extractor uses the ReLU function as the activation function, and the classifier uses the softmax function as the activation function; the attention mechanism network includes a hidden linear layer composed of KM neurons with the Tanh function as the activation function and an output layer composed of 2*KM neurons with the softmax function as the activation function; the 2*KM-dimensional vectors output by the output layer of the attention mechanism network are arranged into a KM-dimensional double-valued vector, and then the second value of the double value of each dimension is taken from the KM-dimensional double-valued vector to form a KM-dimensional attention weight vector.
3. The cell type annotation method according to claim 1, characterized in that: The contrastive learning loss value, modal alignment loss value, and sparse center loss value are calculated only after the sample training loss calculation step and the model parameter adjustment step are executed more than the corresponding round limit, otherwise the value is 0.
4. The cell type annotation method according to claim 1, 2 or 3, characterized in that: The sim similarity calculation is calculated using the cosine similarity calculation formula.
5. A cell type annotation device based on a neural network, characterized in that: The device comprises a model training module and a type annotation module; the model training module is used to convert cell characteristic gene vectors according to cell sequencing data of known cell types as input of the cell type annotation model to train the cell type annotation model; the type annotation module is used to convert cell characteristic gene vectors according to cell sequencing data as input of the cell type annotation model, and the cell type to which the cell type to be determined is marked by the cell type annotation model; The cell sequencing data is RNA sequencing data or ATAC sequencing data; The cell characteristic gene vector is a vector composed of expression values of M pre-set characteristic genes of the cell; The RNA sequencing data is converted into a cell characteristic gene vector: the expression amounts of characteristic genes are selected from the RNA sequencing data to form a cell characteristic gene vector of M dimensions; The ATAC sequencing data is converted into a cell characteristic gene vector: according to the known relationship between chromatin accessibility and gene expression, the chromatin openness state data corresponding to the characteristic gene is extracted from the ATAC sequencing data and mapped into the expression amount of the characteristic gene, thereby obtaining an M-dimensional cell characteristic gene vector; The cell type annotation model includes a feature extractor and a classifier; the feature extractor is a fully connected linear layer network with the cell feature gene vector as input and the KM-dimensional vector as output; the classifier is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the K-dimensional vector as output; the K-dimensional vector output by the classifier is used to represent the probability values of K types of cell types; The model training module includes a training model initialization module, a sample preparation module and a sample training module; The training model initialization module is used to: initialize the training model; the training model includes a cell type annotation model and an attention mechanism network; The attention mechanism network is a fully connected linear layer network with the KM-dimensional vector output by the feature extractor as input and the KM-dimensional vector as output; the KM-dimensional vector output by the attention mechanism network is the attention weight vector; The sample preparation module is used to: form a training sample set and a test sample set respectively by converting the cell sequencing data set of known cell types and the cell sequencing data set of unknown cell types into cell characteristic gene vectors; The sample training module includes a batch sample preparation module, a batch model execution module, and a loss calculation and model optimization adjustment module; The batch sample preparation module is used to: randomly select sizeB training samples and sizeB test samples from the training sample set and the test sample set to form a training sample batch set and a test sample batch set; then calculate the corresponding positive sample and negative sample for each cell feature gene vector in the test sample batch set; wherein, The training sample batch set is represented as XR={{xr(i),yr(xr(i))}|i∈[1..sizeB]}; The test sample batch set is represented by XQ={xq(i)|i∈[1..sizeB]}; where, xr(i) represents the i-th cell feature gene vector in the training sample batch set; xq(i) represents the i-th cell characteristic gene vector in the test sample batch set; yr(xr(i)) represents the numerical label of the known cell type corresponding to the cell characteristic gene vector xr(i), ranging from 1 to K; The positive sample is the closest cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i); The negative sample is a random cell characteristic gene vector among the neighbors of the cell characteristic gene vector xq(i) except the closest one; The nearest neighbors of the cell characteristic gene vector xq(i) are the neighboring cell characteristic gene vectors of the k cell characteristic gene vectors xq(i) found from the test sample batch set by the nearest neighbor algorithm; The batch model execution module is used to: input each cell characteristic gene vector in the training sample batch set and the test sample batch set into the cell type annotation model for execution, and collect intermediate data and output generated during the execution of the cell type annotation model; The loss calculation and model optimization adjustment module is used to: calculate the loss coefficient based on the intermediate data and output collected during the execution of the cell type annotation model, combined with the numerical labels of the known cell types of the training samples, and then adjust the model parameters of the cell type annotation model through gradient descent and back propagation; wherein, The loss coefficient is calculated according to the following formula: L_Total=Lce+0.1*Lpr+a1*Lcl+a2*Lfa+a3*Lsc; L_Total is the loss coefficient; a1, a2, and a3 are balance coefficients for different loss values; Lce is the cross entropy loss value, Lpr is the regularization loss value, Lcl is the contrastive learning loss value, Lfa is the modality alignment loss value, and Lsc is the sparse center loss value; where, Lce=avg({ln(Mo(xr(i),yr(xr(i))))|i∈[1..sizeB]}); Lpr=mulinv(avg({sum({abs((To(xq(i),j)-avgTo(XQ,j))|j∈[1..KM]})|i∈[1..sizeB]}) +avg({abs(corr(To(xq(i)),To(xq(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(corr(To(xr(i)),To(xr(j))))|i∈[1..sizeB],j∈[1..sizeB],i≠j}) +avg({abs(avgTo(XR,j))|j∈[1..KM]})+avg({abs(avgTo(XQ,j))|j∈[1..KM]}); Lcl=﹣avg({ln(epos(xq(j)) / (epos(xq(j))+sum({eneg(xq(i))|i∈[1..sizeB]})))| j∈[1..sizeB]}); Lfa= -avg({cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB],cos(To(xr(i)),To(xq(j)))>hc}); Lsc = avg({sum({aw(xb(i),j)*square(To(xb(i),j)-Cx(y(xb(i)),j)))|j∈[1..KM]})|i∈[1..2*sizeB]}); in, epos(xq(j))=exp(sim(To(xq(j)),To(pos(xq(j))))) / Tv); eneg(xq(i))=exp(sim(To(xq(i)),To(neg(xq(i))))) / Tv); Cx(y(i),j)=avg({To(xb(k),j)|Mo(xb(k))=y(xb(i)), k∈[1..2*sizeB]}); where, xb(i) represents the i-th cell characteristic gene vector of the xb set; The xb set is a cell characteristic gene vector composed of each cell characteristic gene vector of the training sample batch set and each cell characteristic gene vector of the test sample batch set; avg and sum represent the mean and sum of the values in a set of values respectively; ln means natural logarithm; exp means the power of a natural constant; mulinv means reciprocal; abs means absolute value; square means square; sim represents the similarity between two vectors; cos represents the cosine similarity between two vectors; corr represents the Pearson correlation coefficient between two vectors; Mo is the functional representation of the cell type annotation model; To is the functional representation of the feature extractor; aw is the functional representation of the attention mechanism network; avgTo represents the average output of the feature extractor; Mo(xb(k)) represents the output vector after the cell characteristic gene vector xb(k) is input into the cell type annotation model; Mo(xr(i),yr(xr(i))) represents the value of the yr(xr(i))th element of the output vector after the cell characteristic gene vector xr(i) is input into the cell type annotation model for execution; To(xq(i)), To(xq(j)), To(xr(i)), To(xr(j)), To(pos(xq(j))), To(neg(xq(i))) respectively represent the vectors output by the feature extractor after the cell characteristic gene vectors xq(i), xq(j), xr(i), xr(j), pos(xq(j)), neg(xq(i)) are respectively input into the cell type annotation model for execution; To(xq(i),j), To(xb(i),j), To(xb(k),j) respectively represent the j-th element value of the vector output by the feature extractor after the cell characteristic gene vectors xq(i), xb(i), xb(k) are input into the cell type annotation model for execution; aw(xb(i),j) represents the jth component of the attention weight vector output by the attention mechanism network after the cell feature gene vector xb(k) is input into the cell type annotation model for execution; avgTo(XQ,j) and avgTo(XR,j) respectively represent the average value of the jth element of the vector output by the feature extractor after the characteristic gene vectors of each cell in the test sample batch set XQ and the training sample batch set XR are input into the cell type annotation model for execution; pos represents positive samples; neg represents negative samples; pos(xq(j)) and neg(xq(i)) represent the positive sample of the cell feature gene vector xq(j) and the negative sample of xq(i), respectively; {cos(To(xr(i)),To(xq(j)))|i∈[1..sizeB],j∈[1..sizeB], cos(To(xr(i)),To(xq(j)))>hc} means that after any cell feature gene vector in the training sample batch set and any cell feature gene vector in the test sample batch set are respectively input into the cell type annotation model for execution, the cosine similarity of the corresponding two vectors output by the feature extractor is greater than the cosine similarity set composed of hc; hc is a preset constant; Cx(y(xb(i)),j) represents the j-th element mean of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the cell type annotation model; {To(xb(k),j)|Mo(xb(k))=y(xb(i)),k∈[1..2*sizeB]} represents the numerical set composed of the j-th element value of the vector output by the feature extractor corresponding to the cell type y(xb(i)) output by the feature gene vector of each cell in the xb set after being input into the cell type annotation model for execution; wherein, y(xb(i)) represents the numerical label of the cell type corresponding to the cell characteristic gene vector xb(i). If the cell characteristic gene vector xb(i) comes from the training sample batch set, then y(xb(i))=yr(xb(i)); otherwise, y(xb(i))=indexOfmax(Mo(xb(i))); where, indexOfmax(Mo(xb(i))) represents the index of the largest element value in the output vector after the cell characteristic gene vector xb(i) is input into the cell type annotation model for execution; The type annotation module uses the index with the largest element value in the output vector after the cell type annotation model is executed as the cell type to which the cell belongs.
6. The cell type annotation device according to claim 5, characterized in that: The feature extractor and classifier are both single linear layer networks; the feature extractor uses the ReLU function as the activation function, and the classifier uses the softmax function as the activation function; the attention mechanism network includes a hidden linear layer composed of KM neurons with the Tanh function as the activation function and an output layer composed of 2*KM neurons with the softmax function as the activation function; the 2*KM-dimensional vectors output by the output layer of the attention mechanism network are arranged into a KM-dimensional double-valued vector, and then the second value of the double value of each dimension is taken from the KM-dimensional double-valued vector to form a KM-dimensional attention weight vector.
7. The cell type annotation device according to claim 5, characterized in that: The contrastive learning loss value, modal alignment loss value, and sparse center loss value are calculated only after the sample training loss calculation module and the model parameter adjustment module are executed more than the corresponding round limit, otherwise the value is 0.
8. The cell type annotation device according to claim 5, 6 or 7, characterized in that: The sim similarity calculation is calculated using the cosine similarity calculation formula, and the KM value is 64.
9. A machine-readable medium, characterized in that The medium stores a program instruction set that can be read by a machine. When the program instruction set stored in the medium is read and executed by a machine, the machine can implement the neural network-based cell type annotation method according to any one of claims 1 to 4.
10. An electronic device, characterized in that: The device comprises a connected processor and a memory; a program instruction set is stored in the memory; when the processor loads and executes the program instruction set stored in the memory, the device can implement the neural network-based cell type annotation method according to any one of claims 1 to 4.