Multi-head double-path attention method, system and device for spatial domain recognition and medium

By employing a multi-head dual-path attention method, combining the dual-path structure of local and augmented graphs with contrastive learning, the shortcomings of existing methods in recognizing high-order spatial dependencies and deep expression patterns are addressed, achieving more accurate spatial domain recognition and gene expression reconstruction.

CN121545580APending Publication Date: 2026-02-17QUFU NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511706615.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-20
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing spatial domain recognition methods struggle to capture high-order spatial dependencies and lack the ability to infer deep representation patterns, resulting in insufficient accuracy and robustness in spatial domain recognition.

Method used

We employ a multi-head dual-path attention method, which constructs local adjacency graphs and augmented adjacency graphs, combines view-level attention mechanisms and multi-head graph attention mechanisms, introduces contrastive learning and spatial regularization, and utilizes ZINB reconstruction to achieve accurate modeling of spatial structures.

Benefits of technology

It improves the accuracy and robustness of spatial domain identification, better captures direct neighborhood interactions and potential long-range high-order dependencies, enhances resistance to data noise and technical variations, and improves the accuracy of gene expression reconstruction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121545580A_ABST
    Figure CN121545580A_ABST
Patent Text Reader

Abstract

The invention provides a multi-head double-path attention method, system and device for spatial domain recognition and a medium, and belongs to the technical field of biological information and computers. The method comprises the following steps: firstly, constructing a local adjacency graph and an augmented adjacency graph based on spatial transcriptome coordinates and gene expression; then dynamically fusing the double-path features by view-level attention, then applying multi-view attention in parallel, and capturing multi-subspace information; the double-layer progressive coding further depicts high-order spatial dependence; and finally introducing comparative learning, spatial regularization and ZINB gene expression reconstruction combined training, and outputting robust low-dimensional embedding to realize accurate spatial domain identification. According to the multi-head double-path attention method, system, equipment and medium for spatial domain recognition, experiments show that the stMDGC is superior to an existing spatial domain recognition method in the aspects of accuracy and robustness, and the effectiveness of the stMDGC under different biological backgrounds is verified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of bioinformatics and computer technology, and in particular to a multi-head dual-path attention method, system, device and medium for spatial domain recognition. Background Technology

[0002] In multicellular organisms, the spatial distribution of gene expression is crucial for maintaining tissue structure and regulating cellular function. The spatial environment not only regulates transitions in cellular state but also shapes the functional characteristics of intercellular communication and local microenvironments. While single-cell RNA sequencing (scRNA-seq) technology has greatly enhanced our understanding of cellular heterogeneity, its inherent tissue dissociation process leads to the loss of critical spatial location information, thus limiting the holistic analysis of tissue spatial structure and functional compartmentalization.

[0003] The emergence of spatial transcriptomics (ST) technology has provided a powerful tool for large-scale gene expression profiling while preserving the in situ structure of tissues. Current ST technologies are mainly divided into two categories: imaging-based methods (such as MERFISH and STARmap) offer high resolution but may be limited by image quality; sequencing-based methods (such as 10X Visium) enable high-throughput analysis. One of the core analytical tasks of the data generated by these technologies is to identify functionally related but transcriptionally distinct regions within tissues, i.e., spatial domains.

[0004] However, ST data typically exhibits characteristics such as high dimensionality, sparsity, high noise levels, and inter-platform technical variability, posing challenges to robust spatial domain recognition. Traditional clustering methods (such as BayesSpace) improve spatial consistency to some extent by introducing spatial smoothness priors, but often struggle to capture the deep, complex structure of the data. In recent years, deep learning-based methods have shown significant advantages. Some methods (such as stLearn and SpaGCN) attempt to integrate histological image information, but their performance is highly dependent on image quality. Another class of methods based solely on ST data avoids this constraint, for example: STAGATE employs a graph attention autoencoder to jointly model spatial and transcriptomic information; GraphST combines graph neural networks with contrastive learning to bring spatially neighboring points closer together in their embeddings; SEDR uses variational graph autoencoders to model spatial relationships.

[0005] While these methods have advanced the field, they generally suffer from two key limitations: Failure to fully capture higher-order spatial dependencies: Most existing methods focus on local direct adjacency relationships, ignoring long-range interactions and cross-regional functional associations that may exist in the organization.

[0006] Lack of inference ability for deep spatial representation patterns: The model structure limits its ability to resolve complex and implicit spatial representation relationships in structured organizations.

[0007] Therefore, there is an urgent need in this field for a new method that can effectively model higher-order spatial dependencies and deeply mine complex spatial patterns in ST data in order to achieve more accurate and robust spatial domain identification. Summary of the Invention

[0008] The purpose of this invention is to provide a multi-head dual-path attention method, system, device, and medium for spatial domain identification. Addressing the shortcomings of existing spatial domain identification methods in capturing high-order spatial dependencies and lacking the ability to infer deep expression patterns, this invention proposes a multi-head dual-path attention framework. Utilizing progressive encoding of local and augmented dual graphs, combined with contrastive learning and ZINB reconstruction, it accurately models the spatial structure of tissues, achieving high-fidelity spatial domain partitioning and providing a new means for analyzing the spatial heterogeneity of tissue functional microregions and diseases.

