Cell type annotation methods, apparatuses, devices, and media
By constructing a cell annotation model based on a full-map feature matrix and a spatial neighborhood graph, and combining attention mechanisms and biological prior knowledge, the problems of feature aliasing and biological knowledge integration in high-density tissue imaging are solved, thereby improving the accuracy and biological fidelity of cell annotation. This model is suitable for processing large-scale spatial proteomics datasets.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HAINAN UNIV
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies suffer from feature aliasing caused by lateral signal spillover in high-density tissue imaging, making it difficult to effectively distinguish between real protein expression and neighbor spillover noise. Furthermore, biological knowledge is difficult to integrate into deep learning models, resulting in a high misjudgment rate of cell annotation, huge computational resource consumption, and difficulty in processing large-scale clinical slides.
By constructing a full-map feature matrix and a spatial neighborhood graph, and utilizing a cell annotation model with a feature encoder, spatial aggregator, and prototype consistency constraint module, combined with attention mechanisms and biological prior knowledge, adaptive spatial aggregation and model updates are performed to ensure the biological rationality and accuracy of the annotation results.
It significantly improves the annotation accuracy of densely celled regions, enhances the identification of rare cell types, realizes the automation and precision of cell annotation, adapts to the processing of large-scale spatial proteomics datasets, and improves the robustness and generalization ability of the model.
Smart Images

