Spatial transcriptome domain identification method based on double decoders and neighborhood comparison
By using a dual-decoding encoder and neighborhood comparison method, the problems of unreasonable negative sample construction and insufficient graph structure optimization in existing technologies are solved, achieving high-precision and stable spatial domain recognition, which is suitable for biological analysis of complex tissue structures.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGXI NORMAL UNIV
- Filing Date
- 2026-01-21
- Publication Date
- 2026-05-05
AI Technical Summary
Existing spatial transcriptome domain identification methods suffer from problems such as unreasonable negative sample construction, neglect of graph structure optimization, and insufficient modeling of spatial dependencies. These issues result in feature representations failing to accurately reflect the spatial structure, thus affecting the model's discriminative ability and stability.
We adopt a method based on dual decoding encoder and neighborhood comparison. We learn features through graph attention encoder, and reconstruct them by combining gene expression decoder and graph structure decoder. We introduce neighborhood-aware contrastive learning and construct a joint loss function to optimize model parameters, ensuring the consistency of spatial neighborhood structure and the joint optimization of features and structure.
It improves the accuracy and stability of spatial domain identification, can more comprehensively reflect spatial information, enhances the modeling ability under complex organizational structures, and achieves high-precision spatial domain identification.
Smart Images

Figure CN121983145A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of bioinformatics and artificial intelligence, specifically a spatial transcriptome domain identification method based on dual-decoding encoders and neighborhood comparison. Background Technology
[0002] Complex tissues are composed of multiple cells, and the relative positions of their transcriptional expression within the tissue are crucial for elucidating their biological functions and deciphering intercellular communication mechanisms [1]. The emergence of spatial transcriptomics (ST) technology has fundamentally changed biological research, enabling the detection of gene expression profiles while preserving the spatial background of cells [2]. This technological breakthrough has provided deeper insights into the cellular microenvironment and the regulatory mechanisms of various species and diseases, and has been applied to research in the fields of the brain and complex diseases. Current ST technologies can be broadly classified into two categories [3]: imaging-based methods and sequencing-based methods. These spatial transcriptomics technologies have generated a large amount of spatial transcriptomics data, which helps us better understand the complex tissue functions of biological systems [4].
[0003] Identification of spatial domains, namely, regions that exhibit similar gene expression profiles and histological features while maintaining spatial adjacency, is the foundation and most critical aspect of spatial transcriptome data analysis, and also a major challenge in this field [5]. This process can elucidate cell type localization and intercellular interactions in tissue structures by analyzing regional gene expression patterns [6]. Accurate identification of spatial domains plays a crucial role in understanding the occurrence and development of diseases [7]. To address this challenge economically and effectively, computational methods have been proposed to simultaneously model gene expression data and their inherent spatial dependencies. Existing methods can be broadly classified into two categories. The first category attempts to identify spatial domains using some probabilistic techniques, while the second category is based on deep learning techniques. This invention is based on a deep learning approach.
[0004] In 2021, Hu et al. [8] proposed the SpaGCN method, which integrates gene expression, spatial proximity, and histological similarity, and aggregates gene expression information of adjacent sites through graph convolutional networks. In 2022, Dong et al. [5] proposed the STAGATE method, which uses a graph attention autoencoder framework to adaptively learn the similarity of adjacent spots. In 2023, Long et al. [9] proposed the GraphST method, which combines graph neural networks and self-supervised contrastive learning to derive discriminative spatial embeddings by minimizing the embedding distance between spatially adjacent spots. In 2024, Xu et al.
[10] proposed the SEDR method, which uses a deep autoencoder combined with a mask self-supervised learning mechanism to extract low-dimensional representations of gene expression and integrates them with spatial information through a variational graph autoencoder. Zhang et al.
[11] proposed the MuCoST method, which is a multi-view graph contrastive learning framework that enhances spot dependence by fusing gene expression correlation and spatial proximity, thereby enabling the modeling of non-local spatial co-expression dependence and spatial proximity dependence to decode complex tissue structures. Liang et al.
[12] proposed the SpaGCAC method, which uses an adaptive feature space balancing graph convolutional network to dynamically balance local spatial structure and blob features, and combines local topology and probability distribution contrastive learning to enhance spatial domain recognition. In 2025, Zhang et al.
[13] proposed the STMHCG method, which combines spatial representation enhancement and high-confidence clustering guidance to improve spatial domain recognition. Despite achieving satisfactory performance, most existing spatial domain recognition methods still have certain limitations:
[0005] 1. The method of constructing negative samples is unreasonable.
[0006] Existing contrastive learning methods typically generate negative samples by randomly shuffling the gene expression matrix. This approach disrupts the original neighborhood structure between spatial sample points, causing negative samples to deviate from the true spatial topology. Consequently, the obtained feature representations cannot accurately reflect spatial structural constraints, affecting the model's ability to discriminate spatial structures.
[0007] 2. Focusing only on node feature reconstruction while ignoring graph structure optimization.
[0008] Most existing methods only reconstruct or encode gene expression features without simultaneously modeling and optimizing the adjacency relationships between spatial sample points, making it difficult to fully characterize the topological dependencies between spatial sample points.
[0009] 3. Insufficient modeling of spatial dependencies
[0010] When modeling spatial dependencies, some existing methods use fixed weights or neighborhood aggregation based on simple rules, without adaptively modeling the differences in contributions of different neighboring sample points in the feature aggregation process. In scenarios with complex organizational structures or strong spatial heterogeneity, the expressive power of the model is limited. Summary of the Invention
[0011] The purpose of this invention is to overcome the aforementioned shortcomings of existing spatial transcriptome domain identification methods and propose a spatial transcriptome domain identification method based on dual-decoding encoders and neighborhood comparison. This method avoids random perturbations from disrupting spatial structure, improves the reliability of contrastive learning, enables latent representations to more comprehensively reflect spatial information, dynamically allocates weights according to the importance of different neighbors, improves modeling capabilities under complex organizational structures, and exhibits high spatial domain identification accuracy and strong stability.
[0012] The technical solution to achieve the objective of this invention is:
[0013] A spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison includes the following steps:
[0014] Step 1: Spatial Transcriptome Data Preprocessing:
[0015] Obtain raw spatial transcriptome data, which includes: a raw gene expression matrix. , in Represents the set of real numbers. Represents the set of spatial sample points The total number This represents the total number of original genes obtained from the measurement, as well as the spatial coordinate information corresponding to each spatial sample point. Then, the original gene expression matrix was subjected to logarithmic transformation, normalization, and standardization, and highly variable genes were screened to obtain the preprocessed gene expression feature matrix. ,in This indicates the number of highly variable genes after pretreatment;
[0016] Step 2: Spatial Adjacency Graph Construction:
[0017] Based on the spatial coordinate information of each spatial sample point, the Euclidean distance between the spatial sample points is calculated; a spatial adjacency graph is constructed using the K-nearest neighbor method. Each spatial sample point is treated as a graph node, resulting in a node set. Edges are established between spatially adjacent sample points to form a spatial adjacency matrix. ;
[0018] Step 3: Encoder Feature Learning Based on Graph Attention:
[0019] The features in the preprocessed gene expression feature matrix from step one are used as the initial features of the nodes, and the spatial adjacency graph obtained in step two is input into the graph attention encoder. Under the constraint of the spatial adjacency graph, for each target node, the neighbor weights corresponding to the neighbor nodes are adaptively calculated based on the feature similarity between the target node and its neighbor nodes. The feature information of the neighbor nodes is used for weighted aggregation, and the features of the target node are updated through a multi-layer graph attention encoder to obtain the low-dimensional latent representation corresponding to each spatial sample point.
[0020] Step 4: Joint reconstruction using dual decoders:
[0021] The low-dimensional latent representation output by the graph attention encoder is reconstructed by the following two decoders: (1) a gene expression decoder, which reconstructs the original gene expression matrix and calculates the gene expression reconstruction loss based on the difference between the reconstruction result and the original gene expression matrix, so as to constrain the low-dimensional latent representation to maintain the consistency of gene expression features; (2) a graph structure decoder, which reconstructs the spatial adjacency relationship through the inner product operation between the low-dimensional latent representations and calculates the graph structure reconstruction loss based on the difference between the reconstructed spatial adjacency relationship and the original spatial adjacency relationship, so as to constrain the low-dimensional latent representation to maintain the consistency of spatial topology; thereby realizing the joint constraint of gene expression feature information and spatial topology information in the same latent representation space.
[0022] Step 5: Neighborhood-aware contrastive learning:
[0023] Each spatial sample point's low-dimensional latent representation is used as an anchor point. For the current anchor sample point, the K nearest neighbor sample points in the spatial adjacency graph are selected as positive samples, and the remaining sample points in the spatial adjacency graph that are not adjacent to the anchor sample point are selected as negative samples. Based on the low-dimensional latent representations corresponding to the anchor sample point, positive samples, and negative samples, a neighborhood-aware contrast loss is calculated without destroying the original spatial structure. The neighborhood-aware contrast loss is calculated with the low-dimensional latent representation corresponding to the anchor sample point as the center, and is used to measure the relative similarity between the anchor sample point and the low-dimensional latent representations corresponding to its positive and negative samples. This aims to shorten the distance between the anchor sample point and the positive samples in the latent representation space, and increase the distance between the anchor sample point and the negative samples, thereby enhancing the discriminative power of the latent representation.
[0024] Step Six: Joint Loss Function Optimization:
[0025] Based on the gene expression reconstruction loss and graph structure reconstruction loss obtained in step four, and the domain awareness contrast loss obtained in step five, a joint loss function is constructed. By minimizing the joint loss function, the model parameters of the graph attention encoder, gene expression decoder, and graph structure decoder are iteratively optimized through backpropagation to obtain the final low-dimensional latent representation.
[0026] Step 7: Spatial Domain Clustering:
[0027] Based on the low-dimensional latent representation output by the graph attention encoder after training by the joint loss function in step six, when the model parameters converge, an unsupervised clustering algorithm is used to cluster the spatial sample points to obtain the spatial domain partitioning results of the spatial transcriptome data. The unsupervised clustering algorithm adopts a clustering method based on Gaussian mixture model, and relies on the mclust() function in the mclust package of R language to obtain the final spatial domain partitioning results.
[0028] The specific steps for constructing the spatial adjacency graph in step two are as follows:
[0029] Based on the spatial coordinate information of each spatial sample point, the Euclidean distance between the spatial sample points is calculated; a spatial adjacency graph is constructed using the K-nearest neighbor method. , where the set of nodes Represents the set of all sample points and edges. This represents the adjacency relationship between sample points, and further defines the spatial adjacency matrix. This represents the adjacency relationship between spatial sample points, where, when spatial sample points Located at the sample point When in the set of K nearest neighbors, Representing spatial sample points and spatial sample points There exists an undirected edge connecting them; otherwise, ,in .
[0030] The specific steps of encoder feature learning based on graph attention in step three are as follows:
[0031] The gene expression features in the gene expression feature matrix after preprocessing in step one and the spatial adjacency graph constructed in step two are input into the graph attention encoder, and a low-dimensional latent representation of each spatial sample point is obtained through a multi-layer graph attention network. The attention mechanism of the graph attention encoder is used to dynamically calculate the attention weights corresponding to different neighbor sample points based on the node feature similarity, and to use the attention weights to perform weighted aggregation of the feature information of the neighbor sample points.
[0032] Given a constructed spatial adjacency graph Each spatial sample point Considered One of the nodes, and assign an initial embedding vector. , , where the initial embedding vector Taken from gene expression feature matrix The Rows are used to represent corresponding spatial sample points. Gene expression matrix; multilayer graph attention network is used to process this. Features of spatial sample points, where spatial sample points In the Layer update feature representation The calculation is as follows, and , Indicates the number of layers in a multi-layer graph attention network:
[0033]
[0034] in, , , This represents the ELU activation function. Representing a spatial adjacency graph Mid-space sample points The neighborhood group, It is the first The trainable weight matrix of the encoder layer, the first Spatial sample points in the layered attention layer and Normalized edge weights between The calculation is as follows:
[0035]
[0036] in, Represents the attention coefficient, used to quantify the first... Spatial sample points in encoder layer Spatial sample points with neighbors The correlation between them is calculated as follows:
[0037]
[0038] This represents the Sigmod activation function. for In a layered graph attention encoder, the attention weight parameters correspond to the features of the target sample point itself. for The graph attention encoder uses attention weight parameters corresponding to the features of neighboring sample points to ultimately generate a low-dimensional latent representation. ,in , Indicates the first The spatial sample points in the graph attention encoder are at the nth spatial sample point. Feature representation of the layer output.
[0039] The specific steps of the joint reconstruction by the dual decoders in step four are as follows:
[0040] A dual-decoder architecture is adopted to simultaneously reconstruct the gene expression feature matrix and the spatial neighborhood graph, thereby obtaining a more informative spatial sample point representation. The dual-decoder architecture includes: (1) a gene expression decoder, used to reconstruct the original gene expression data, and (2) a graph structure decoder, used to recover the inner product decoder of the spatial graph topology, as follows:
[0041] Gene expression decoder with low-dimensional potential representation As input, its initialization layer input feature representation is defined as The final output of the graph attention encoder is used as the input of the gene expression decoder, with spatial sample points. In the Update feature representation of layer ) Calculation as follows :
[0042]
[0043] This represents the ELU activation function. Indicates the first The trainable weight matrix of each decoder layer, and the last layer of the decoder generates the reconstructed gene expression matrix. ,in Furthermore, the reconstructed adjacency matrix By latent representation get:
[0044]
[0045] in This represents the Sigmod activation function;
[0046] Loss function for reconstructing gene expression data Used to quantify the preprocessed gene expression matrix With the reconstructed gene expression matrix Differences between them:
[0047]
[0048] Loss of graph structure reconstruction Defined as:
[0049] .
[0050] The specific steps of neighborhood-aware contrastive learning in step five are as follows:
[0051] To obtain higher quality low-dimensional latent representations, a neighborhood-aware contrastive learning module is introduced. Using each spatial sample point as an anchor point, positive and negative sample pairs are constructed based on spatial neighborhood relationships, and contrastive loss is calculated.
[0052] In the neighborhood-aware contrastive learning module, the input is a low-dimensional latent representation derived from the graph attention encoder. For a given anchor point Based on spatial adjacency graph Construct positive and negative sample pairs in the spatial adjacency graph. The former A pair of spatially adjacent points constitutes a positive sample pair, and the rest... Each point is used as a negative sample, spatial sample points Neighborhood contrast loss The calculation is as follows:
[0053]
[0054] in Spatial adjacency graph The number of neighboring spatial sample points, This represents the total number of spatial sample points. For temperature parameters, Representing spatial sample points Feature representation, Including spatial sample points Feature representation of all spatial sample points outside, The similarity is represented by the similarity between pairs of spatial sample points, where the similarity is... The calculation formula, using cosine distance as the metric, is as follows:
[0055]
[0056] Define the following neighborhood contrast loss function :
[0057] .
[0058] The specific steps for optimizing the joint loss function in step six are as follows:
[0059] Loss of gene expression reconstruction Graph structure reconstruction loss Neighborhood contrast loss function A joint optimization is performed, which constitutes the final training objective, as follows:
[0060]
[0061] The reconstruction loss function is weighted. Graph structure reconstruction loss Neighborhood contrast loss function Perform joint optimization and train the model parameters.
[0062] This technical solution achieves the following objectives:
[0063] 1. Construct contrastive learning samples while maintaining the consistency of spatial neighborhood structure;
[0064] 2. Simultaneously reconstruct gene expression characteristics and spatial map structure to improve the expression ability of potential representations;
[0065] 3. Adaptively model the influence weights of different spatial neighbors on the target sample point;
[0066] 4. Improve the accuracy, stability, and biological consistency of spatial domain identification.
[0067] Compared with the prior art, the present technical solution has the following beneficial effects:
[0068] 1. A contrastive learning mechanism that maintains spatial topological consistency
[0069] By constructing positive and negative samples using a neighborhood-aware approach, random perturbations can be avoided from disrupting the spatial structure, thus improving the reliability of contrastive learning.
[0070] 2. Joint optimization of features and structure
[0071] By using a dual-decoder structure, gene expression features and spatial graph structure are reconstructed simultaneously, enabling the potential representation to more comprehensively reflect spatial information.
[0072] 3. Strong adaptive neighborhood modeling capability
[0073] Introducing a graph attention mechanism can dynamically allocate weights based on the importance of different neighbors, thereby improving the modeling capabilities for complex organizational structures.
[0074] 4. High spatial domain recognition accuracy and strong stability
[0075] It exhibits good generalization ability and recognition effect on multiple spatial transcriptome data platforms. Attached Figure Description
[0076] Figure 1 This is a flowchart illustrating an embodiment;
[0077] Figure 2 Box plots of ARI and NMI on 12 human dorsolateral prefrontal cortex (DLPFC) slices in the example;
[0078] Figure 3 The spatial domain results identified in slice 151673 of the human dorsolateral prefrontal cortex dataset (DLPFC) in the example are shown.
[0079] Figure 4 The bar chart shows the ARI and NMI values on the human breast cancer (HBC) dataset in this example.
[0080] Figure 5 This is the spatial domain result of identification in human breast cancer tissue in the example;
[0081] Figure 6 The bar chart shows the ARI and NMI values on the mouse visual cortex (MSC) dataset in this example.
[0082] Figure 7 The spatial domain results for recognition in the mouse visual cortex (MSC) are shown in the examples. Detailed Implementation
[0083] The present invention will be further described below with reference to the accompanying drawings and embodiments, but this is not intended to limit the scope of the invention.
[0084] Example:
[0085] All experiments in this example were conducted on a workstation equipped with an Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz and an NVIDIA A100 80GB PCIe GPU. The operating system was Ubuntu 20.04, and the deep learning frameworks were PyTorch 2.0.0 and CUDA 11.8. The model parameters were set as follows: , , , , and The parameter settings for other methods all follow the corresponding parameters in the relevant literature.
[0086] Reference Figure 1 A spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison includes the following steps:
[0087] Step 1: Spatial Transcriptome Data Preprocessing:
[0088] Obtain raw spatial transcriptome data, which includes: a raw gene expression matrix. , in Represents the set of real numbers. Represents the set of spatial sample points The total number This represents the total number of original genes obtained from the measurement, as well as the spatial coordinate information corresponding to each spatial sample point. Then, the original gene expression matrix was subjected to logarithmic transformation, normalization, and standardization, and highly variable genes were screened to obtain the preprocessed gene expression feature matrix. ,in This indicates the number of highly variable genes after pretreatment;
[0089] Step 2: Spatial Adjacency Graph Construction:
[0090] Based on the spatial coordinate information of each spatial sample point, the Euclidean distance between the spatial sample points is calculated; a spatial adjacency graph is constructed using the K-nearest neighbor method. Each spatial sample point is treated as a graph node, resulting in a node set. edge set To represent the adjacency relationship between spatial sample points, a spatial adjacency matrix is further defined. This represents the adjacency relationship between spatial sample points, where, when spatial sample points Located at spatial sample point When in the set of K nearest neighbors, , representing spatial sample points and spatial sample points There exists an undirected edge connecting them; otherwise, ,in ;
[0091] Step 3: Encoder Feature Learning Based on Graph Attention:
[0092] The features in the gene expression feature matrix preprocessed in step one are used as the initial features of the nodes and the spatial adjacency graph constructed in step two are input into the graph attention encoder; and a low-dimensional latent representation of each spatial sample point is obtained through a multi-layer graph attention network; the attention mechanism of the graph attention encoder is used to dynamically calculate the attention weights corresponding to different neighbor sample points based on the node feature similarity for the relationship between the target spatial sample point and its spatial neighbor sample points, and to use the attention weights to perform weighted aggregation of the feature information of the neighbor sample points;
[0093] Given a constructed spatial adjacency graph Each spatial sample point Considered One of the nodes, and assign an initial embedding vector. , , where the initial embedding vector Taken from gene expression feature matrix The Rows are used to represent corresponding spatial sample points. Gene expression matrix; multilayer graph attention network is used to process this. Features of spatial sample points, where spatial sample points In the Layer update feature representation The calculation is as follows, and , Indicates the number of layers in a multi-layer graph attention network:
[0094]
[0095] in, , , This represents the ELU activation function. Representing a spatial adjacency graph Mid-space sample points The neighborhood group, It is the first The trainable weight matrix of the encoder layer, the first Spatial sample points in the layered attention layer and Normalized edge weights between The calculation is as follows:
[0096]
[0097] in, Represents the attention coefficient, used to quantify the first... Spatial sample points in encoder layer Spatial sample points with neighbors The correlation between them is calculated as follows:
[0098]
[0099] This represents the Sigmod activation function. for The attention weight parameters of the layer graph attention encoder and the features of the target sample point itself. for The graph attention encoder uses attention weight parameters corresponding to the features of neighboring sample points to ultimately generate a low-dimensional latent representation. ,in , Indicates the first The spatial sample points in the graph attention encoder are at the nth spatial sample point. Feature representation of layer output;
[0100] Step 4: Joint reconstruction using dual decoders:
[0101] The low-dimensional latent representation output by the graph attention encoder is reconstructed by the following two decoders: (1) a gene expression decoder, which reconstructs the original gene expression matrix and calculates the gene expression reconstruction loss based on the difference between the reconstruction result and the original gene expression matrix, so as to constrain the low-dimensional latent representation to maintain the consistency of gene expression features; (2) a graph structure decoder, which reconstructs the spatial adjacency relationship through the inner product operation between the low-dimensional latent representations and calculates the graph structure reconstruction loss based on the difference between the reconstructed spatial adjacency relationship and the original spatial adjacency relationship, so as to constrain the low-dimensional latent representation to maintain the consistency of spatial topology; thereby realizing the joint constraint of gene expression feature information and spatial topology information in the same latent representation space; as follows:
[0102] Gene expression decoder with low-dimensional potential representation As input, its initialization layer input feature representation is defined as The final output of the graph attention encoder is used as the input of the gene expression decoder, with spatial sample points. In the Update feature representation of layer ) Calculation as follows :
[0103]
[0104] This represents the ELU activation function. Indicates the first The trainable weight matrix of each decoder layer, and the last layer of the decoder generates the reconstructed gene expression matrix. ,in Furthermore, the reconstructed adjacency matrix By latent representation get:
[0105]
[0106] in This represents the Sigmod activation function;
[0107] Loss function for reconstructing gene expression data Used to quantify the preprocessed gene expression matrix With the reconstructed gene expression matrix Differences between them:
[0108]
[0109] Loss of graph structure reconstruction Defined as:
[0110] ;
[0111] Step 5: Neighborhood-aware contrastive learning:
[0112] Each spatial sample point's low-dimensional latent representation is used as an anchor point. For the current anchor sample point, the K nearest neighbor sample points in the spatial adjacency graph are selected as positive samples, and the remaining sample points in the spatial adjacency graph that are not adjacent to the anchor sample point are selected as negative samples. Based on the low-dimensional latent representations corresponding to the anchor sample point, positive samples, and negative samples, a neighborhood-aware contrast loss is calculated without destroying the original spatial structure. The neighborhood-aware contrast loss is calculated with the low-dimensional latent representation corresponding to the anchor sample point as the center, and is used to measure the relative similarity between the anchor sample point and the low-dimensional latent representations corresponding to its positive and negative samples. This aims to shorten the distance between the anchor sample point and the positive samples in the latent representation space, and increase the distance between the anchor sample point and the negative samples, thereby enhancing the discriminative power of the latent representation.
[0113] To obtain higher quality low-dimensional latent representations, a neighborhood-aware contrastive learning module is introduced. Using each spatial sample point as an anchor point, positive and negative sample pairs are constructed based on spatial neighborhood relationships, and contrastive loss is calculated.
[0114] In the neighborhood-aware contrastive learning module, the input is a low-dimensional latent representation derived from the graph attention encoder. For a given anchor point , Based on spatial adjacency graph Construct positive and negative sample pairs in the spatial adjacency graph. The former A pair of spatially adjacent points constitutes a positive sample pair, and the rest... Each point is used as a negative sample, spatial sample points Neighborhood contrast loss The calculation is as follows:
[0115]
[0116] in Spatial adjacency graph The number of neighboring spatial sample points, This represents the total number of spatial sample points. For temperature parameters, Representing spatial sample points Feature representation, Including spatial sample points Feature representation of all spatial sample points outside, The similarity is represented by the similarity between pairs of spatial sample points, where the similarity is... The calculation formula, using cosine distance as the metric, is as follows:
[0117]
[0118] Define the following neighborhood contrast loss function :
[0119] ;
[0120] Step Six: Joint Loss Function Optimization:
[0121] Based on the gene expression reconstruction loss and graph structure reconstruction loss obtained in step four, and the domain awareness contrast loss obtained in step five, a joint loss function is constructed. By minimizing the joint loss function, the model parameters of the graph attention encoder, gene expression decoder, and graph structure decoder are iteratively optimized through backpropagation to obtain the final low-dimensional latent representation.
[0122] Step 7: Spatial Domain Clustering:
[0123] Based on the low-dimensional latent representation output by the graph attention encoder after training by the joint loss function in step six, when the model parameters converge, an unsupervised clustering algorithm is used to cluster the spatial sample points to obtain the spatial domain partitioning results of the spatial transcriptome data. The unsupervised clustering algorithm adopts a clustering method based on Gaussian mixture model, and relies on the mclust() function in the mclust package of R language to obtain the final spatial domain partitioning results.
[0124] The core innovation of this example lies in:
[0125] 1. Introduction of the Neighborhood-Aware Comparative Learning Module
[0126] Constructing positive and negative samples through spatial neighborhood relationships distinguishes it from existing random perturbation methods.
[0127] 2. Dual decoding joint reconstruction mechanism
[0128] Simultaneously, gene expression characteristics and spatial graph structure are reconstructed to achieve synergistic optimization of features and structure.
[0129] 3. The organic combination of graph attention and self-supervised contrastive learning
[0130] This approach unifies graph attention mechanisms, dual-decoding autoencoder structures, and neighborhood-aware contrastive learning into a single self-supervised framework for spatial domain recognition tasks.
[0131] This example uses real spatial transcriptome data to evaluate the performance of the proposed method and compares it with seven baseline methods, including stMHCG
[13] , MuCoST
[11] , SEDR
[10] , GraphST[9], STAGATE[5], SpaGCN[8] and Scanpy
[14] .
[0132] like Figure 2 As shown, the method in this example achieves better results than other methods on 12 datasets of DLPFC using 10x Visium. Box plots of the ARI and NMI scores for this example and seven spatial domain recognition methods are shown below. Figure 2 As shown. By Figure 2 As can be seen, the method in this example has a higher mean than other methods, with average ARI and NMI scores of 0.58 and 0.68, respectively, and exhibits consistent performance and low instability across all sections. To better illustrate this method, section 151673 is used as an example, and its histological H&E stained section image is shown below. Figure 4 As shown, the adjusted RAND index (ARI) calculated in this example is 0.627, and the normalized mutual information (NMI) is 0.731. The recognition performance is compared with the other seven methods as follows: Figure 3 As shown, from Figure 3 As can be seen from this example, the proposed method is more accurate in identifying spatial domains and closer to the real labels compared to other methods, which fully demonstrates the spatial domain identification capability of the proposed method.
[0133] This example, along with seven other methods, was applied to a cancer tissue dataset to further validate their performance in cancer tissue spatial domain recognition. The comparison results between this example and the other six methods are as follows: Figure 4 As shown in the bar chart, the ARI and NMI scores indicate that this example has the highest ARI score of 0.668, followed by the NMI score of 0.701. Clearly, this example performs exceptionally well on this dataset. Figure 5 As shown, this example is more consistent with manual annotation in terms of spatial domain recognition, and can label multiple specific tumor regions more effectively and smoothly than the other six methods.
[0134] Further testing was conducted on datasets with low gene expression capture rates. This example was applied to a mouse visual cortex dataset generated using STARmap technology. The proposed method achieved the best performance in terms of clustering accuracy and consistency with the true labels, achieving the highest scores in both ARI (0.621) and NMI (0.68), significantly outperforming other methods, such as... Figure 6 As shown.
[0135] from Figure 7As can be seen, compared with other methods, the spatial domains identified in this example match the organizational structure annotated by experts more closely, the layered boundaries are clearer, and the spatial organization is more compact. Notably, when identifying layers L2 / 3, L4, L5, and L6, this example is able to obtain clear regions and consistent morphology, fully demonstrating its ability to perceive hierarchical structures.
[0136] References:
[0137] [1]Asp M, Bergenstråhle J, Lundeberg J. Spatially resolved transcriptomes—next generation tools for tissue exploration[J]. BioEssays, 2020, 42(10): 1900221.
[0138] [2]Yuan Z, Yao J. Harnessing computational spatial omics to explore the spatial biology intricacies[C]. Seminars in Cancer Biology. AcademicPress, 2023, 95: 25-41.
[0139] [3]Zeng Z, Li Y, Li Y, et al. Statistical and machine learning methods for spatially resolved transcriptomics data analysis[J]. Genomebiology, 2022, 23(1): 83.
[0140] [4]Cheng A, Hu G, Li W V. Benchmarking cell-type clustering methods for spatially resolved transcriptomics data[J]. Briefings in bioinformatics, 2023, 24(1).
[0141] [5]Dong K, Zhang S. Deciphering spatial domains from spatiallyresolved transcriptomics with an adaptive graph attention auto-encoder[J].Nature communications, 2022, 13(1): 1739.
[0142] [6]Guo T, Yuan Z, Pan Y, et al. SPIRAL: integrating and aligningspatially resolved transcriptomics data across different experiments,conditions, and technologies[J]. Genome Biology, 2023, 24(1): 241.
[0143] [7]Wu S Z, Al-Eryani G, Roden D L, et al. A single-cell and spatiallyresolved atlas of human breast cancers[J]. Nature genetics, 2021, 53(9):1334-1347.
[0144] [8]Hu J, Li X, Coleman K, et al. SpaGCN: Integrating gene expression,spatial location and histology to identify spatial domains and spatiallyvariable genes by graph convolutional network[J]. Nature methods, 2021, 18(11): 1342-1351.
[0145] [9]Long Y, Ang K S, Li M, et al. Spatially informed clustering,integration, and deconvolution of spatial transcriptomics with GraphST[J].Nature Communications, 2023, 14(1): 1155.
[0146]
[10] Xu H, Fu H, Long Y, et al. Unsupervised spatially embedded deeprepresentation of spatial transcriptomics[J]. Genome Medicine, 2024, 16(1):12.
[0147]
[11] Zhang L, Liang S, Wan L. A multi-view graph contrastive learningframework for deciphering spatially resolved transcriptomics data[J].Briefings in Bioinformatics, 2024, 25(4): bbae255.
[0148]
[12] Liang X, Shang J, Liu J X, et al. Enhancing Spatial DomainIdentification in Spatially Resolved Transcriptomics Using GraphConvolutional Networks With Adaptively Feature-Spatial Balance andContrastive Learning[J]. IEEE / ACM Transactions on Computational Biology andBioinformatics, 2024.
[0149]
[13] Zhang X, Shang J, Zhao Y, et al. stMHCG: High-confidence multi-view clustering for identification of spatial domains from spatially resolvedtranscriptomics[J]. Neurocomputing, 2025: 130362.
[0150]
[14] Fraley C, Raftery A E, Murphy T B, et al. mclust version 4 for R:normal mixture modeling for model-based clustering, classification, anddensity estimation[R]. Technical report, 2012.
Claims
1. A spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison, characterized in that, Includes the following steps: Step 1: Spatial Transcriptome Data Preprocessing: Obtain raw spatial transcriptome data, which includes: a raw gene expression matrix. , in Represents the set of real numbers. Represents the set of spatial sample points The total number This represents the total number of original genes obtained from the measurement, as well as the spatial coordinate information corresponding to each spatial sample point. Then, the original gene expression matrix was subjected to logarithmic transformation, normalization, and standardization, and highly variable genes were screened to obtain the preprocessed gene expression feature matrix. ,in This indicates the number of highly variable genes after pretreatment; Step 2: Spatial Adjacency Graph Construction: Based on the spatial coordinate information of each spatial sample point, the Euclidean distance between the spatial sample points is calculated; a spatial adjacency graph is constructed using the K-nearest neighbor method. Each spatial sample point is treated as a graph node, resulting in a node set. Edges are established between spatially adjacent sample points to form a spatial adjacency matrix. ; Step 3: Encoder Feature Learning Based on Graph Attention: The features in the preprocessed gene expression feature matrix in step one are used as the initial features of the nodes, and the spatial adjacency graph obtained in step two is input into the graph attention encoder. Under the constraint of the spatial adjacency graph, for each target node, the neighbor weights corresponding to the neighbor nodes are adaptively calculated based on the feature similarity between the target node and its neighbor nodes. The feature information of the neighbor nodes is used for weighted aggregation, and the features of the target node are updated through a multi-layer graph attention network to obtain the low-dimensional latent representation corresponding to each spatial sample point. Step 4: Joint reconstruction using dual decoders: The low-dimensional latent representations output by the graph attention encoder are reconstructed by the following two decoders: (1) a gene expression decoder, which reconstructs the original gene expression matrix and calculates the gene expression reconstruction loss based on the difference between the reconstruction result and the original gene expression matrix, so as to constrain the low-dimensional latent representations to maintain the consistency of gene expression features; (2) a graph structure decoder, which reconstructs the spatial adjacency relationship through the inner product operation between the low-dimensional latent representations and calculates the graph structure reconstruction loss based on the difference between the reconstructed spatial adjacency relationship and the original spatial adjacency relationship, so as to constrain the low-dimensional latent representations to maintain the consistency of spatial topology; thereby realizing the joint constraint of gene expression feature information and spatial topology information in the same latent representation space. Step 5: Neighborhood-aware contrastive learning: Each spatial sample point's low-dimensional latent representation is used as an anchor point. For the current anchor sample point, the K nearest neighbor sample points in the spatial adjacency graph are selected as positive samples, and the remaining sample points in the spatial adjacency graph that are not adjacent to the anchor sample point are selected as negative samples. Based on the low-dimensional latent representations corresponding to the anchor sample point, positive samples, and negative samples, a neighborhood-aware contrast loss is calculated without destroying the original spatial structure. The neighborhood-aware contrast loss is calculated with the low-dimensional latent representation corresponding to the anchor sample point as the center, and is used to measure the relative similarity between the anchor sample point and the low-dimensional latent representations corresponding to its positive and negative samples. This aims to shorten the distance between the anchor sample point and the positive samples in the latent representation space, and increase the distance between the anchor sample point and the negative samples, thereby enhancing the discriminative power of the latent representation. Step Six: Joint Loss Function Optimization: Based on the gene expression reconstruction loss and graph structure reconstruction loss obtained in step four, and the domain awareness contrast loss obtained in step five, a joint loss function is constructed; the joint loss function is minimized, and the model parameters of the graph attention encoder, gene expression decoder, and graph structure decoder are iteratively optimized through backpropagation to obtain the final low-dimensional latent representation; Step 7: Spatial Domain Clustering: Based on the low-dimensional latent representation output by the graph attention encoder when the model parameters converge after optimization training via the joint loss function in step six, an unsupervised clustering algorithm is used to cluster spatial sample points to obtain the spatial domain partitioning results of the spatial transcriptome data. The unsupervised clustering algorithm adopts a clustering method based on Gaussian mixture model, and the final spatial domain partitioning results are obtained by relying on the mclust() function in the mclust package of R language.
2. The spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison according to claim 1, characterized in that, The specific steps for constructing the spatial adjacency graph in step two are as follows: Based on the spatial coordinate information of each spatial sample point, the Euclidean distance between the spatial sample points is calculated; a spatial adjacency graph is constructed using the K-nearest neighbor method. , where the set of nodes Represents the set of all spatial sample points and edges. To represent the adjacency relationship between spatial sample points, a spatial adjacency matrix is further defined. This represents the adjacency relationship between spatial sample points, where, when spatial sample points Located at spatial sample point When in the set of K nearest neighbors, , representing spatial sample points and spatial sample points There exists an undirected edge connecting them; otherwise, ,in .
3. The spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison according to claim 1, characterized in that, The specific steps of encoder feature learning based on graph attention in step three are as follows: The gene expression features in the gene expression feature matrix after preprocessing in step one and the spatial adjacency graph constructed in step two are input into the graph attention encoder, and a low-dimensional latent representation of each spatial sample point is obtained through a multi-layer graph attention network. The attention mechanism of the graph attention encoder is used to dynamically calculate the attention weights corresponding to different neighbor sample points based on the node feature similarity, and to use the attention weights to perform weighted aggregation of the feature information of the neighbor sample points. Given a constructed spatial adjacency graph Each spatial sample point Considered One of the nodes, and assign an initial embedding vector. , , where the initial embedding vector Taken from gene expression feature matrix The Rows are used to represent corresponding spatial sample points. Gene expression matrix; multilayer graph attention network is used to process this. Features of spatial sample points, where spatial sample points In the Layer update feature representation The calculation is as follows, and , Indicates the number of layers in a multi-layer graph attention network: , in, , , This represents the ELU activation function. Representing a spatial adjacency graph Mid-space sample points The neighborhood group, It is the first The trainable weight matrix of the encoder layer, the first Spatial sample points in the layered attention layer and Normalized edge weights between The calculation is as follows: , in, Represents the attention coefficient, used to quantify the first... Spatial sample points in encoder layer Spatial sample points with neighbors The correlation between them is calculated as follows: , This represents the Sigmod activation function. for In a layered graph attention encoder, the attention weight parameters correspond to the features of the target sample point itself. for The graph attention encoder uses attention weight parameters corresponding to the features of neighboring sample points to ultimately generate a low-dimensional latent representation. ,in , Indicates the first The spatial sample points in the graph attention encoder are at the nth spatial sample point. Feature representation of the layer output.
4. The spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison according to claim 1, characterized in that, The specific steps of the joint reconstruction by the dual decoders in step four are as follows: A dual-decoder architecture is adopted to simultaneously reconstruct the gene expression feature matrix and the spatial neighborhood graph, thereby obtaining a more informative spatial sample point representation. The dual-decoder architecture includes: (1) a gene expression decoder, used to reconstruct the original gene expression data, and (2) a graph structure decoder, used to recover the inner product decoder of the spatial graph topology, as follows: Gene expression decoder with low-dimensional potential representation As input, its initialization layer input feature representation is defined as The final output of the graph attention encoder is used as the input of the gene expression decoder, with spatial sample points. In the Update feature representation of layer ) Calculation as follows : , This represents the ELU activation function. Indicates the first The trainable weight matrix of each decoder layer, and the last layer of the decoder generates the reconstructed gene expression matrix. ,in Furthermore, the reconstructed adjacency matrix By latent representation get: , in This represents the Sigmod activation function; Loss function for reconstructing gene expression data Used to quantify the preprocessed gene expression matrix With the reconstructed gene expression matrix Differences between them: , Loss of graph structure reconstruction Defined as: 。 5. The spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison according to claim 1, characterized in that, The specific steps of neighborhood-aware contrastive learning in step five are as follows: To obtain higher quality low-dimensional latent representations, a neighborhood-aware contrastive learning module is introduced. Using each spatial sample point as an anchor point, positive and negative sample pairs are constructed based on spatial neighborhood relationships, and contrastive loss is calculated. In the neighborhood-aware contrastive learning module, the input is a low-dimensional latent representation derived from the graph attention encoder. For a given anchor point , Based on spatial adjacency graph Construct positive and negative sample pairs in the spatial adjacency graph. The former A pair of spatially adjacent points constitutes a positive sample pair, and the rest... Each point is used as a negative sample, spatial sample points Neighborhood contrast loss The calculation is as follows: , in Spatial adjacency graph The number of neighboring spatial sample points, This represents the total number of spatial sample points. For temperature parameters, Representing spatial sample points Feature representation, Including spatial sample points Feature representation of all spatial sample points outside, The similarity is represented by the similarity between pairs of spatial sample points, where the similarity is... The calculation formula, using cosine distance as the metric, is as follows: , Define the following neighborhood contrast loss function : 。 6. The spatial transcriptome domain identification method based on dual-decoding encoder and neighborhood comparison according to claim 1, characterized in that, The specific steps for optimizing the joint loss function in step six are as follows: Loss of gene expression reconstruction Graph structure reconstruction loss Neighborhood contrast loss function A joint optimization is performed, which constitutes the final training objective, as follows: , The reconstruction loss function is weighted. Graph structure reconstruction loss Neighborhood contrast loss function Perform joint optimization and train the model parameters.