[0009] To achieve the above objectives, this invention provides a multi-head dual-path attention method for spatial domain recognition, abbreviated as stMDGC, which includes the following steps: Step S1: Based on the tissue coordinates and gene expression information of the spatial transcriptome data, construct the local adjacency graph and the augmented adjacency graph; Step S2: Using the local adjacency graph and the augmented adjacency graph as two independent views, a view-level attention mechanism is adopted to dynamically learn and fuse the node features of the two views to generate a comprehensive feature representation of each node. Step S3: The comprehensive feature representation is used as the input to the local adjacency graph and the augmented adjacency graph, respectively. A multi-head graph attention mechanism is applied in parallel to capture information from different subspaces. The outputs of all attention heads are fused to obtain the node embedding representation of the first layer. Step S4: Repeat steps S1 to S3 with the first-layer node embedding representation as input to generate the second-layer node embedding representation; Step S5: Based on the second-layer node embedding representation, a contrastive learning module, a spatial regularization constraint, and a gene expression reconstruction module are introduced for joint training; by optimizing the overall objective function that combines contrastive loss, spatial regularization loss, and ZINB loss, a low-dimensional embedding representation for spatial domain recognition is obtained.

[0010] Preferably, step S1 specifically includes: When constructing a local adjacency graph, its adjacency matrix Euclidean distance calculation based on spatial coordinates is specifically as follows: for nodes With nodes If the Euclidean distance between the two is less than or equal to the predefined radius Then its corresponding adjacency matrix elements ,otherwise ; When constructing an augmenting adjacency graph, its adjacency relationships are determined using Jaccard similarity filtering. The formula for calculating Jaccard similarity is: ; in, Represents a node With nodes Jaccard similarity, Represents a node The set of direct neighbors, Represents a node The set of direct neighbors.

[0011] Preferably, step S2 specifically includes: For local views, a Gaussian kernel-based attention function is used to compute nodes. Its neighboring nodes raw attention scores between : ; Wherein, the initial input features are defined as , This is the original gene expression matrix. elements in This represents the original gene expression value of the corresponding node. The total number of nodes. For the original feature dimension, Represents the set of real numbers. Represent a OK The set of real matrices of columns, and let , , , express A 3D real vector space, Indicates the original 3D feature mapping to the transformed The characteristic transformation matrix of the dimensional space, Represents the attention weight vector. Represents nodes in a partial view The set of neighbors, i.e., the set of direct neighbors; For augmented views, standard graph attention network computation nodes are used. Its neighboring nodes raw attention scores between : ; in, Represents the characteristic transformation matrix. Represents the attention weight vector. Represents nodes in the augmented view The set of neighbors, i.e., the augmented neighbor set; The original attention scores of the local view and the augmented view are normalized to obtain standardized attention weights. Based on standardized attention weights, local view embeddings are generated by aggregation. and augmented view embedding : The global importance scores of the two views are calculated and normalized to obtain the fusion weights. Finally, the comprehensive feature representation is obtained by weighted summation.

[0012] Preferably, step S3 specifically includes: Use multiple independent attention heads to process input features in parallel; Each attention head generates a corresponding node embedding representation according to the process in step S2; Embed the outputs of all attention heads and perform a splicing operation; A nonlinear activation function is applied to the concatenated result to obtain the final node embedding representation of the first layer.

[0013] Preferably, the specific execution process in step S5 includes: The contrastive learning module treats the outputs of different attention heads as different views and defines positive and negative sample pairs based on spatial proximity. Total comparative loss It is the sum of the losses for each view pair: ; in, Indicates the number of views. Indicates the total number of nodes. Iterate from 2 to 1. , representing the number of each view. From 1 to Traversal, representing the number of each spatial node in the data. Represents a node Feature embedding in the first view, Represents a node In the traversal of the th Feature embedding in each view; Space regularization loss It is used to constrain adjacent nodes to stay close in the embedding space, and its calculation formula is based on the cosine similarity between the node embedding and its neighbor embedding. ; in, Indicates belonging to a node The node number of the direct neighbor. Indicates that it does not belong to a node. The node number of the direct neighbor. The cosine similarity matrix representing the latent embeddings of the th Line number The elements of a column, i.e., nodes With nodes Cosine similarity in the latent embedding space The cosine similarity matrix representing the latent embeddings of the th Line number The elements of a column, i.e., nodes With nodes Cosine similarity in the latent embedding space This represents the sigmoid activation function. Represents a node The set of direct neighbors; The gene expression reconstruction module uses a ZINB decoder to reconstruct gene expression data from the second-layer node embeddings and calculates the ZINB loss. ; in, This represents the ZINB reconstruction loss obtained using the ZINB decoder. Represents gene expression data, Represents the ZINB distribution. Indicates the probability of zero inflation. The parameter representing the mean of the negative binomial components. The discrete parameters of the negative binomial distribution are represented. The overall objective function is the weighted sum of the above losses. : ; in, , and This represents the weighting factor.