Figure CN122157797A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of bioinformatics and medical image processing technology, and particularly to cell type annotation methods, devices, equipment and media. Background Technology
[0002] Spatial proteomics technology can simultaneously detect the expression of dozens of proteins in tissue samples at high resolution while preserving precise spatial location information of cells. Cell type annotation, as a core component of data analysis in this field, is fundamental to understanding the complex tumor microenvironment, deconstructing disease mechanisms, and discovering novel biomarkers. Currently, automated cell annotation technologies are mainly divided into three categories: clustering-based, traditional supervised learning, and image-based deep learning methods. Although these methods have made some progress, there are still bottlenecks to be addressed in practical applications. One is that lateral signal spillover in high-density tissue imaging causes feature aliasing, and existing models lack cell-specific annotation capabilities. Explicit modeling of spatial topological relationships cannot distinguish between real protein expression and neighbor spillover noise, resulting in a very high misclassification rate in densely populated cell regions. Secondly, the symbolic prior knowledge of cell types held by biologists is difficult to integrate into pure data-driven deep learning black-box models. When the training data contains noise or weak signals, the model is prone to producing prediction results that violate biological logic. Thirdly, there is a contradiction between efficiency and accuracy in spatial context modeling. Methods that directly process the original images consume huge computational resources and are difficult to process large-scale clinical slides. On the other hand, simple spatial smoothing methods based on neighborhood averaging will lose local heterogeneity, resulting in rare cell types being smoothed out.
[0003] In summary, improving the accuracy and biological fidelity of cell annotation is a problem that needs to be solved in this field. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide a cell type annotation method, apparatus, device, and medium to improve the accuracy and biological fidelity of cell annotation. The specific solution is as follows: In a first aspect, this application discloses a cell type annotation method, including: Cell segmentation is performed on historical multi-tissue images to obtain single-cell samples, and a full-image feature matrix and spatial neighborhood map are constructed based on the cell characteristics and spatial location of the single-cell samples. The full-image feature matrix and the spatial neighborhood graph are input into the current cell annotation model; wherein, the current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module; The feature encoder maps the full-image feature matrix into an initial latent vector. Based on the spatial neighborhood graph, the effective nearest neighbor cells of each single-cell sample are determined. The attention coefficient of the effective nearest neighbor cells to the single-cell sample is determined based on the attention mechanism. The spatial aggregator performs a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficients to obtain the spatial perception features of the single-cell sample. The classification decoder outputs the predicted type probability distribution of the single-cell sample based on the spatial perception features. The biological prototype features of the single-cell sample are weighted and summed using the predicted type probability distribution as weights to generate reconstructed features. The prototype consistency constraint module is used to obtain the prototype consistency loss value based on the reconstructed features and the spatial awareness features. The current cell annotation model is updated based on the prototype consistency loss value to obtain a new current cell annotation model. Then, the process jumps back to the step of inputting the full-map feature matrix and the spatial neighborhood graph into the current cell annotation model until the preset stopping condition is met, and the new current cell annotation model is determined as the target cell annotation model. The target cell annotation model is used to annotate cell types in the current multi-tissue image.
[0005] Optionally, the step of performing cell segmentation on historical multiple tissue images to obtain single-cell samples, and constructing a full-image feature matrix and a spatial neighborhood map based on the cell-specific features and spatial location of the single-cell samples, includes: Cell segmentation is performed on historical multi-tissue images to obtain a sample set; wherein each single-cell sample in the sample set is a node; A full-map feature matrix is constructed using the cell-specific features of the single-cell samples; wherein, the cell-specific features include the in situ expression intensity and morphological features of the markers; The spatial location of a single cell sample is encoded using the two-dimensional coordinates of its centroid. Based on the spatial location of the cell, the effective nearest neighbor cells of each single cell sample are determined using the K-nearest neighbor method. Connection edges between the single cell sample and its corresponding effective nearest neighbor cells are constructed to obtain a spatial neighborhood graph.
[0006] Optionally, determining the effective nearest neighbor cells for each single-cell sample based on the spatial neighborhood map, and determining the attention coefficient of the effective nearest neighbor cells to the single-cell sample based on an attention mechanism, includes: Based on the spatial neighborhood map, determine each effective nearest neighbor cell of the current single-cell sample, and sequentially determine each effective nearest neighbor cell as the current effective nearest neighbor cell; The initial latent vector of the current single-cell sample and the initial latent vector of the current effective nearest neighbor cell are transformed using a spatial transformation matrix to obtain the first transformed matrix of the current single-cell sample and the second transformed matrix of the current effective nearest neighbor cell. The first transformed matrix and the second transformed matrix are then concatenated to obtain a concatenated vector. The attention coefficients of the current effective neighbor cells to the current single-cell sample are obtained by using the attention weight vector and the splicing vector, so as to obtain the attention coefficients of each effective neighbor cell to the current single-cell sample.
[0007] Optionally, the step of using the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficient includes: The attention coefficients of each effective neighbor cell to the current single-cell sample are normalized to obtain the target contribution weight of each effective neighbor cell to the current single-cell sample. The spatial aggregator is used to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the target contribution weight.
[0008] Optionally, before generating the reconstructed features by weighting and summing the biological prototype features of the single-cell sample using the predicted type probability distribution as weights, the method further includes: The average expression profile of each cell type in the historical multiple tissue images is statistically analyzed, and the average expression profile of each cell type is determined as the biological prototype feature of each cell type.
[0009] Optionally, the step of using the prototype consistency constraint module to obtain the prototype consistency loss value based on the reconstructed features and the spatial awareness features includes: The prototype consistency constraint module is used to obtain the mean squared error between the reconstructed features and the spatial awareness features of each single cell sample, and the average mean squared error of all single cell samples is obtained to obtain the prototype consistency loss value of the current cell annotation model.
[0010] Optionally, updating the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model includes: The classification cross-entropy loss value of the current cell annotation model is obtained based on the error between the predicted type probability distribution and the true cell type of each single cell sample. The sum of the prototype consistency loss value and the classification cross-entropy loss value is determined as the total loss value, and the current cell annotation model is updated with the goal of minimizing the total loss value to obtain a new current cell annotation model.
[0011] Secondly, this application discloses a cell type annotation device, comprising: The feature construction module is used to perform cell segmentation on historical multi-tissue images to obtain single-cell samples, and to construct a full-image feature matrix and a spatial neighborhood map based on the cell features and spatial location of the single-cell samples. The model input module is used to input the full-image feature matrix and the spatial neighborhood graph into the current cell annotation model; wherein, the current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module; The feature acquisition module is used to map the full-image feature matrix into an initial latent vector using the feature encoder, determine the effective nearest neighbor cells of each single-cell sample based on the spatial neighborhood graph, determine the attention coefficient of the effective nearest neighbor cells to the single-cell sample based on the attention mechanism, and use the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficients to obtain the spatial perception features of the single-cell sample. The feature reconstruction module is used to use the classification decoder to output the predicted type probability distribution of the single cell sample based on the spatial perception features, and to perform a weighted summation of the biological prototype features of the single cell sample with the predicted type probability distribution as the weight to generate reconstructed features. The loss value acquisition module is used to acquire the prototype consistency loss value based on the reconstruction features and the spatial perception features using the prototype consistency constraint module. The model optimization module is used to update the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model, and then jump back to the step of inputting the full-map feature matrix and the spatial neighborhood graph into the current cell annotation model until the preset stopping condition is met, and the new current cell annotation model is determined as the target cell annotation model. The type annotation module is used to annotate the current multi-tissue image with cell types using the target cell annotation model.
[0012] Thirdly, this application discloses an electronic device, including: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the aforementioned disclosed cell type annotation method.
[0013] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed cell type annotation method.
[0014] The beneficial effects of this application are as follows: This application performs cell segmentation on historical multi-tissue images to obtain single-cell samples, and constructs a full-image feature matrix and a spatial neighborhood map based on the cell's own characteristics and spatial location. The full-image feature matrix and the spatial neighborhood map are input into the current cell annotation model. The current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module. The feature encoder maps the full-image feature matrix into an initial latent vector. Based on the spatial neighborhood map, the effective nearest neighbor cells of each single-cell sample are determined, and the attention coefficient of the effective nearest neighbor cells on the single-cell sample is determined based on an attention mechanism. The spatial aggregator performs a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells based on the attention coefficients. The process involves: obtaining the spatial awareness features of the single-cell sample; using the classification decoder to output the predicted type probability distribution of the single-cell sample based on the spatial awareness features; weighting the biological prototype features of the single-cell sample with the predicted type probability distribution as weights to generate reconstructed features; using the prototype consistency constraint module to obtain the prototype consistency loss value based on the reconstructed features and the spatial awareness features; updating the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model; returning to the step of inputting the full-image feature matrix and the spatial neighborhood graph into the current cell annotation model until a preset stopping condition is met, and determining the new current cell annotation model as the target cell annotation model; and using the target cell annotation model to annotate the current multi-tissue image with cell types.Therefore, this application obtains single-cell samples by segmenting historical multi-tissue images, constructs a full-image feature matrix and a spatial neighborhood map, and inputs them into a cell annotation model containing a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module. After the feature encoder maps the initial latent vector, effective neighboring cells are determined based on the spatial neighborhood map. Attention coefficients are obtained through an attention mechanism, and then the spatial aggregator weights and sums the initial latent vectors to obtain spatially perceptual features. Adaptive spatial aggregation is achieved by combining the spatial neighborhood map with the attention mechanism, which can accurately distinguish the effective signals of neighboring cells from spillover noise, fundamentally solving the feature aliasing problem caused by lateral signal spillover, and significantly improving the annotation accuracy of densely celled regions. Subsequently, the classification decoder outputs the predicted type probability distribution and uses it to generate reconstructed features. The prototype consistency constraint module obtains the original features based on the reconstructed features and spatially perceptual features. The model employs a prototype consistency loss value, transforming discrete biological priors into differentiable mathematical constraints. This prototype consistency loss forces the model predictions to follow biological laws, completely avoiding the biological illusion problem of purely data-driven models and ensuring the biological rationality and fidelity of the annotation results. The model is iteratively updated until it meets preset conditions to obtain the target model, which is ultimately used for cell type annotation of current multi-tissue images. The model adopts end-to-end collaborative training, with each module optimized in tandem, balancing feature extraction accuracy and computational efficiency of local graph structure operations. It is suitable for processing large-scale spatial proteomics datasets, significantly improving the model's robustness and generalization ability. The ability to identify rare and easily confused cell phenotypes is significantly enhanced, achieving a dual improvement in the automation and precision of cell annotation. This provides reliable technical support for spatial proteomics research and effectively solves the core technical pain points of traditional methods. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0016] Figure 1 This is a flowchart of a cell type annotation method disclosed in this application; Figure 2 This is a specific overall framework diagram of the model disclosed in this application; Figure 3 This is a schematic diagram illustrating the effect of a specific model disclosed in this application; Figure 4 This is a schematic diagram of the structure of a cell type annotation device disclosed in this application; Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0018] Spatial proteomics technology can detect the expression of dozens of proteins in tissue samples at high resolution and preserve the precise spatial location of cells. Cell type annotation, as the core of data analysis in this field, is key to understanding the tumor microenvironment, studying disease mechanisms, and discovering biomarkers. Currently, automated cell annotation technologies are mainly divided into three categories: clustering-based methods that group cells using clustering algorithms and then manually annotate them by experts; traditional supervised learning methods that treat cells as independent feature vectors and classify them using multilayer perceptrons or support vector machines; and image-based deep learning methods that use convolutional neural networks to extract the morphological and spatial features of cells and their surroundings. Although these methods have made some progress, there are still three core problems that urgently need to be solved in practical applications. One is the feature aliasing problem caused by lateral signal spillover. In high-density tissue imaging, protein signals from adjacent cells can easily interpenetrate, but existing models lack explicit modeling of the spatial topological relationships between cells, making it impossible to distinguish between true protein expression and spillover noise from neighbors, resulting in different cells... First, there is a high degree of similarity in cell type characteristics, leading to an extremely high misclassification rate in densely populated cell regions. Second, there is a disconnect between biological common sense and model prediction. Biologists have mastered a large amount of discrete symbolic prior knowledge related to cell types. This knowledge is logical and non-differentiable, while existing pure data-driven deep learning black-box models rely entirely on data fitting. When the training data contains noise or weak signals, it is easy to produce prediction results that violate biological logic, and it is difficult to effectively integrate such biological principles into a differentiable deep learning training framework. Third, there is a trade-off between efficiency and accuracy in spatial context modeling. Some methods capture spatial texture through convolutional neural networks, but they need to process massive amounts of raw image slices, resulting in huge computational overhead and difficulty in utilizing the topological structure information between cells. Another type of lightweight method oversimplifies spatial information, causing researchers to either face the problem of exhausting computational resources or have to sacrifice spatial perception accuracy when processing large-scale spatial protein datasets, or even causing the features of rare cell types to be flattened.
[0019] Therefore, this application provides a cell type annotation scheme to improve the accuracy and biological fidelity of cell annotation.
[0020] See Figure 1 As shown in the embodiments, this application discloses a cell type annotation method, including: Step S11: Perform cell segmentation on historical multi-tissue images to obtain single-cell samples, and construct a full-image feature matrix and a spatial neighborhood map based on the cell characteristics and spatial location of the single-cell samples.
[0021] In this embodiment, the step of performing cell segmentation on historical multiple tissue images to obtain single-cell samples, and constructing a full-image feature matrix and a spatial neighborhood graph based on the cell-specific features and spatial location of the single-cell samples, includes: performing cell segmentation on historical multiple tissue images to obtain a sample set; wherein each single-cell sample is a node in the sample set; constructing a full-image feature matrix using the cell-specific features of the single-cell samples; wherein the cell-specific features include the in-situ expression intensity and morphological features of markers; encoding the cell spatial location of the single-cell samples using the two-dimensional coordinates of the cell centroids of the single-cell samples; determining the effective nearest neighbor cells of each single-cell sample based on the cell spatial location and using the K-nearest neighbor method; and constructing connection edges between the single-cell samples and the corresponding effective nearest neighbor cells to obtain a spatial neighborhood graph.
[0022] First, cell segmentation is performed on the historical multi-tissue images used for model training. Through segmentation, all single cells in the image are accurately identified and a single cell sample set S={c1,c2,...,cM} is formed, where M represents the total number of cells. Each single cell sample in this set is used as the basic node for the subsequent construction of the spatial neighborhood graph.
[0023] Then, the cell-specific features (and attribute vectors) of each single-cell sample are extracted. ∈R N+1 To construct the full-image feature matrix X∈R M×(N+1) The cell's intrinsic characteristics specifically include the in situ expression intensity of N protein markers and morphological features such as cell area that reflect cell morphology. Each row of the full-image feature matrix corresponds to all of the above intrinsic characteristics of a single-cell sample, becoming the core data characterizing the cell's inherent properties. Next, the two-dimensional coordinates p of the cell centroid of each single-cell sample are extracted. i ∈R 2 The coordinates are directly used to quantize and encode the actual spatial location information of a single-cell sample, resulting in coordinate data that reflects the spatial arrangement of all cells, and a coordinate matrix P∈R. M×2 .
[0024] Based on the spatial location of the cell, the K-nearest neighbor algorithm is used to search for the K nearest single-cell samples in space with Euclidean distance and determine them as the effective nearest neighbors of the cell. Based on this, a dedicated connection edge (i,j)∈E is established between each single-cell sample and all its corresponding effective nearest neighbors. With the single-cell sample as node vi and the connection edge between cells as the topological relationship between nodes, a spatial neighborhood graph G=(V,E) that can accurately reflect the spatial neighborhood relationship of cells and the local microenvironment in the tissue slice is finally constructed. This spatial neighborhood graph not only preserves the cell's own characteristic attributes, but also explicitly models the spatial topological dependency relationship between cells, thus defining a precise local range for subsequent adaptive spatial aggregation operations.
[0025] The core objective of this embodiment is to learn a mapping function f, f: G(X, P)--->Y. This function takes a spatial neighborhood graph G as input and achieves accurate prediction of the category of each single cell sample by combining the cell features corresponding to each node in the aggregate graph with the spatial topological relationship between nodes. It outputs the category label yi corresponding to each cell, where yi belongs to the category set {1,…,K} containing K types of cells, that is, it clarifies the specific cell type to which each single cell sample belongs.
[0026] Step S12: Input the full-image feature matrix and the spatial neighborhood graph into the current cell annotation model; wherein, the current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module.
[0027] For example Figure 2 As shown, the constructed full-map feature matrix and spatial neighborhood graph are input into the cell annotation model currently used for training. This model is the SCAPC model (Spatial Context-Aware and Prototype-Consistent Model), whose core structure consists of four main parts: feature encoder, spatial aggregator, classification decoder, and prototype consistency constraint module. Among them, the spatial aggregator is the Adaptive Spatial Aggregation Module (ASAM), and the prototype consistency constraint module is the Physically Informed Prototype Consistency Constraint (PIPC) component. These modules work together to form a cascaded hybrid neural network architecture, which aims to effectively overcome the dual challenges of lateral signal spillover and biological illusion faced by existing methods by deeply integrating the topological information of cell neighborhood with the biological prior knowledge of physical knowledge.
[0028] Step S13: The feature encoder maps the full-image feature matrix into an initial latent vector. Based on the spatial neighborhood graph, the effective nearest neighbor cells of each single-cell sample are determined. The attention coefficient of the effective nearest neighbor cells to the single-cell sample is determined based on the attention mechanism. The spatial aggregator performs a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficients to obtain the spatial perception features of the single-cell sample.
[0029] The feature encoder of the SCAPC model maps the constructed full-image feature matrix into initial latent vectors. The feature encoder uses a Multi-Layer Perceptron (MLP) as its core component, and its input is the full-image feature matrix. This matrix summarizes the cell-specific features of all single-cell samples, specifically including the in situ expression intensity of multiple protein markers and morphological features for each single cell. Since these raw features are high-dimensional and noisy data, they are difficult to directly use for subsequent spatial aggregation and cell type prediction. Therefore, the feature encoder performs dimensionality reduction, denoising, and feature enhancement on the full-image feature matrix through multi-layer nonlinear transformations. This maps the high-dimensional raw feature vector corresponding to each single-cell sample in the matrix into a uniform, low-dimensional initial latent vector with high discriminative power, as shown below: ; In the formula, This represents the initial hidden vector corresponding to the i-th single-cell sample (the hidden feature of layer 0, i.e., the basic feature output by the encoder). This represents a non-linear activation function, specifically the ReLU activation function. This represents the learnable weight matrix of the feature encoder. This represents the cell-specific characteristics of the i-th single-cell sample. This represents the learnable bias vector of the feature encoder.
[0030] This initial latent vector retains the core biological feature information of the single-cell sample while eliminating some redundant noise. It is also compatible with the spatial aggregation operation of the subsequent ASAM module (adaptive spatial aggregation module), laying a suitable feature foundation for subsequent attention-weighted aggregation based on spatial neighborhood graphs and the generation of spatial perception features, ensuring the effective fusion of subsequent spatial topology information and cell features.
[0031] In this embodiment, determining the effective nearest neighbor cells of each single-cell sample based on the spatial neighborhood graph, and determining the attention coefficients of the effective nearest neighbor cells to the single-cell sample based on the attention mechanism, includes: determining each effective nearest neighbor cell of the current single-cell sample based on the spatial neighborhood graph, and sequentially determining each effective nearest neighbor cell as the current effective nearest neighbor cell; transforming the initial latent vector of the current single-cell sample and the initial latent vector of the current effective nearest neighbor cell using a spatial transformation matrix to obtain a first transformed matrix of the current single-cell sample and a second transformed matrix of the current effective nearest neighbor cell; concatenating the first transformed matrix and the second transformed matrix to obtain a concatenated vector; and obtaining the attention coefficients of the current effective nearest neighbor cells to the current single-cell sample using the attention weight vector and the concatenated vector to obtain the attention coefficients of each effective nearest neighbor cell to the current single-cell sample.
[0032] Based on the constructed spatial neighborhood graph, the effective nearest neighbors of the current single-cell sample are first determined, and these nearest neighbors are used as the effective neighbors of the single cell. Each effective nearest neighbor is then identified as the current effective nearest neighbor. Next, a preset spatial transformation matrix is used to linearly transform the initial latent vector of the current single-cell sample and the initial latent vector of the current effective nearest neighbors, respectively, to obtain the first transformed matrix of the current single-cell sample and the second transformed matrix of the current effective nearest neighbors. Then, the first transformed matrix and the second transformed matrix are concatenated to form a complete concatenated vector. Finally, a dot product operation is performed between the pre-set attention weight vector and this concatenated vector to obtain the attention coefficient of the current effective nearest neighbors for the current single-cell sample. The specific formula is shown below: ; In the formula, This represents the attention coefficient of the current effective nearest neighbor cell j to the current single-cell sample i. Represents the attention weight vector. Represents the spatial transformation matrix. This represents the initial hidden vector of the current single-cell sample i. Let represent the initial hidden vector of the current effective nearest neighbor cell j, and LeakyReLU represents the leaky ReLU activation function, which is used to introduce nonlinearity and alleviate the gradient vanishing problem, ensuring that the model can learn the differences in contributions of different nearest neighbors.
[0033] In this embodiment, the step of using the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells based on the attention coefficient includes: normalizing the attention coefficients of each effective nearest neighbor cell to the current single-cell sample to obtain the target contribution weight of each effective nearest neighbor cell to the current single-cell sample; and using the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells based on the target contribution weight.
[0034] After obtaining the attention coefficients of each effective neighbor cell for the current single-cell sample, these attention coefficients need to be locally normalized using softmax. Specifically, for the attention coefficients corresponding to all effective neighbor cells of the current single-cell sample, the softmax function is used to calculate and convert each attention coefficient into a value between 0 and 1. The sum of the normalized coefficients of all effective neighbor cells for the single-cell sample is always 1. This yields the target contribution weight of each effective neighbor cell to the current single-cell sample (i.e., the normalized attention weight), as shown in the following formula: ; In the formula, This represents the weight of the effective nearest neighbor cell j in relation to the target of the current single-cell sample i. This represents the attention coefficient of the effective nearest neighbor cell m to the current single-cell sample i.
[0035] The spatial aggregator (ASAM module) in the SCAPC model uses the target contribution weight as its core basis. It multiplies the initial latent vector of the current single cell sample, the initial latent vector of each effective neighbor cell, and the corresponding target contribution weight, and then sums all the weighted initial latent vectors. Finally, it obtains the spatial perception feature that integrates the core features of the current single cell sample and the spatial topological information of the effective neighbor cells. The specific formula is as follows: ; In the formula, This represents the spatial perception features of the current single-cell sample i. This represents the weight of the effective nearest neighbor cell j in relation to the target of the current single-cell sample i. Let represent the initial hidden vector of the effective nearest neighbor cell j. This represents a non-linear activation function.
[0036] This process ensures the rationality of weight allocation through normalization, and accurately distinguishes the feature contribution of effective neighboring cells by using the target contribution weight. It achieves adaptive aggregation of spatial features, effectively eliminates noise interference caused by lateral signal overflow, and provides a highly discriminative feature basis for subsequent cell type prediction and biological prior constraints.
[0037] Step S14: The classification decoder outputs the predicted type probability distribution of the single-cell sample based on the spatial perception features. The biological prototype features of the single-cell sample are weighted and summed using the predicted type probability distribution as the weight to generate reconstructed features.
[0038] The SCAPC model's classification decoder receives the spatial perception features of a single-cell sample output by the spatial aggregator. Through multi-layer nonlinear transformation and Softmax activation operation, it outputs the predicted type probability distribution of all preset cell types corresponding to the single-cell sample. This distribution reflects the model's confidence in the current cell's classification category.
[0039] In this embodiment, before the step of weighting and summing the biological prototype features of the single-cell sample using the predicted type probability distribution as weight to generate reconstructed features, the method further includes: statistically analyzing the average expression spectrum of each type of cell in the historical multiple tissue images, and determining the average expression spectrum of each type of cell as the biological prototype feature of each type of cell.
[0040] To address the issue of "biological illusions" arising from purely data-driven models, this paper combines prototype learning and physically aware neural networks. Before generating reconstructed features, biological prototype features are constructed. Prototype theory suggests that a category can be represented by the mean vector of all samples in the feature space. Physically aware neural networks emphasize that model predictions must conform to domain rules. In spatial proteomics, cell types are essentially defined by marker expression profiles. Therefore, for each cell type annotated in historical multiple tissue images, the average expression profile of all single-cell samples' spatial perception features or original expression features is statistically analyzed. This average expression profile is the biological prototype feature of the corresponding category; it is the standardized signature vector of that cell type in the feature space, carrying the inherent biological expression rules of that cell type (such as prior knowledge in the fields of high CD3 expression in T cells and high CD19 expression in B cells). After determining the average expression profile of each cell type as its biological prototype feature, a complete biological prototype matrix can be constructed. This provides a benchmark for subsequent generation of reconstructed features that conform to biological priors by weighting and summing the predicted type probability distribution, thereby constraining the model to learn feature representations that conform to biological rules and avoiding "biological illusion" predictions that violate cell type expression rules.
[0041] Finally, using the predicted type probability distribution y output by the classification decoder as weights, the biological prototype features of each type of cell in the biological prototype matrix are weighted and summed. That is, the biological prototype feature of each type of cell is multiplied by its corresponding predicted probability, and then all weighted prototype features are accumulated according to their dimensions to finally obtain the reconstructed features of the current single-cell sample. The specific formula is as follows: ; In the formula, Represents the reconstructed features of single-cell sample i. This represents the probability distribution of the predicted type for single-cell sample i. Indicates biological prototype characteristics. This represents the predicted probability that a single-cell sample i belongs to the k-th cell class, i.e. The k-th element in This represents the biological prototype characteristics of the k-th cell type.
[0042] This reconstructed feature integrates the class bias predicted by the model with biological prior knowledge, and is an ideal feature representation that conforms to the inherent expression rules of cell types, providing a benchmark for the subsequent calculation of prototype consistency loss.
[0043] Step S15: Use the prototype consistency constraint module to obtain the prototype consistency loss value based on the reconstruction features and the spatial awareness features.
[0044] In this embodiment, the step of obtaining the prototype consistency loss value based on the reconstructed features and the spatial awareness features using the prototype consistency constraint module includes: obtaining the mean squared error between the reconstructed features and the spatial awareness features of each single cell sample using the prototype consistency constraint module, and obtaining the average mean squared error of all single cell samples to obtain the prototype consistency loss value of the current cell annotation model.
[0045] The Prototype Consistency Constraint Module (PIPC) first obtains the reconstructed features generated by weighted summation for each single-cell sample and the spatially perceived features obtained by adaptive aggregation through a spatial aggregator. It then calculates the difference between the two features dimension by dimension and squares the difference. Finally, it sums the squared values across all dimensions to obtain the mean squared error of a single sample. This process is repeated for all single-cell samples. The arithmetic mean of the mean squared errors of all single-cell samples is then taken to obtain the prototype consistency loss value of the current SCAPC model. The specific formula is shown below: ; In the formula, This represents the prototype consistency loss value.
[0046] This loss value serves as a regularization term to constrain model training, forcing spatially perceived features to align with reconstructed features that conform to biological priors. This fundamentally avoids the "biological illusion" problem caused by purely data-driven models, ensuring that the model's prediction results both fit the data distribution and conform to the inherent marker expression patterns of cell types.
[0047] Step S16: Update the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model, and jump back to the step of inputting the full graph feature matrix and the spatial neighborhood graph into the current cell annotation model until the preset stopping condition is met, and determine the new current cell annotation model as the target cell annotation model.
[0048] In this embodiment, updating the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model includes: obtaining the classification cross-entropy loss value of the current cell annotation model based on the error between the predicted type probability distribution and the true cell type of each single cell sample; determining the sum of the prototype consistency loss value and the classification cross-entropy loss value as the total loss value; and updating the current cell annotation model with the goal of minimizing the total loss value to obtain a new current cell annotation model.
[0049] First, the classification decoder outputs the predicted type probability distribution of a single-cell sample. This distribution is then compared with the true cell type label corresponding to each single-cell sample. The error between the two is calculated using the classification cross-entropy formula, yielding the classification cross-entropy loss value of the current SCAPC model. This loss value is used to measure the accuracy of the model's cell type prediction. The specific formula is shown below: ; In the formula, This represents the classification cross-entropy loss value. This represents the actual probability that a single-cell sample i belongs to the k-th cell type, i.e., the true cell type label, or the one-hot encoding of the true label. This represents the predicted probability that single-cell sample i belongs to the k-th cell class.
[0050] The prototype consistency loss value calculated by the prototype consistency constraint module is then weighted and summed with the classification cross-entropy loss value. The sum of the two is determined as the total loss value, which takes into account both the model's classification accuracy and biological prior constraints. The specific formula is as follows: ; In the formula, This represents the total loss value. This represents the classification cross-entropy loss value. This represents the prototype consistency loss value. The hyperparameters, or weights, represent the control over the strength of biological prior constraints.
[0051] Next, with the goal of minimizing the total loss, the learnable parameters of modules such as the feature encoder, spatial aggregator, and classification decoder in the SCAPC model are updated through backpropagation to obtain the updated current cell annotation model. The model can not only learn the discriminative boundary to distinguish cell types, but also internalize domain knowledge, achieving the unity of data-driven and knowledge-driven approaches. Then, the process jumps back to the step of inputting the full-map feature matrix and spatial neighborhood graph into the current cell annotation model, and repeats the iterative process of feature encoding, spatial aggregation, classification prediction, loss calculation, and parameter updating until the preset stopping conditions are met (such as reaching the upper limit of the number of iterations, the loss value converging to below the threshold, etc.). Finally, the new current cell annotation model that meets the conditions is determined as the target cell annotation model. This model has both high-precision cell type classification ability and strictly follows biological prior rules, effectively avoiding the "biological illusion" problem.
[0052] Step S17: Use the target cell annotation model to annotate the current multi-tissue image with cell types.
[0053] The current multi-tissue image to be annotated undergoes the same preprocessing procedure as historical images. Specifically, cell segmentation is performed to obtain a set of single-cell samples. The in-situ expression intensity of markers and morphological features of each single cell are extracted to construct a full-image feature matrix. A spatial neighborhood map is constructed based on the two-dimensional coordinates of the cell centroid and the K-nearest neighbor method. Subsequently, the full-image feature matrix and the spatial neighborhood map are input into the trained target cell annotation model (SCAPC). The model sequentially passes through a feature encoder to generate an initial latent vector, a spatial aggregator to generate spatially perceptual features that fuse spatial topological information, and a classification decoder to output the predicted type probability distribution of each single-cell sample corresponding to each type of cell. Finally, the category with the highest predicted probability for each single-cell sample is selected as its final cell type label, completing the cell type annotation of all single cells in the current multi-tissue image. This annotation process utilizes both the cell's own features and spatial microenvironment information, and is subject to biological prior constraints to ensure compliance of the results. It can accurately and reliably complete cell type annotation in high-density tissue scenes.
[0054] The beneficial effects of this application are as follows: This application performs cell segmentation on historical multi-tissue images to obtain single-cell samples, and constructs a full-image feature matrix and a spatial neighborhood map based on the cell's own characteristics and spatial location. The full-image feature matrix and the spatial neighborhood map are input into the current cell annotation model. The current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module. The feature encoder maps the full-image feature matrix into an initial latent vector. Based on the spatial neighborhood map, the effective nearest neighbor cells of each single-cell sample are determined, and the attention coefficient of the effective nearest neighbor cells on the single-cell sample is determined based on an attention mechanism. The spatial aggregator performs a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells based on the attention coefficients. The process involves: obtaining the spatial awareness features of the single-cell sample; using the classification decoder to output the predicted type probability distribution of the single-cell sample based on the spatial awareness features; weighting the biological prototype features of the single-cell sample with the predicted type probability distribution as weights to generate reconstructed features; using the prototype consistency constraint module to obtain the prototype consistency loss value based on the reconstructed features and the spatial awareness features; updating the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model; returning to the step of inputting the full-image feature matrix and the spatial neighborhood graph into the current cell annotation model until a preset stopping condition is met, and determining the new current cell annotation model as the target cell annotation model; and using the target cell annotation model to annotate the current multi-tissue image with cell types.Therefore, this application obtains single-cell samples by segmenting historical multi-tissue images, constructs a full-image feature matrix and a spatial neighborhood map, and inputs them into a cell annotation model containing a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module. After the feature encoder maps the initial latent vector, effective neighboring cells are determined based on the spatial neighborhood map. Attention coefficients are obtained through an attention mechanism, and then the spatial aggregator weights and sums the initial latent vectors to obtain spatially perceptual features. Adaptive spatial aggregation is achieved by combining the spatial neighborhood map with the attention mechanism, which can accurately distinguish the effective signals of neighboring cells from spillover noise, fundamentally solving the feature aliasing problem caused by lateral signal spillover, and significantly improving the annotation accuracy of densely celled regions. Subsequently, the classification decoder outputs the predicted type probability distribution and uses it to generate reconstructed features. The prototype consistency constraint module obtains the original features based on the reconstructed features and spatially perceptual features. The model employs a prototype consistency loss value, transforming discrete biological priors into differentiable mathematical constraints. This prototype consistency loss forces the model predictions to follow biological laws, completely avoiding the biological illusion problem of purely data-driven models and ensuring the biological rationality and fidelity of the annotation results. The model is iteratively updated until it meets preset conditions to obtain the target model, which is ultimately used for cell type annotation of current multi-tissue images. The model adopts end-to-end collaborative training, with each module optimized in tandem, balancing feature extraction accuracy and computational efficiency of local graph structure operations. It is suitable for processing large-scale spatial proteomics datasets, significantly improving the model's robustness and generalization ability. The ability to identify rare and easily confused cell phenotypes is significantly enhanced, achieving a dual improvement in the automation and precision of cell annotation. This provides reliable technical support for spatial proteomics research and effectively solves the core technical pain points of traditional methods.
[0055] In a specific model performance comparison, this embodiment compared its method with three highly representative state-of-the-art methods on four benchmark datasets: cHL1_MIBI, cHL2_MIBI, cHL_CODEX, and CRC_CODEX (classical Hodgkin Lymphoma, cHL, and colorectal cancer, CRC). This fully validated the superiority of the method presented in this embodiment. The quantitative performance (mean ± standard deviation) on the four datasets is shown in Table 1, where the best results are indicated in bold and the second-best results are indicated by underline. Table 1. Comparison of Results
[0056] These benchmark methods cover different learning paradigms: ASTIR, as a representative of semi-supervised learning, utilizes prior biological knowledge to automate cell classification, representing a knowledge-driven approach. CellSighter and MAPS, as representatives of supervised learning, are based on deep neural networks for feature extraction, representing a purely data-driven approach. The results show that the deep learning-based supervised methods (MAPS and CellSighter) significantly outperform the semi-supervised method ASTIR overall, indicating that data-driven feature extraction has a natural advantage in capturing complex cell phenotypes. However, even the best-performing baseline method, MAPS, experienced a performance decline (F1 score of 0.768) when handling the complex CRC_CODEX dataset, possibly due to neglecting spatial dependencies between cells. In contrast, the SCAPC method in this embodiment aggregates neighborhood information through graph attention and combines prior knowledge constraints to learn more discriminative and biologically consistent feature representations, thus significantly improving classification performance. Overall, the SCAPC method outperforms competing methods across all four datasets in three key metrics, demonstrating superior generalization ability.
[0057] In addition, such as Figure 3 Further fine-grained analysis revealed that SCAPC not only maintained high accuracy in dominant categories (such as Tumors) but also demonstrated significant advantages in identifying rare and easily confused phenotypes. Specifically, for DC / NK cells in cHL2_MIBI and Neutrophils / Tregs in cHL_CODEX, SCAPC effectively corrected common classification confusions in baseline models by modeling the microenvironmental context. This strongly confirms the model's robustness and balance in addressing the challenges of class imbalance and high similarity.
[0058] To intuitively evaluate the comprehensive capabilities of SCAPC, a multi-dimensional qualitative evaluation was conducted on the cHL_CODEX dataset. In terms of spatial fidelity, the predicted cell phenotype atlas showed a high degree of consistency with the real data. The model successfully captured complex tissue structures and accurately delineated the boundaries between tumor nests and the stroma; this validates the effectiveness of the graph attention mechanism in preserving local spatial details. Regarding biological consistency, the predicted marker expression heatmap closely matched the real data, demonstrating extremely high fidelity. This is attributed to the prototype consistency constraint module, which constrains the model to learn biologically meaningful representations rather than simply overfitting to statistical distributions.
[0059] On the one hand, this application constructs a spatial adjacency graph based on a graph attention mechanism on the cHL_CODEX dataset, and solves the problems of signal overflow and feature aliasing through an adaptive spatial aggregation mechanism that dynamically calculates weights. Specifically, an adjacency graph is constructed based on cell spatial coordinates, and weights are dynamically allocated using a graph attention mechanism. Combined with the differences in protein expression in local tissues, interference signals are adaptively suppressed and effective features are extracted, avoiding signal bias caused by fixed aggregation. At the same time, graph structure modeling is used to achieve deep fusion of cell features and spatial topological information, ensuring the accuracy and rationality of cell feature extraction.
[0060] On the other hand, this application utilizes a physics-inspired prototype constraint strategy to transform biological common sense into quantifiable model constraints. By extracting the average expression profile of cells from historical data as biological prototype features, discrete biomarker rules are transformed into continuous and computable loss function constraints. Through prototype consistency loss linked with the classifier, predictions that do not conform to biological logic are avoided, ensuring that cell classification results conform to actual physiological laws and fundamentally improving the reliability of model predictions.
[0061] Furthermore, this application utilizes the trained target model to annotate cell types in current multi-tissue images. First, it constructs adaptive full-image features and spatial neighborhood relationships through preprocessing, and then outputs cell type probability distributions through model inference, combining the highest probability category to complete accurate annotation. At the same time, it verifies the rationality of the model's predictions through qualitative visualization. Relying on spatial topology modeling and biological prior constraints, it achieves efficient and compliant cell type identification, effectively avoiding unreasonable predictions and ensuring the accuracy and reliability of cell annotation.
[0062] See Figure 4 As shown in the figure, this application discloses a cell type annotation device, including: The feature construction module 11 is used to perform cell segmentation on historical multi-tissue images to obtain single-cell samples, and to construct a full-image feature matrix and a spatial neighborhood map based on the cell features and spatial location of the single-cell samples. The model input module 12 is used to input the full-image feature matrix and the spatial neighborhood graph into the current cell annotation model; wherein, the current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module; The feature acquisition module 13 is used to map the full-image feature matrix into an initial latent vector using the feature encoder, determine the effective nearest neighbor cells of each single-cell sample based on the spatial neighborhood graph, determine the attention coefficient of the effective nearest neighbor cells to the single-cell sample based on the attention mechanism, and use the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficients to obtain the spatial perception features of the single-cell sample. The feature reconstruction module 14 is used to use the classification decoder to output the predicted type probability distribution of the single cell sample based on the spatial perception features, and to perform weighted summation of the biological prototype features of the single cell sample with the predicted type probability distribution as weight to generate reconstructed features. The loss value acquisition module 15 is used to acquire the prototype consistency loss value based on the reconstruction features and the spatial perception features using the prototype consistency constraint module. Model optimization module 16 is used to update the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model, and then jump back to the step of inputting the full-map feature matrix and the spatial neighborhood graph into the current cell annotation model until the preset stopping condition is met, and the new current cell annotation model is determined as the target cell annotation model. The type annotation module 17 is used to annotate the current multi-tissue image with cell types using the target cell annotation model.
[0063] Furthermore, embodiments of this application also provide an electronic device. Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0064] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the cell type annotation method performed by the electronic device disclosed in any of the foregoing embodiments.
[0065] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0066] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0067] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.
[0068] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system can be Windows, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the cell type annotation method executed by the electronic device as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.
[0069] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed cell type annotation method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0070] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0071] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application. The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly in hardware, software modules executed by a processor, or a combination of both. The software module may be located in random access memory (RAM), memory, read-only memory (ROM), electrically programmable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), register, hard disk, removable disk, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium known in the art.
[0072] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0073] The present invention has provided a detailed description of a cell type annotation method, apparatus, device, and medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only intended to help understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A cell type annotation method, characterized in that, include: Cell segmentation is performed on historical multi-tissue images to obtain single-cell samples, and a full-image feature matrix and spatial neighborhood map are constructed based on the cell characteristics and spatial location of the single-cell samples. The full-image feature matrix and the spatial neighborhood graph are input into the current cell annotation model; wherein, the current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module; The feature encoder maps the full-image feature matrix into an initial latent vector. Based on the spatial neighborhood graph, the effective nearest neighbor cells of each single-cell sample are determined. The attention coefficient of the effective nearest neighbor cells to the single-cell sample is determined based on the attention mechanism. The spatial aggregator performs a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficients to obtain the spatial perception features of the single-cell sample. The classification decoder outputs the predicted type probability distribution of the single-cell sample based on the spatial perception features. The biological prototype features of the single-cell sample are weighted and summed using the predicted type probability distribution as weights to generate reconstructed features. The prototype consistency constraint module is used to obtain the prototype consistency loss value based on the reconstructed features and the spatial awareness features. The current cell annotation model is updated based on the prototype consistency loss value to obtain a new current cell annotation model. Then, the process jumps back to the step of inputting the full-map feature matrix and the spatial neighborhood graph into the current cell annotation model until the preset stopping condition is met, and the new current cell annotation model is determined as the target cell annotation model. The target cell annotation model is used to annotate cell types in the current multi-tissue image.
2. The cell type annotation method according to claim 1, characterized in that, The process of segmenting historical multi-tissue images into single-cell samples and constructing a full-image feature matrix and a spatial neighborhood map based on the cell characteristics and spatial location of the single-cell samples includes: Cell segmentation is performed on historical multi-tissue images to obtain a sample set; wherein each single-cell sample in the sample set is a node; A full-map feature matrix is constructed using the cell-specific features of the single-cell samples; wherein, the cell-specific features include the in situ expression intensity and morphological features of the markers; The spatial location of a single cell sample is encoded using the two-dimensional coordinates of its centroid. Based on the spatial location of the cell, the effective nearest neighbor cells of each single cell sample are determined using the K-nearest neighbor method. Connection edges between the single cell sample and its corresponding effective nearest neighbor cells are constructed to obtain a spatial neighborhood graph.
3. The cell type annotation method according to claim 1, characterized in that, The step of determining the effective nearest neighbor cells for each single-cell sample based on the spatial neighborhood map, and determining the attention coefficient of the effective nearest neighbor cells to the single-cell sample based on the attention mechanism, includes: Based on the spatial neighborhood map, determine each effective nearest neighbor cell of the current single-cell sample, and sequentially determine each effective nearest neighbor cell as the current effective nearest neighbor cell; The initial latent vector of the current single-cell sample and the initial latent vector of the current effective nearest neighbor cell are transformed using a spatial transformation matrix to obtain the first transformed matrix of the current single-cell sample and the second transformed matrix of the current effective nearest neighbor cell. The first transformed matrix and the second transformed matrix are then concatenated to obtain a concatenated vector. The attention coefficients of the current effective neighbor cells to the current single-cell sample are obtained by using the attention weight vector and the splicing vector, so as to obtain the attention coefficients of each effective neighbor cell to the current single-cell sample.
4. The cell type annotation method according to claim 3, characterized in that, The step of using the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells based on the attention coefficient includes: The attention coefficients of each effective neighbor cell to the current single-cell sample are normalized to obtain the target contribution weight of each effective neighbor cell to the current single-cell sample. The spatial aggregator is used to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the target contribution weight.
5. The cell type annotation method according to claim 1, characterized in that, Before generating the reconstructed features by weighting and summing the biological prototype features of the single-cell sample using the predicted type probability distribution as weights, the method further includes: The average expression profile of each cell type in the historical multiple tissue images is statistically analyzed, and the average expression profile of each cell type is determined as the biological prototype feature of each cell type.
6. The cell type annotation method according to claim 1, characterized in that, The step of using the prototype consistency constraint module to obtain the prototype consistency loss value based on the reconstructed features and the spatial awareness features includes: The prototype consistency constraint module is used to obtain the mean squared error between the reconstructed features and the spatial awareness features of each single cell sample, and the average mean squared error of all single cell samples is obtained to obtain the prototype consistency loss value of the current cell annotation model.
7. The cell type annotation method according to any one of claims 1 to 6, characterized in that, The step of updating the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model includes: The classification cross-entropy loss value of the current cell annotation model is obtained based on the error between the predicted type probability distribution and the true cell type of each single cell sample. The sum of the prototype consistency loss value and the classification cross-entropy loss value is determined as the total loss value, and the current cell annotation model is updated with the goal of minimizing the total loss value to obtain a new current cell annotation model.
8. A cell type annotation device, characterized in that, include: The feature construction module is used to perform cell segmentation on historical multi-tissue images to obtain single-cell samples, and to construct a full-image feature matrix and a spatial neighborhood map based on the cell features and spatial location of the single-cell samples. The model input module is used to input the full-image feature matrix and the spatial neighborhood graph into the current cell annotation model; wherein, the current cell annotation model includes a feature encoder, a spatial aggregator, a classification decoder, and a prototype consistency constraint module; The feature acquisition module is used to map the full-image feature matrix into an initial latent vector using the feature encoder, determine the effective nearest neighbor cells of each single-cell sample based on the spatial neighborhood graph, determine the attention coefficient of the effective nearest neighbor cells to the single-cell sample based on the attention mechanism, and use the spatial aggregator to perform a weighted summation of the initial latent vectors of the single-cell sample and the corresponding effective nearest neighbor cells according to the attention coefficients to obtain the spatial perception features of the single-cell sample. The feature reconstruction module is used to use the classification decoder to output the predicted type probability distribution of the single cell sample based on the spatial perception features, and to perform a weighted summation of the biological prototype features of the single cell sample with the predicted type probability distribution as the weight to generate reconstructed features. The loss value acquisition module is used to acquire the prototype consistency loss value based on the reconstruction features and the spatial perception features using the prototype consistency constraint module. The model optimization module is used to update the current cell annotation model based on the prototype consistency loss value to obtain a new current cell annotation model, and then jump back to the step of inputting the full-map feature matrix and the spatial neighborhood graph into the current cell annotation model until the preset stopping condition is met, and the new current cell annotation model is determined as the target cell annotation model. The type annotation module is used to annotate the current multi-tissue image with cell types using the target cell annotation model.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the cell type annotation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program; wherein, when executed by a processor, the computer program implements the steps of the cell type annotation method as described in any one of claims 1 to 7.