[0014] This invention also provides a multi-head dual-path attention system for spatial domain recognition, comprising: The data preprocessing module is used to read tissue coordinate information and gene expression matrix from spatial transcriptome data, and to perform quality control, normalization, and screening for highly variable genes. The dual-path graph construction module, connected to the data preprocessing module, is used to construct a local adjacency graph based on Euclidean distance and an augmented adjacency graph based on Jaccard similarity, and output two sets of adjacency matrices. The view-level attention fusion module, connected to the dual-path graph construction module, is used to run Gaussian kernel attention and standard graph attention mechanisms on the local adjacency graph and the augmented adjacency graph respectively. After obtaining two sets of node embeddings, the learnable view weights are used to dynamically fuse them to generate a comprehensive feature representation. The multi-head graph attention encoding module, connected to the view-level attention fusion module, is used to execute the multi-head graph attention mechanism in parallel on the local graph and the augmented graph, splicing the outputs of the multi-head graph and passing them through non-linear activation to obtain the first layer of node embedding; A two-layer progressive encoding module, connected to a multi-head graph attention encoding module, is used to send the first-layer node embeddings back into the dual-path graph construction module, the view-level attention fusion module, and the multi-head graph attention encoding module to form a second-layer node embedding, in order to capture higher-order spatial dependencies. The contrastive learning and regularization module, connected to the two-layer progressive encoding module, is used to treat the outputs of different attention heads as multiple views and construct positive and negative sample pairs based on spatial proximity to calculate the contrastive loss; at the same time, spatial regularization loss is introduced to constrain the distance between adjacent nodes in the embedding space. The gene expression reconstruction module is connected to the two-layer progressive coding module and has a built-in zero-inflated negative binomial decoder, which is used to embed and map the second-layer nodes back into the gene expression space and calculate the ZINB loss. The joint optimization and output module, connected to the contrastive learning and regularization module and the gene expression reconstruction module, is used to weight and sum the contrastive loss, spatial regularization loss and ZINB loss to form the overall objective function, train the entire system through backpropagation, and output the final low-dimensional embedding representation.

[0015] The present invention also provides a computer device including a memory and a processor, the memory being used to store instructions and the processor being used to execute the instructions to implement the multi-head dual-path attention method for spatial domain recognition as described above.

[0016] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the multi-head dual-path attention method for spatial domain recognition as described above.

[0017] Therefore, the multi-head dual-path attention method, system, device, and medium for spatial domain recognition described above in this invention have the following beneficial technical effects: (1) By constructing a dual-path structure of local graph and augmented graph, and constructing a view-level attention mechanism, and integrating it with the multi-head graph attention mechanism, this invention can simultaneously capture direct neighborhood interactions and potential long-range high-order dependencies in space, thereby learning a deep feature representation that combines local details and global consistency, overcoming the shortcomings of the limited feature extraction capabilities of existing methods.

[0018] (2) By introducing a joint optimization strategy of contrastive learning and spatial regularization, the model can effectively distinguish between similar and dissimilar regions and maintain the spatial neighborhood structure, which enhances the model's resistance to data noise and technical variations. This results in clustering accuracy and biological consistency on various real datasets that are superior to existing mainstream methods.

[0019] (3) The present invention uses the zero-inflated negative binomial (ZINB) model as a decoder, which accurately fits the over-dispersion and zero-inflated characteristics that are common in spatial transcriptome data, making the reconstruction of gene expression more accurate, thereby improving the ability to extract real biological signals from the data and providing a more reliable basis for downstream analysis. Attached Figure Description

[0020] Figure 1 This is a flowchart illustrating the stMDGC process. Figure 2 The results of a comparative experiment between stMDGC and six other spatial domain recognition models on a mouse anterior brain dataset are shown. Figure 2 (A) in the image is the Allen atlas of the mouse forebrain. Figure 2 (B) in the figure represents the spatial domain results of a manually annotated mouse prefrontal brain dataset. Figure 2 (C) in the figure is a bar chart of ARI and NMI values ​​for the seven methods. Figure 2 (D) in the figure represents the clustering visualization results of seven methods on a mouse forebrain dataset. Figure 2 (E) in the image represents the visualization of the selected differentially expressed genes (DEGs). Figure 3 The results of a comparative experiment between stMDGC and seven other spatial domain recognition models on a human breast cancer dataset are shown. Figure 3 In the image (A), the histological image of the dataset is shown. Figure 3 (B) in the image represents the manually labeled result. Figure 3 (C) in the table represents the ARI and NMI index results for eight methods. Figure 3 (D) in the diagram represents the clustering visualization result; Figure 4 The results of heterogeneity analysis of stMDGC on the human breast cancer dataset are shown, where (A) is a bubble chart of selected differentially expressed genes (DEGs). Figure 4 (B) in the figure is a volcano plot showing the difference between clusters 3 and 7. Figure 4 In the diagram, (C) represents the differential gene expression identified by stMDGC between cluster 1 and cluster 19. Figure 4 (D) in the figure represents the differential gene expression identified by stMDGC between cluster 3 and cluster 7; Figure 5The results of the comparative experiment between stMDGC and seven other spatial domain recognition models on a mouse visual cortex dataset are shown. Figure 5 (A) in the diagram is the mouse visual cortex reference area map of the Allen atlas. Figure 5 (B) in the figure represents the spatial domain results of a manually annotated mouse visual cortex dataset. Figure 5 (C) in the figure is a bar chart visualizing the ARI and NMI values ​​of eight methods on a mouse visual cortex dataset. Figure 5 (D) in the figure represents the clustering visualization results of eight methods in the visual cortex. Figure 5 (E) in the figure represents the visualization results of the marker genes identified by stMDGC at each layer. Detailed Implementation

[0021] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0022] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.

[0023] Example 1 like Figure 1 As shown, the multi-head dual-path attention method for spatial domain recognition includes the following steps: Step S1: Based on tissue coordinates and gene expression information from spatial transcriptome data, a local adjacency graph is constructed using the K-nearest neighbor algorithm to characterize direct interactions between spatially adjacent locations. Simultaneously, an augmented adjacency graph is constructed, utilizing the expression similarity of higher-order neighbor genes to model long-range dependencies and capture higher-order spatial relationships. The complementary structures of these two types of graphs provide a foundation for subsequent feature learning.

[0024] Step S1 specifically includes: Step 1.1: Since adjacent points often exhibit similar expression patterns, stMDGC employs two different methods to construct adjacency graphs to utilize this spatial information. The first method generates a local adjacency graph, represented as... It includes a selected node and its direct neighbors. Among them, The gene expression matrix and adjacency matrix are from the original input. Based on nodes With another node Euclidean distance calculation between them, with a predefined radius As a distance threshold. Specifically, if the node and nodes The distance between them is less than or equal to Then the node is considered It is a node The direct neighbors are used to obtain the adjacency matrix. The elements corresponding to the two nodes ;otherwise .

[0025] Step 1.2: stMDGC considers not only direct neighbors but also indirect neighbors, thus constructing an augmenting adjacency graph, represented as... Augmented Adjacency Graph By node It consists of its direct neighbors and second-order subsets, based on nodes. Second-order neighborhoods are identified by their Jaccard similarity to their second-order neighbors. A predefined threshold is applied; if the Jaccard similarity value exceeds this threshold, the corresponding node is considered to be related to node [unclear - likely a specific node name]. They are highly similar and are included in their extended neighborhood.

[0026] ; in, Represents a node With nodes Jaccard similarity, Represents a node The set of direct neighbors, Represents a node The direct neighbor set, nodes It is a node The second-order neighbor.

[0027] Step S2: To fully integrate information from local and augmented paths, a view-level attention mechanism is used to adaptively learn the weight contributions of the two paths in the feature representations of different nodes. Through dynamic weighted fusion, a comprehensive feature representation that combines local dependencies and global context is generated, thereby more comprehensively reflecting the spatial representation pattern.

[0028] Step S2 specifically includes: Step 2.1: Treat the local adjacency graph and the augmented adjacency graph as two independent views, represented as the local view and the augmented view, respectively. To effectively integrate the information from the two views, a view-level attention mechanism is designed. Specifically, for the local view, a Gaussian kernel transform is used to calculate the attention score, reflecting the similarity between point pairs. The calculation process is as follows: ; in, The attention score in the local view is represented by the input feature defined as follows: , Indicates the number of nodes. Represents the original feature dimension. Indicates the first Gene expression values ​​of each node, Indicates transpose, let , Using the original gene expression values ​​as input, , Indicates the original 3D feature mapping to the transformed The characteristic transformation matrix of the dimensional space, This represents the corresponding attention weight vector. Represents nodes in a partial view The neighbor set.

[0029] Step 2.2: For the augmented view, the attention score is calculated using the standard GAT network format, effectively integrating the similarity of points. The calculation formula is as follows: ; in, This represents the attention score in the augmented view. Represents the characteristic transformation matrix. This represents the corresponding attention weight vector. Represents nodes in the augmented view The set of neighbors.

[0030] Step 2.3: Based on the attention scores obtained in Step 2.2, use the softmax function to analyze the nodes. The original attention scores between the target node and its neighbors are normalized to obtain attention weights, which measure the relative importance of different neighbors to the target node. The attention weights for the two views are represented as follows: ; ; in, Represents nodes in a partial view and nodes Attention weights This represents the attention score of the local view obtained in step 2.1. Represents nodes in the augmented view and nodes Attention weights This represents the attention score of the augmented view obtained in step 2.2. The formula for calculating the attention weight of a local view includes all nodes. The nodes of the local adjacency graph. This represents all nodes in the augmented view attention weight calculation formula. The nodes in the augmented adjacency graph.

[0031] Step 2.4: After obtaining the attention weights, the feature vectors of adjacent nodes are aggregated according to their corresponding weights, and then a linear transformation and LeakyReLU activation function are applied to obtain the node embeddings in different views. Specifically, the node representations in the two views are as follows: ; ; in, Represents a node The embedding obtained in the partial view Represents a node Embedded in the augmented view Indicates when node Belongs to node Neighboring nodes in the local view Indicates when node Belongs to node Neighboring nodes in the augmented view.

[0032] Step 2.5: To integrate the embeddings of the two views, a multi-view fusion method based on an attention mechanism is proposed, which calculates the global attention score of the two views. .

[0033] ; ; in, Represents the learnable projection matrix. This represents a learnable attention vector. This represents the hyperbolic tangent activation function. From 1 to Traversal represents the number of each spatial node in the data.

[0034] Step 2.6: Then, based on the global attention score obtained in Step 2.5, use softmax activation to normalize the two attention scores, thus obtaining the attention weight for each view. : ; Step 2.7: Use these attention weights to fuse the embeddings of the two views to obtain the nodes. In the final embedding of the first attention head, it is represented as The calculation process is as follows: ; Step S3: Apply a multi-head graph attention mechanism to both the local and augmented adjacency graphs. Adaptively assign the importance of neighboring nodes using attention coefficients to obtain multi-perspective feature representations from different neighborhoods and relationships. Local paths focus on capturing direct neighborhood interactions, while augmented paths highlight potential higher-order dependency patterns.

[0035] Step S3 specifically includes: By enabling multiple attention heads to operate in parallel, the network can capture complex information from different perspectives. Each attention head processes the input data independently. After generating the embeddings for each attention head, the ELU activation function is used to connect and fuse the embeddings, resulting in the final embeddings of the first layer of the network. The calculation formula is as follows: ; in, This indicates the final embedding of the first-layer network. Represents a node In the The final embedding of each attention head.

[0036] Step S4: The two-layer architecture achieves progressive fusion of local and global features through layer-by-layer modeling. The first layer focuses on capturing direct interactions and short-range expression patterns in spatial proximity, while the second layer expands the receptive field to characterize higher-order dependencies and cross-regional relationships, retaining useful local information from the previous layer during the fusion process. In this way, the model can simultaneously obtain fine-grained local discriminative power and global consistency, providing more expressive embedded representations for spatial domain recognition.

[0037] Step S4 specifically includes: For the second layer of the network, the output of the first layer is used as input, and the steps of the first layer are repeated to obtain the final embedding. .

[0038] ; in, Indicates a node in the second layer network In the The final embedding of each attention head.

[0039] Unlike the first layer, the second layer introduces a contrastive learning module to further integrate gene expression information and spatial location information.

[0040] Step S5: To further enhance the discriminative power of node representations, a contrastive learning strategy is introduced. By constructing positive and negative sample pairs, the model can simultaneously focus on the differences between spatial and transcriptional patterns, improving the embedding representation's ability to aggregate similar regions and distinguish unrelated regions. A spatial regularization term is added during training to maintain the proximity of adjacent nodes in the latent space while encouraging the separation of distant nodes. This constraint maintains the consistency of the spatial neighborhood structure and prevents the embedding representation from disrupting the original tissue topology. Finally, gene expression is reconstructed using a ZINB decoder, and the final embedding guides downstream analysis.

[0041] Step S5 specifically includes: Step 5.1: Unlike traditional contrastive learning, each attentional head is treated as a single view. Each attention point is considered Each view is assigned a unique identifier, and three types of positive sample pairs are defined: (i) identical samples from different heads (views), (ii) spatially neighboring samples within the same view, and (iii) spatially neighboring samples from different views. Two types of negative sample pairs are also defined: non-spatially neighboring samples within the same view, and non-spatially neighboring samples from different views. This sampling strategy improves the diversity of positive samples while making the selection of negative samples less arbitrary. For computational simplicity, the contrastive learning module first selects a baseline view; here, the first attention head (i.e., the view) is used. Figure 1 Next, calculate the view. Figure 1 Embedding similarity between views; in view Figure 1 Heshi Figure 2 Take the loss calculation formula as an example.

[0042] ; in, Indicates vision Figure 1 With vision Figure 2 The comparative loss, Indicates the temperature coefficient. Indicates vision Figure 1 Middle node Embedded vector, Indicates vision Figure 2 Middle node Embedded vector, Represents an exponential function. This represents the inner product operation that amplifies the similarity difference. (Based on view...) Figure 1 Heshi Figure 2 Taking the loss calculation between them as an example, we will consider Figure 1 Viewed as a baseline view , From 1 to Traversal represents the number of each spatial node in the data.

[0043] Step 5.2, with visual Figure 1 Heshi Figure 2 Taking the loss calculation between them as an example, we will consider Figure 1 Consider it a baseline view. Therefore, Total contrast loss for each view for: ; in, This indicates the number of views; one attention head represents one view. One view, Iterate from 2 to 1. , representing the number of each view. From 1 to Traversal, representing the number of each spatial node in the data. Represents a node Feature embedding in the first view, Represents a node In the traversal of the th Feature embedding in each view; Step 5.3: To preserve the local topological structure of the data, a spatial regularization loss based on neighborhood relationships is introduced to guide model training. Specifically, the spatial regularization loss is calculated using the similarity between the node-level embedding features of each point and the node-level embedding features of its neighbors. : ; in, The cosine similarity matrix representing the latent embeddings of the th Line number The elements of a column, i.e., nodes With nodes Cosine similarity in the latent embedding space The cosine similarity matrix representing the latent embeddings of the th Line number The elements of a column, i.e., nodes With nodes Cosine similarity in the latent embedding space This represents the sigmoid activation function. Point The direct neighbor set. Minimizing the spatial regularization loss can improve the discriminative power of the potential embedding.

[0044] Step 5.4: To accurately simulate the overdispersion and zero-inflation features commonly found in temperature data, stMDGC reconstructs the temperature data using a zero-inflation negative binomial distribution. The ZINB decoder maps the latent space representation back to the gene expression space.

[0045] ; in, This represents the ZINB reconstruction loss obtained using the ZINB decoder. Represents the ZINB distribution. Indicates the probability of zero inflation. The parameter representing the mean of the negative binomial components. This represents the discrete parameters of the negative binomial distribution. Minimizing the ZINB reconstruction loss can make the reconstructed gene expression more closely resemble the true gene expression.

[0046] Step 5.5 employs a joint optimization strategy combining contrastive loss, spatial regularization loss, and ZINB loss. The final loss function is defined as: ; in, , and All of these represent weighting factors.

[0047] To verify the effectiveness of the present invention, this embodiment uses the method proposed in this invention to conduct a large number of experiments on spatial transcriptomics datasets covering different experimental platforms, including the mouse anterior brain dataset on the 10X Visium platform, the human breast cancer dataset, and the mouse visual cortex dataset on the BaristaSeq platform. The experimental results show that it is superior to the comparison method in terms of accuracy and robustness, verifying its effectiveness in different biological contexts.

[0048] like Figure 2 The results of the stMDGC experiment on the mouse anterior brain dataset are shown, in which the forebrain tissue is divided into 52 distinct spatial domains based on anatomical reference annotations. Figure 2 (A) in the middle Figure 2 In section (B), this invention compared six methods, including SpaGCN, STAGATE, ConSpaS, GraphST, SEDR, and stHGC. Clustering results showed that this invention consistently outperformed all other comparative models on both of the two commonly used clustering evaluation metrics, ARI and NMI. Figure 2 (C) in Figure 2 (D) in the middle), and visualize the marker genes of the identified regions ( Figure 2 (E) in the figure effectively confirms the accuracy of the results identified by stMDGC, which can effectively identify fine regions in the mouse anterior brain dataset.

[0049] To verify the spatial domain recognition capability of stMDGC on different spatial transcriptome datasets, this invention was applied to the human breast cancer dataset ( Figure 3 , Figure 4 ) and mouse main visual field dataset ( Figure 5 ).like Figure 3 This is an experimental image of the application of stMDGC on the human breast cancer dataset, using histological images and 20 tumor functional regions manually annotated by pathologists as a benchmark for comparison. Figure 3 (A) in the middle Figure 3 In section (B), this invention compared seven methods, including SpaGCN, STAGATE, ConSpaS, GraphST, SEDR, stHGC, and SpaGRA. Clustering results showed that this invention consistently outperformed all other comparative models on both of the two commonly used clustering evaluation metrics, ARI and NMI. Figure 3 (C) in Figure 3 (D) in the middle.

[0050] To verify the heterogeneity of breast cancer regions, differential expression analysis was performed on different regions identified by stMDGC, such as... Figure 4 The image shows the differential expression analysis of stMDGC on the human breast cancer dataset. Experimental analysis results revealed that the expression of COX6C, CPB1, and CRISP3 in the tumor region was significantly higher than that in the healthy region, and these genes are associated with the progression of breast cancer. Figure 4 In (A) of the study, to further verify the differences, invasive ductal carcinoma (IDC) and breast carcinoma in situ (DCIS / LCIS) were compared. Figure 4 Differential expression analysis of genes (B)-(D) was performed, and the experimental results showed that the identified cancer regions were significantly heterogeneous with other regions.

[0051] like Figure 5 The image shows an experimental application of stMDGC on a mouse visual cortex dataset. This dataset strictly follows the Allen atlas annotation standards and fully covers the layered structural domains and corresponding white matter regions. Figure 5 (A) in the middle Figure 5 In (B) of this paper, seven methods were compared, including SpaGCN, GraphST, ConSpaS, SEDR, SpaGRA, STAGATE, and stHGC. The clustering results showed that this invention consistently outperformed all other comparative models on the two commonly used clustering evaluation metrics, ARI and NMI. Figure 5 (C) in Figure 5 (D)), and then visualization of the identified marker genes at each level confirmed the accuracy of the identified spatial domain. Figure 5 (E) in the figure, and at the same time verified the effectiveness of the present invention in spatial domain identification on idle datasets on different platforms.

[0052] Example 2 Multi-head dual-path attention systems for spatial domain recognition include: The data preprocessing module is used to read tissue coordinate information and gene expression matrix from spatial transcriptome data, and to perform quality control, normalization, and screening for highly variable genes. The dual-path graph construction module, connected to the data preprocessing module, is used to construct a local adjacency graph based on Euclidean distance and an augmented adjacency graph based on Jaccard similarity, and output two sets of adjacency matrices. The view-level attention fusion module, connected to the dual-path graph construction module, is used to run Gaussian kernel attention and standard graph attention mechanisms on the local adjacency graph and the augmented adjacency graph respectively. After obtaining two sets of node embeddings, the learnable view weights are used to dynamically fuse them to generate a comprehensive feature representation. The multi-head graph attention encoding module, connected to the view-level attention fusion module, is used to execute the multi-head graph attention mechanism in parallel on the local graph and the augmented graph, splicing the outputs of the multi-head graph and passing them through non-linear activation to obtain the first layer of node embedding; A two-layer progressive encoding module, connected to a multi-head graph attention encoding module, is used to send the first-layer node embeddings back into the dual-path graph construction module, the view-level attention fusion module, and the multi-head graph attention encoding module to form a second-layer node embedding, in order to capture higher-order spatial dependencies. The contrastive learning and regularization module, connected to the two-layer progressive encoding module, is used to treat the outputs of different attention heads as multiple views and construct positive and negative sample pairs based on spatial proximity to calculate the contrastive loss; at the same time, spatial regularization loss is introduced to constrain the distance between adjacent nodes in the embedding space. The gene expression reconstruction module is connected to the two-layer progressive coding module and has a built-in zero-inflated negative binomial decoder, which is used to embed and map the second-layer nodes back into the gene expression space and calculate the ZINB loss. The joint optimization and output module, connected to the contrastive learning and regularization module and the gene expression reconstruction module, is used to weight and sum the contrastive loss, spatial regularization loss and ZINB loss to form the overall objective function, train the entire system through backpropagation, and output the final low-dimensional embedding representation.

[0053] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0054] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0055] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0056] It is worth noting that all contents not described in detail in this invention are existing technologies and are well known to those skilled in the art.

[0057] Therefore, this invention employs the aforementioned multi-head dual-path attention method, system, device, and medium for spatial domain identification. Addressing the shortcomings of existing spatial domain identification methods in capturing high-order spatial dependencies and lacking the ability to infer deep expression patterns, this invention proposes a multi-head dual-path attention framework. By utilizing progressive encoding of local and augmented dual graphs, combined with contrastive learning and ZINB reconstruction, it accurately models the spatial structure of tissues, achieving high-fidelity spatial domain partitioning and providing a new means for analyzing the spatial heterogeneity of tissue functional microregions and diseases.

[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A multi-head dual-path attention method for spatial domain recognition, characterized in that, The method comprises the following steps: Step S1, based on the tissue coordinates and gene expression information of the spatial transcriptome data, constructing a local adjacency graph and an augmented adjacency graph; Step S2, taking the local adjacency graph and the augmented adjacency graph as two independent views, using a view-level attention mechanism to dynamically learn and fuse the node feature of the two views to generate a comprehensive feature representation of each node; Step S3, taking the comprehensive feature representation as the input of the local adjacency graph and the augmented adjacency graph respectively, and applying a multi-head graph attention mechanism in parallel to capture information from different subspaces, and fusing the outputs of all attention heads to obtain the node embedding representation of the first layer; Step S4, repeating steps S1 to S3 by taking the first layer node embedding representation as input to generate a second layer node embedding representation; Step S5, based on the second layer node embedding representation, introducing a contrastive learning module, a spatial regularization constraint and a gene expression reconstruction module for joint training; by optimizing the overall objective function combining the contrastive loss, the spatial regularization loss and the ZINB loss, a low-dimensional embedding representation for spatial domain recognition is obtained.

2. The spatial-domain-aware multi-headed dual-path attention method of claim 1, wherein, Step S1 specifically comprises: When constructing a local adjacency graph, its adjacency matrix is computed based on the Euclidean distance between nodes , specifically, for nodes , if the Euclidean distance between them is less than or equal to a pre-defined radius , then the corresponding adjacency matrix element , otherwise ; When constructing the augmented adjacency graph, the adjacency relationship is determined by Jaccard similarity screening, and the calculation formula of Jaccard similarity is: ; wherein, representing a node a Jaccard similarity to a node , representing a direct neighbor set of a node , representing a direct neighbor set of a node .

3. The spatial-domain-aware multi-headed dual-path attention method of claim 1, wherein, Step S2 specifically comprises: For local views, the attention function based on a Gaussian kernel is computed for the nodes The original attention scores between a node and its neighbor nodes :​ ; Wherein, the initial input features are defined as , This is the original gene expression matrix. elements in This represents the original gene expression value of the corresponding node. The total number of nodes. For the original feature dimension, Represents the set of real numbers. Represent a OK The set of real matrices of columns, and let , , , express A 3D real vector space, Indicates the original 3D feature mapping to the transformed The characteristic transformation matrix of the dimensional space, Represents the attention weight vector. Represents nodes in a partial view The set of neighbors, i.e., the set of direct neighbors; For augmented views, the standard graph attention network is used to compute the nodes The original attention scores between a node and its neighbor nodes :​ ; wherein, denotes a feature transformation matrix, denotes an attention weight vector, denotes a set of neighbors of a node in the augmented view, i.e. the augmented neighbor set; The original attention scores of the local view and the augmented view are normalized respectively to obtain standardized attention weights; aggregating the local view embeddings and the augmented view embeddings according to the standardized attention weights and the augmented view embeddings ​ The global importance scores of the two views are calculated and normalized to obtain fusion weights, and finally the comprehensive feature representation is obtained by weighted summation.

4. The spatial-domain-aware multi-headed dual-path attention method of claim 3, wherein, Step S3 specifically comprises: Use multiple independent attention heads to process the input features in parallel; Each attention head generates a corresponding node embedding representation according to the process of step S2; The output embeddings of all attention heads are spliced; Apply a nonlinear activation function to the spliced result to obtain the final node embedding representation of the first layer.

5. The spatial-domain-aware multi-headed dual-path attention method of claim 1, wherein, The specific execution process in step S5 comprises: The contrastive learning module regards the outputs of different attention heads as different views, and defines positive and negative sample pairs based on spatial proximity; total contrastive loss is the sum of the view pair losses: ; wherein, represents the number of views, represents the total number of nodes, traverses from 2 to , represents the number of each view, traverses from 1 to , represents the number of each spatial node in the data, represents the feature embedding of the node in the 1st view, represents the feature embedding of the node in the th view traversed to; spatial regularization loss for constraining neighboring nodes to remain close in the embedding space, whose computational formula is based on the cosine similarity of the node embedding and its neighbor embeddings; ; wherein, denotes the node number of a direct neighbor of the node , denotes the node number of a node which is not a direct neighbor of the node , denotes the element in the cosine similarity matrix of latent embeddings in row and column , i.e. the cosine similarity of node and node in the latent embedding space, denotes the element in the cosine similarity matrix of latent embeddings in row and column , i.e. the cosine similarity of node and node in the latent embedding space, denotes the sigmoid activation function, denotes the direct neighbor set of the node ; The gene expression reconstruction module uses a ZINB decoder to reconstruct the gene expression data from the second layer node embedding, and calculates the ZINB loss; ; wherein, denotes the ZINB reconstruction loss obtained using the ZINB decoder, denotes the gene expression data, denotes the ZINB distribution, denotes the zero inflation probability, denotes the mean parameter of the negative binomial component, denotes the dispersion parameter of the negative binomial distribution; The overall objective function is a weighted sum of the above losses : ; wherein , and denote a weight factor.

6. A multi-headed dual-path attention system with spatial domain recognition, characterized in that, It comprises: A data preprocessing module for reading the tissue coordinate information and gene expression matrix in the spatial transcriptome data, and performing quality control, normalization and high variable gene screening; A double-path graph construction module connected to the data preprocessing module for constructing a local adjacency graph based on coordinate Euclidean distance and an augmented adjacency graph based on Jaccard similarity, and outputting two sets of adjacency matrices; A view-level attention fusion module connected to the double-path graph construction module for running Gaussian kernel attention and standard graph attention mechanisms on the local adjacency graph and the augmented adjacency graph respectively, obtaining two sets of node embeddings, and then dynamically fusing them using learnable view weights to generate a comprehensive feature representation; A multi-head graph attention encoding module connected to the view-level attention fusion module for executing a multi-head graph attention mechanism on the local graph and the augmented graph in parallel, splicing the outputs of multiple heads and passing them through a nonlinear activation to obtain the first layer node embedding. The double-layer progressive coding module is connected with the multi-head graph attention coding module, and is used for embedding the first-layer nodes into the double-path graph construction module, the view-level attention fusion module and the multi-head graph attention coding module again to form second-layer node embedding to capture high-order spatial dependence; The contrast learning and regularization module is connected with the double-layer progressive coding module, is used for regarding different attention head outputs as multi-views, constructing positive and negative sample pairs based on spatial proximity, and calculating a contrast loss; meanwhile, a spatial regularization loss is introduced to constrain the distance of adjacent nodes in the embedding space; The gene expression reconstruction module is connected with the double-layer progressive coding module, and is internally provided with a zero-inflated negative binomial decoder, and is used for mapping the second-layer node embedding back to the gene expression space and calculating a ZINB loss; The joint optimization and output module is connected with the contrast learning and regularization module and the gene expression reconstruction module, is used for weighting and summing the contrast loss, the spatial regularization loss and the ZINB loss to form a total objective function, training the entire system through back propagation, and outputting a final low-dimensional embedding representation.

7. A computer device, comprising: The computer program is executed by the processor to implement the multi-head double-path attention method for spatial domain identification.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the multi-head double-path attention method for spatial domain identification.