Single-cell RNA sequencing data clustering method based on bilevel-graph constraint contrast learning
By employing a bilevel-graph-constrained contrastive learning method, combined with squirrel search and GCN network, the representation of single-cell RNA sequencing data is optimized, overcoming the limitations of high-dimensional sparsity and traditional methods, and achieving more accurate cell clustering.
Patent Information
- Application Number
- CN202511013512.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-11-04
AI Technical Summary
The high dimensionality and sparsity of single-cell RNA sequencing data make cluster analysis difficult. Traditional contrastive learning and graph learning methods each have their limitations and cannot effectively capture the topological structure between cells and accurately cluster them.
A two-level graph-constrained contrastive learning approach is adopted. Key genes are screened using a squirrel search optimization algorithm. Cell-cell graphs are constructed by combining cellular and cluster-level contrastive learning. GCN networks are used to enhance the representation, and graph-constrained contrastive learning and reconstruction learning are performed to optimize cell representation.
It significantly improves the clustering accuracy of single-cell RNA sequencing data, effectively handles high-dimensional sparse data, accurately assigns cells to the corresponding clusters, and captures the topological structure between cells without relying on the quality of the initial graph construction.
Smart Images

Figure CN120895104A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a clustering method for single-cell RNA sequencing data based on bilevel graph-constrained contrastive learning, belonging to the field of bioinformatics. Background Technology
[0002] Single-cell RNA sequencing (scRNA-seq) technology has revolutionized our understanding of cellular heterogeneity and dynamics in complex biological systems. Compared to traditional batch RNA sequencing, scRNA-seq can map gene expression profiles at unprecedented resolution, enabling deeper identification and characterization of unknown cell types, detection of rare cell populations, and description of cellular heterogeneity in complex diseases. Therefore, scRNA-seq has become an indispensable tool in the field of biology.
[0003] Cluster analysis is a crucial step in scRNA-seq data analysis, laying the foundation for many downstream tasks. Accurate cell clustering results enable researchers to more precisely identify different cell types and states, reconstruct developmental trajectories, and reveal functional relationships between cell populations. However, the inherent high dimensionality and sparsity of scRNA-seq data pose significant challenges to cluster analysis. To alleviate these issues, a common approach is to perform dimensionality reduction before clustering. For example, pcaReduce first uses PCA for dimensionality reduction and then applies the K-means algorithm for clustering; Seurat first obtains highly variable genes and then uses the Louvain algorithm for clustering; the SC3 algorithm reduces data dimensionality through highly variable genes, calculates inter-cell distances, and performs K-means to generate a consistency matrix. However, dimensionality reduction methods like PCA can only capture linear relationships and cannot effectively model complex nonlinear cell relationships.
[0004] In recent years, deep learning-based scRNA-seq data clustering methods have attracted attention due to their hierarchical representation capabilities. Among them, contrastive learning performs well in single-cell RNA sequencing data clustering due to its ability to effectively learn discriminative representations and its strong robustness to data noise. Graph learning, on the other hand, demonstrates unique advantages in scRNA-seq data clustering due to its ability to effectively model potential relationships and topological structures between cells. Although both contrastive and graph learning show significant advantages in scRNA-seq data clustering, they each have inherent limitations. Traditional contrastive learning methods effectively extract discriminative features but often neglect potential relationships between cells, failing to capture the cell population topology crucial for accurate clustering. In contrast, graph learning methods directly model inter-cell relationships, but their clustering performance is overly dependent on the quality and accuracy of the initial graph construction.
[0005] To address the aforementioned limitations, a clustering method for single-cell RNA sequencing data based on bilevel graph-constrained contrastive learning is proposed. Summary of the Invention
[0006] The problem this invention aims to solve is that it provides a bilevel graph-constrained contrastive learning method for clustering single-cell RNA sequencing data. This method addresses the challenges in the field of single-cell RNA sequencing data, such as the difficulties in representation learning caused by the high dimensionality and sparsity of the data, as well as the limitations of traditional contrastive learning and graph learning. The method significantly improves the accuracy of scRNA-seq data clustering.
[0007] The technical solution of this invention is: a single-cell RNA sequencing data clustering method based on bilevel graph-constrained contrastive learning, the method comprising:
[0008] Step 1: Preprocess the scRNA-seq data and screen key genes using the squirrel search optimization algorithm;
[0009] Step 2: Combine comparative learning at the cellular and cluster levels to learn preliminary characterization;
[0010] Step 3: Construct cell-cell graphs to perform graph-constrained comparative learning on the previously learned preliminary representations to obtain the final enhanced representations, and obtain the scRNA-seq data clustering results through conventional clustering algorithms.
[0011] Furthermore, the specific steps of Step 1 include:
[0012] Step 1.1: For scRNA-seq data, first filter out genes and cells that are not expressed, and then perform data standardization and logarithmic transformation on the filtered data;
[0013] Step 1.2: Use the squirrel search algorithm to screen key genes in the pre-processed scRNA-seq data.
[0014] Furthermore, the specific steps of Step 2 include:
[0015] Step 2.1: Perform data augmentation on the key genes selected by screening, randomly discard a certain proportion of gene expression and add Gaussian noise to obtain two sets of augmented views;
[0016] Step 2.2: Use a momentum encoder to encode the features of the two sets of enhanced views to obtain two encoded representations;
[0017] Step 2.3: For the two encoded representations obtained, use a cell-level projector to project them into a cell-level contrastive learning space to obtain cell-level representations, and use a cluster-level projector to project them into a cluster-level contrastive learning space to obtain cluster-level representations.
[0018] Step 2.4: For the obtained cell-level characterization, perform cell-level comparative learning to optimize the characterization;
[0019] Step 2.5: For the obtained cluster-level representations, perform cluster-level comparative learning to optimize the representations;
[0020] Step 2.6 Finally, cell-level contrast loss and cluster-level contrast loss are combined to optimize cell representation learning and obtain preliminary representations.
[0021] Furthermore, the specific steps of Step 3 include:
[0022] Step 3.1: Use the preprocessed and gene-screened data to construct the original cell-cell map to capture potential relationships between cells;
[0023] Step 3.2: Use Bernoulli distribution to generate feature mask and graph edge mask matrix to enhance the initial representation learned by DCL and the original cell-cell graph constructed, thereby obtaining enhanced representation and enhanced cell-cell graph;
[0024] Step 3.3: Use the GCN network to encode and learn the potential relationships between cells in the preliminary representation generated by DCL and the original cell-cell map, the enhanced representation and the combination of the enhanced cell-cell map, to obtain two sets of map-encoded representations;
[0025] Step 3.4: Project the obtained graph encoding representation onto a low-dimensional space for comparative learning of graph constraints; at the same time, reconstruct the graph encoding representation without data augmentation back to the dimensional space of the initial representation generated by DCL for reconstruction learning.
[0026] Step 3.5 Finally, combined graph constraint contrastive learning and reconstruction learning are used to further optimize cell representation, obtain the final cell representation, and then perform clustering using a conventional clustering algorithm.
[0027] Furthermore, Step 1.2 includes six steps: squirrel initialization, selection of gene subset expression matrix, sorting and classification, position update, seasonal adjustment, and iteration; specifically including:
[0028] Step 1.2.1, Squirrel Initialization: Initialize e squirrels L i Each squirrel represents a possible subset of genes:
[0029]
[0030] Here, θ is a value generated by multiplying a number between 0 and 1 generated from a uniform distribution by π. This represents the value of the j-th gene in the i-th gene subset. This represents the value of the 2000th gene initialized in gene subset i;
[0031] Step 1.2.2: Selecting a subset of gene expression matrices: L i Convert to binary representation The transformation rule is: when α = (cosθ) 2 ≤β=(sinθ) 2 hour, Otherwise Combine I i Based on the pre-processed gene expression matrix, e gene subset expression matrices are determined. Specifically, for I... i ,in If the value is 0, the corresponding gene in the gene expression matrix after preliminary preprocessing is discarded; if the value is 1, the corresponding gene in the gene expression matrix after preliminary preprocessing is retained.
[0032] Step 1.2.3, Sorting and Classification: Perform K-means clustering on the obtained e gene subset expression matrices, calculate the silhouette coefficient f and fitness fit; sort them in descending order of fitness value, record the best squirrel position as hickory tree (ht), the 2nd to 4th positions as acorn tree (at), and the rest as ordinary tree (nt).
[0033] Step 1.2.4, Position Update: Based on squirrel foraging behavior, different update strategies are applied to at and nt, and the presence of predators is taken into account to prevent local optima;
[0034] Step 1.2.5, Seasonal Adjustment: Use half of nt for seasonal adjustment updates, and use the Lévy flight function to prevent the algorithm from getting trapped in local optima;
[0035] Step 1.2.6, Iteration: Repeat steps 2-5 until the maximum number of iterations is reached or the convergence condition is met, to obtain the final optimal solution ht, and screen out the key genes that need to be retained.
[0036] Furthermore, Steps 2.4-2.6 include,
[0037] S2.4, Regarding the obtained cell-level characterization and Cell-level contrastive learning is used to optimize cell-level characterization, as specifically implemented below:
[0038]
[0039] in, This represents cell-level contrast loss, where B is the batch size and Z is the representation from two cell-level representations. and The connection vector, Z i Z is the feature vector from the i-th cell of a cell-level representation. i+ It is a feature vector from another cell-level representation of the same cell, used as Z. i Positive samples, τ1 represents the temperature coefficient used to adjust the discrimination between samples, g∈O(i) is Z i The negative sample index set;
[0040] S2.5, For the obtained cluster-level representation and Cluster-level contrastive learning is used to optimize cluster-level representations, as specifically implemented below:
[0041]
[0042] in, This represents the cluster-level contrastive loss. It is a comparison loss term. This is the entropy regularization term, which prevents the model from grouping all samples into the same or a few clusters during clustering. C is the number of clusters. It is the feature vector of the i-th cluster in a cluster-level representation. It is the feature vector of the i-th cluster in another clustering-level representation, used as Let N(i) be the set of positive samples, j∈N(i) be the set of negative sample indices of the i-th cluster, and sim denote the cosine similarity calculation between vectors. and It is the probability of the i-th cluster, calculated using the Softmax function;
[0043] S2.6 Finally, combined cell-level contrast loss Comparison loss with clustering level As the total loss of the DCL module Cell characterization learning and optimization are performed to obtain preliminary characterization F;
[0044]
[0045] Furthermore, the specific steps of Step 3.1 are as follows:
[0046] Step 3.1.1: Calculate the inter-cell distance D using Manhattan distance. ij :
[0047]
[0048] Where r represents the number of genes in the processed data, x it x represents the expression value of the t-th gene in cell i. jtThis represents the expression value of the t-th gene in cell j;
[0049] For each cell, first select its k nearest neighbors, then further filter these k nearest neighbors according to a predefined distance threshold, retaining neighbors that meet the conditions; finally, calculate the edge weights as follows:
[0050]
[0051] Where, d th Let KNN(i) represent the distance threshold, and KNN(i) represent the k nearest neighbors of cell i.
[0052] After calculation, a weighted graph G is generated. M The edge weight is
[0053] Step 3.1.2: Use attention weights to account for the nonlinear structure of scRNA-seq data:
[0054]
[0055] Where AS represents the original attention score matrix, d k Q' and K' are the dimensions of each attention head, and the preprocessed and gene-selected data are linearly mapped and reshaped into a multi-head form.
[0056] The result AS of multi-head attention is compressed through a linear layer and then normalized using a softmax function:
[0057] AS o =softmax(W O AS)
[0058] Among them, AS o W represents the normalized attention weight score. O The weights represent the output layer of the multi-head attention mechanism, i.e., the linear layer.
[0059] Use a predefined attention weight threshold to determine whether an edge is generated between cell i and cell j:
[0060]
[0061] Among them, a th AS represents the attention weight threshold. oij The attention weight score between cell i and cell j;
[0062] After the above calculations, another weighted graph G is obtained. A Then, take G. M and G AIf there are isolated nodes on the common edges, add self-loops; in this way, the original cell-cell graph G is obtained. For edge weight processing, the weights of the common edges are added together, and the self-loops are set to 1.
[0063] Furthermore, Steps 3.4-3.5 include,
[0064] S3.4 Encode and represent Z from the two sets of graphs obtained. F and Projecting onto a lower-dimensional space yields E ZF and Comparative learning of graph constraints is performed, and Z is also... F Reconstructing back to the dimensional space of the initial representation F yields F C We will refactor and learn, and the specific implementation is as follows:
[0065]
[0066] Where α1 and α2 are the balance graph-constrained contrastive learning losses. Two symmetrical contrast loss terms and The weights, and the calculation method for the two contrasting loss terms are as follows: In the formula, p i The normalized probability of the similarity between cell i and its positive samples relative to the similarity of all cells is represented by d, which is the aggregate similarity between cell i and its positive sample pairs. m represents the number of cells, and d represents the number of positive samples. i This represents the degree of cell i in graph G;
[0067] The positive sample of cell i is defined as follows: a. the original cell i and its corresponding cell in the enhanced view; b. the cell connected to i in the original view via graph edges; c. the corresponding cell in the enhanced view of the cell connected to i in the original view via graph edges; τ2 is the temperature parameter; z is the feature dimension that initially characterizes F, M R It is a binary mask matrix with the same shape as F, F i This represents the i-th dimension of the feature characterizing F. Representing the reconstructed representation F C If the i-th feature in F is zero, then M R The elements in the list are set to 0, otherwise set to 1;
[0068] S3.5 Finally, the joint graph constraint contrasts the learning loss. and reconstructed learning loss As the final loss of the GCL module Further optimize cell characterization to obtain the final cell characterization and perform clustering using the K-means clustering algorithm;
[0069]
[0070] Where λ is a balancing factor used to adjust the graph-constrained contrastive learning loss. and reconstruction loss The relative importance of.
[0071] The present invention also provides a single-cell RNA sequencing data clustering system based on bilevel-graph constraint contrastive learning, the system comprising: a module for performing the single-cell RNA sequencing data clustering method based on bilevel-graph constraint contrastive learning.
[0072] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the bilevel-graph constraint contrastive learning method for clustering single-cell RNA sequencing data.
[0073] The beneficial effects of this invention are:
[0074] 1. This invention first performs data preprocessing and gene screening, and then learns the preliminary characterization of cells through bilevel contrastive learning; then, it obtains enhanced characterization by constructing cell-cell diagram constraints on the preliminary characterization; finally, it uses conventional clustering algorithms to obtain clustering results; this invention demonstrates excellent performance in scRNA-seq data clustering.
[0075] 2. This invention combines the advantages of contrastive learning and graph learning while avoiding their respective shortcomings; it obtains effective preliminary cell representations through bilevel contrastive learning, and then uses Manhattan distance and attention weights to construct cell graphs, designing graph-constrained contrastive loss to further enhance cell representations; this design captures the topological structure between cells without overly relying on the quality of the initial graph construction.
[0076] 3. The method of this invention was compared with 14 baseline methods on 10 real datasets. The invention showed significant advantages in scRNA-seq data clustering, was able to learn cluster-friendly cell representations, effectively handle high-dimensional sparse data, and accurately assign cells to the corresponding clusters. Attached Figure Description
[0077] Figure 1 This is a structural diagram of the method model in this invention. Detailed Implementation
[0078] Example 1: As Figure 1 As shown, a clustering method for single-cell RNA sequencing data based on bilevel graph-constrained contrastive learning is described, the method comprising:
[0079] Step 1: Preprocess the scRNA-seq data and screen key genes using a squirrel search optimization algorithm; the specific steps of Step 1 include:
[0080] Step 1.1: For scRNA-seq data, first use the Scanpy tool to filter out unexpressed genes and cells in the gene counting matrix. Then, perform data standardization and logarithmic transformation on the filtered data to convert the counting matrix into an expression matrix. Next, select the first 2000 hypervariable genes to obtain the preliminary gene expression matrix.
[0081] Step 1.2: The pre-processed gene expression matrix is then processed using a squirrel search algorithm to screen key genes and reduce data dimensionality. This involves six steps: squirrel initialization, selection of a subset of gene expression matrices, sorting and classification, position updating, seasonal adjustment, and iteration. Specifically, this includes:
[0082] Step 1.2.1, Squirrel Initialization: Initialize e squirrels L i Each squirrel represents a possible subset of genes:
[0083]
[0084] Here, θ is a value generated by multiplying a number between 0 and 1 generated from a uniform distribution by π. This represents the value of the j-th gene in the i-th gene subset. This represents the value of the 2000th gene initialized in gene subset i;
[0085] Step 1.2.2: Selecting a subset of gene expression matrices: L i Convert to binary representation The transformation rule is: when α = (cosθ) 2 ≤β=(sinθ) 2 hour, Otherwise Combine I i Based on the pre-processed gene expression matrix, e gene subset expression matrices are determined. Specifically, for I... i ,in If the value is 0, the corresponding gene in the gene expression matrix after preliminary preprocessing is discarded; if the value is 1, the corresponding gene in the gene expression matrix after preliminary preprocessing is retained.
[0086] Step 1.2.3, Sorting and Classification: Perform K-means clustering on the obtained e gene subset expression matrices, calculate the silhouette coefficient f and fitness fit; sort them in descending order of fitness value, record the best squirrel position as hickory tree (ht), the 2nd to 4th positions as acorn tree (at), and the rest as ordinary tree (nt).
[0087] Step 1.2.4, Position Update: Based on squirrel foraging behavior, different update strategies are applied to at and nt, and the presence of predators is taken into account to prevent local optima;
[0088] Step 1.2.5, Seasonal Adjustment: Use half of nt for seasonal adjustment updates, and use the Lévy flight function to prevent the algorithm from getting trapped in local optima;
[0089] Step 1.2.6, Iteration: Repeat steps 2-5 until the maximum number of iterations is reached or the convergence condition is met, to obtain the final optimal solution ht, and screen out the key genes that need to be retained.
[0090] Step 2: Combine contrastive learning at the cellular and cluster levels (DCL) to learn the initial characterization;
[0091] Furthermore, the specific steps of Step 2 include:
[0092] Step 2.1: Perform data augmentation on the key genes selected through screening. Randomly discard a certain proportion of gene expression and add Gaussian noise to obtain two sets of augmented views. and
[0093] Step 2.2: Apply the obtained two sets of enhanced views and Feature encoding is performed using a momentum encoder, resulting in two encoded representations, E1 and E2. Both encoders consist of identical linear layers with parameters P1 and P2, respectively. P1 is updated during training via backpropagation, while P2 is updated using momentum d. The update mechanism is as follows:
[0094]
[0095] in, This represents the updated linear layer parameters P2;
[0096] Step 2.3: For the two encoded representations E1 and E2 obtained, use a cell-level projector to project them onto the cell-level contrastive learning space to obtain cell-level representations. and The cluster-level representation is obtained by projecting it onto a cluster-level contrastive learning space using a cluster-level projector. and
[0097] Step 2.4: For the obtained cell-level characterization and Cell-level contrastive learning is used to optimize cell-level characterization, as specifically implemented below:
[0098]
[0099] in, This represents cell-level contrast loss, where B is the batch size and Z is the representation from two cell-level representations. and The connection vector, Z i Z is the feature vector from the i-th cell of a cell-level representation. i+ It is a feature vector from another cell-level representation of the same cell, used as Z. i Positive samples, τ1 represents the temperature coefficient used to adjust the discrimination between samples, g∈O(i) is Z i The negative sample index set;
[0100] Step 2.5: For the obtained cluster-level representation and Cluster-level contrastive learning is used to optimize cluster-level representations, as specifically implemented below:
[0101]
[0102] in, This represents the cluster-level contrastive loss. It is a comparison loss term. This is the entropy regularization term, which prevents the model from grouping all samples into the same or a few clusters during clustering. C is the number of clusters. It is the feature vector of the i-th cluster in a cluster-level representation. It is the feature vector of the i-th cluster in another clustering-level representation, used as Let N(i) be the set of positive samples, j∈N(i) be the set of negative sample indices of the i-th cluster, and sim denote the cosine similarity calculation between vectors. and It is the probability of the i-th cluster, calculated using the Softmax function;
[0103] Step 2.6 Finally, combine cell-level contrast loss Comparison loss with clustering level As the total loss of the DCL module Cell characterization learning and optimization are performed to obtain preliminary characterization F;
[0104]
[0105] Step 3: Construct cell-cell graphs to perform graph-constrained contrastive learning (GCL) on the previously learned preliminary representations to obtain the final enhanced representations, and obtain the scRNA-seq data clustering results through conventional clustering algorithms.
[0106] Furthermore, the specific steps of Step 3 include:
[0107] Step 3.1: Construct the original cell-cell graph using the preprocessed and gene-screened data to capture potential relationships between cells. Specifically, integrate Manhattan distance and attention weights to capture both linear and nonlinear relationships between cells, thereby generating a more reliable original cell-cell graph G to better capture potential relationships between cells. The specific steps of Step 3.1 are as follows:
[0108] Step 3.1.1: Calculate the inter-cell distance D using Manhattan distance. ij :
[0109]
[0110] Where r represents the number of genes in the processed data, x it x represents the expression value of the t-th gene in cell i. jt This represents the expression value of the t-th gene in cell j;
[0111] For each cell, first select its k nearest neighbors, then further filter these k nearest neighbors according to a predefined distance threshold, retaining neighbors that meet the conditions; finally, calculate the edge weights as follows:
[0112]
[0113] Where, d th Let KNN(i) represent the distance threshold, and KNN(i) represent the k nearest neighbors of cell i.
[0114] After calculation, a weighted graph G is generated. M The edge weight is
[0115] Step 3.1.2: Use attention weights to account for the nonlinear structure of scRNA-seq data:
[0116]
[0117] Where AS represents the original attention score matrix, d k Q' and K' are the dimensions of each attention head, and the preprocessed and gene-selected data are linearly mapped and reshaped into a multi-head form.
[0118] The result AS of multi-head attention is compressed through a linear layer and then normalized using a softmax function:
[0119] AS o =softmax(W O AS)
[0120] Among them, AS o W represents the normalized attention weight score. O The weights represent the output layer of the multi-head attention mechanism, i.e., the linear layer.
[0121] Use a predefined attention weight threshold to determine whether an edge is generated between cell i and cell j:
[0122]
[0123] Among them, a th AS represents the attention weight threshold. oij The attention weight score between cell i and cell j;
[0124] After the above calculations, another weighted graph G is obtained. A Then, take G. M and G A If there are isolated nodes on the common edges, add self-loops; in this way, the original cell-cell graph G is obtained. For edge weight processing, the weights of the common edges are added together, and the self-loops are set to 1.
[0125] Step 3.2: Use Bernoulli distribution to generate feature masks and graph-edge mask matrices to enhance the initial representation F learned by DCL and the constructed original cell-cell graph G, thereby obtaining the enhanced representation F. * And enhanced cell-cell diagram G * ;
[0126] Step 3.3: Using the GCN network, perform preliminary characterization (F) and original cell-cell mapping (G) on the DCL generated, and enhance the characterization (F). * And enhanced cell-cell diagram G * The combination of these methods is used to encode and learn the latent relationships between cells, resulting in two sets of graph-encoded representations Z. F , The specific implementation is as follows:
[0127] Z F =G(GFW) (1) W (2) ,
[0128] Among them, W (1) and W (2) These are the weights of a two-layer GCN network;
[0129] Step 3.4: Project the obtained graph encoding representation onto a low-dimensional space for comparative learning of graph constraints; at the same time, reconstruct the graph encoding representation without data augmentation back to the dimensional space of the initial representation generated by DCL for reconstruction learning.
[0130] Step 3.5 Finally, combined graph constraint contrastive learning and reconstruction learning are used to further optimize cell representation, obtain the final cell representation, and then perform clustering using a conventional clustering algorithm.
[0131] Furthermore, Steps 3.4-3.5 include,
[0132] S3.4 Encode and represent Z from the two sets of graphs obtained. F and Projecting onto a lower-dimensional space yields E ZF and Comparative learning of graph constraints is performed, and Z is also... F Reconstructing back to the dimensional space of the initial representation F yields F C We will refactor and learn, and the specific implementation is as follows:
[0133]
[0134] Where α1 and α2 are the balance graph-constrained contrastive learning losses. Two symmetrical contrast loss terms and The weights, and the calculation method for the two contrasting loss terms are as follows: In the formula, p i The normalized probability of the similarity between cell i and its positive samples relative to the similarity of all cells is represented by d, which is the aggregate similarity between cell i and its positive sample pairs. m represents the number of cells, and d represents the number of positive samples. i This represents the degree of cell i in graph G;
[0135] The positive sample of cell i is defined as follows: a. the original cell i and its corresponding cell in the enhanced view; b. the cell connected to i in the original view via graph edges; c. the corresponding cell in the enhanced view of the cell connected to i in the original view via graph edges; τ2 is the temperature parameter; z is the feature dimension that initially characterizes F, M R It is a binary mask matrix with the same shape as F, F i This represents the i-th dimension of the feature characterizing F. Representing the reconstructed representation F C If the i-th feature in F is zero, then M R The elements in the list are set to 0, otherwise set to 1;
[0136] S3.5 Finally, the joint graph constraint contrasts the learning loss. and reconstructed learning loss As the final loss of the GCL module Further optimize cell characterization to obtain the final cell characterization and perform clustering using the K-means clustering algorithm;
[0137]
[0138] Where λ is a balancing factor used to adjust the graph-constrained contrastive learning loss. and reconstruction loss The relative importance of.
[0139] The present invention also provides a single-cell RNA sequencing data clustering system based on bilevel-graph constraint contrastive learning, the system comprising: a module for performing the single-cell RNA sequencing data clustering method based on bilevel-graph constraint contrastive learning.
[0140] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the bilevel-graph constraint contrastive learning method for clustering single-cell RNA sequencing data.
[0141] This invention first preprocesses the raw scRNA-seq data and uses a squirrel search optimization algorithm to screen key genes, significantly reducing the high dimensionality of the original data. Then, data augmentation is performed on the preprocessed and gene-screened data to generate two augmented views. A momentum encoder is used to encode the two views separately, and the encoded results are projected onto two different dimensional spaces for comparative learning at the cell level and cluster level to learn preliminary representations. Finally, a cell-cell graph is constructed to capture potential relationships between cells, further constraining the previously learned preliminary representations, thereby improving the accuracy of subsequent clustering of scRNA-seq data using conventional clustering algorithms. Experimental results on 10 real scRNA-seq datasets show that the bilevel-graph-constrained comparative learning method for single-cell RNA sequencing data clustering significantly improves the accuracy of scRNA-seq data clustering.
[0142] This invention evaluates the performance of the proposed model on scRNA-seq data clustering tasks. Experiments used 10 real-world datasets: Pollen, Trachea, Lung, Muraro, Bladder, Klein, Romanov, PBMC, Heart, and Splen. Details of the datasets are shown in Table 1.
[0143] Table 1 shows 10 real datasets.
[0144]
[0145]
[0146] To verify the effectiveness of the method of this invention, it was compared with 14 representative scRNA-seq data clustering methods, including: K-means, Louvain, Seurat, SC3, Leiden, GraphSCC, scCDG, scFseCluster, scMCKC, SCCCL, DeepScena, scDECL, scCDCG, and scSimGCL. Adjusted Rand Index (ARI) and Normalized Mutual Information (NMI) were used as evaluation metrics. ARI measures the similarity between two data distributions, ranging from -1 to 1; a value closer to 1 indicates a higher consistency between the clustering results and the true labels. NMI measures the amount of information shared between the clustering results and the true labels, ranging from 0 to 1; a value closer to 1 indicates higher mutual information between the clustering results and the true labels, i.e., better clustering performance.
[0147] Table 2 shows the ARI results of the method of the present invention and 14 comparative methods on 10 real datasets.
[0148]
[0149] Table 3 shows the NMI results of the method of the present invention and 14 comparative methods on 10 real datasets.
[0150]
[0151]
[0152] Based on the experimental results in Tables 2 and 3, the method proposed in this invention exhibits excellent and stable clustering performance. In terms of ARI scores, except for the Pollen and Klein datasets where it ranks second, the method of this invention achieves the best results on all other datasets. Similarly, in terms of NMI scores, except for the Lung and Klein datasets where it ranks second, the method also achieves the best performance on all other datasets. This demonstrates that the method of this invention possesses good generalization ability and robustness, achieving excellent clustering results on different types of single-cell datasets, thus verifying the effectiveness and practicality of the method.
[0153] The specific embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1. A clustering method for single-cell RNA sequencing data based on bilevel graph-constrained contrastive learning, characterized by: The method includes: Step 1: Preprocess the scRNA-seq data and screen key genes using the squirrel search optimization algorithm; Step 2: Combine comparative learning at the cellular and cluster levels to learn preliminary characterization; Step 3: Construct cell-cell graphs to perform graph-constrained comparative learning on the previously learned preliminary representations to obtain the final enhanced representations, and obtain the scRNA-seq data clustering results through conventional clustering algorithms.
2. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 1, characterized in that: The specific steps of Step 1 include: Step 1.1: For scRNA-seq data, first filter out genes and cells that are not expressed, and then perform data standardization and logarithmic transformation on the filtered data; Step 1.2: Use the squirrel search algorithm to screen key genes in the pre-processed scRNA-seq data.
3. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 1, characterized in that: The specific steps of Step 2 include: Step 2.1: Perform data augmentation on the key genes selected by screening, randomly discard a certain proportion of gene expression and add Gaussian noise to obtain two sets of augmented views; Step 2.2: Use a momentum encoder to encode the features of the two sets of enhanced views to obtain two encoded representations; Step 2.3: For the two encoded representations obtained, use a cell-level projector to project them into a cell-level contrastive learning space to obtain cell-level representations, and use a cluster-level projector to project them into a cluster-level contrastive learning space to obtain cluster-level representations. Step 2.4: For the obtained cell-level characterization, perform cell-level comparative learning to optimize the characterization; Step 2.5: For the obtained cluster-level representations, perform cluster-level comparative learning to optimize the representations; Step 2.6 Finally, cell-level contrast loss and cluster-level contrast loss are combined to optimize cell representation learning and obtain preliminary representations.
4. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 1, characterized in that: The specific steps of Step 3 include: Step 3.1: Use the preprocessed and gene-screened data to construct the original cell-cell map to capture potential relationships between cells; Step 3.2: Use Bernoulli distribution to generate feature mask and graph edge mask matrix to enhance the initial representation learned by DCL and the original cell-cell graph constructed, thereby obtaining enhanced representation and enhanced cell-cell graph; Step 3.3: Use the GCN network to encode and learn the potential relationships between cells in the preliminary representation generated by DCL and the original cell-cell map, the enhanced representation and the combination of the enhanced cell-cell map, to obtain two sets of map-encoded representations; Step 3.4: Project the obtained graph encoding representation onto a low-dimensional space for comparative learning of graph constraints; at the same time, reconstruct the graph encoding representation without data augmentation back to the dimensional space of the initial representation generated by DCL for reconstruction learning. Step 3.5 Finally, combined graph constraint contrastive learning and reconstruction learning are used to further optimize cell representation, obtain the final cell representation, and then perform clustering using a conventional clustering algorithm.
5. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 1, characterized in that: Step 1.2 comprises six steps: squirrel initialization, selection of gene subset expression matrix, sorting and classification, position update, seasonal adjustment, and iteration; specifically including: Step 1.2.1, Squirrel Initialization: Initialize e squirrels L i Each squirrel represents a possible subset of genes: Here, θ is a value generated by multiplying a number between 0 and 1 generated from a uniform distribution by π. This represents the value of the j-th gene in the i-th gene subset. This represents the value of the 2000th gene initialized in gene subset i; Step 1.2.2: Selecting a subset of gene expression matrices: L i Convert to binary representation The transformation rule is: when α = (cosθ) 2 ≤β=(sinθ) 2 hour, Otherwise Combine I i Based on the pre-processed gene expression matrix, e gene subset expression matrices are determined. Specifically, for I... i ,in If the value is 0, the corresponding gene in the gene expression matrix after preliminary preprocessing is discarded; if the value is 1, the corresponding gene in the gene expression matrix after preliminary preprocessing is retained. Step 1.2.3, Sorting and Classification: Perform K-means clustering on the obtained e gene subset expression matrices, calculate the silhouette coefficient f and fitness fit; sort them in descending order of fitness value, record the best squirrel position as hickory tree (ht), the 2nd to 4th positions as acorn tree (at), and the rest as ordinary tree (nt). Step 1.2.4, Position Update: Based on squirrel foraging behavior, different update strategies are applied to at and nt, and the presence of predators is taken into account to prevent local optima; Step 1.2.5, Seasonal Adjustment: Use half of nt for seasonal adjustment updates, and use the Lévy flight function to prevent the algorithm from getting trapped in local optima; Step 1.2.6, Iteration: Repeat steps 2-5 until the maximum number of iterations is reached or the convergence condition is met, to obtain the final optimal solution ht, and screen out the key genes that need to be retained.
6. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 3, characterized in that: Steps 2.4-2.6 include, S2.4, Regarding the obtained cell-level characterization and Cell-level contrastive learning is used to optimize cell-level characterization, as specifically implemented below: in, This represents cell-level contrast loss, where B is the batch size and Z is the representation from two cell-level representations. and The connection vector, Z i Z is the feature vector from the i-th cell of a cell-level representation. i+ It is a feature vector from another cell-level representation of the same cell, used as Z. i Positive samples, τ1 represents the temperature coefficient used to adjust the discrimination between samples, g∈O(i) is Z i The negative sample index set; S2.5, For the obtained cluster-level representation and Cluster-level contrastive learning is used to optimize cluster-level representations, as specifically implemented below: in, This represents the cluster-level contrastive loss. It is a comparison loss term. This is the entropy regularization term, which prevents the model from grouping all samples into the same or a few clusters during clustering. C is the number of clusters. It is the feature vector of the i-th cluster in a cluster-level representation. It is the feature vector of the i-th cluster in another clustering-level representation, used as Let N(i) be the set of positive samples, j∈N(i) be the set of negative sample indices of the i-th cluster, and sim denote the cosine similarity calculation between vectors. and It is the probability of the i-th cluster, calculated using the Softmax function; S2.6 Finally, combined cell-level contrast loss Comparison loss with clustering level As the total loss of the DCL module Cell characterization learning and optimization are performed to obtain preliminary characterization F; 7. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 4, characterized in that: The specific steps of Step 3.1 are as follows: Step 3.1.1: Calculate the inter-cell distance D using Manhattan distance. ij : Where r represents the number of genes in the processed data, x it x represents the expression value of the t-th gene in cell i. jt This represents the expression value of the t-th gene in cell j; For each cell, first select its k nearest neighbors, then further filter these k nearest neighbors according to a predefined distance threshold, retaining neighbors that meet the conditions; finally, calculate the edge weights as follows: Where, d th Let KNN(i) represent the distance threshold, and KNN(i) represent the k nearest neighbors of cell i. After calculation, a weighted graph G is generated. M The edge weight is Step 3.1.2: Use attention weights to account for the nonlinear structure of scRNA-seq data: Where AS represents the original attention score matrix, d k Q' and K' are the dimensions of each attention head, and the preprocessed and gene-selected data are linearly mapped and reshaped into a multi-head form. The result AS of multi-head attention is compressed through a linear layer and then normalized using a softmax function: AS o =softmax(W O AS) Among them, AS o W represents the normalized attention weight score. O The weights represent the output layer of the multi-head attention mechanism, i.e., the linear layer. Use a predefined attention weight threshold to determine whether an edge is generated between cell i and cell j: Among them, a th AS represents the attention weight threshold. oij The attention weight score between cell i and cell j; After the above calculations, another weighted graph G is obtained. A Then, take G. M and G A If there are isolated nodes on the common edges, add self-loops; in this way, the original cell-cell graph G is obtained. For edge weight processing, the weights of the common edges are added together, and the self-loops are set to 1.
8. The single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning according to claim 4, characterized in that: Steps 3.4 and 3.5 include, S3.4 Encode and represent Z from the two sets of graphs obtained. F and Z F *Projecting to a lower-dimensional space yields E ZF and E ZF * Perform comparative learning of graph constraints, and simultaneously, Z F Reconstructing back to the dimensional space of the initial representation F yields F C We will refactor and learn, and the specific implementation is as follows: Where α1 and α2 are the balance graph-constrained contrastive learning losses. Two symmetrical contrast loss terms and The weights, and the calculation method for the two contrasting loss terms are as follows: In the formula, p i The normalized probability of the similarity between cell i and its positive samples relative to the similarity of all cells is represented by d, which is the aggregate similarity between cell i and its positive sample pairs. m represents the number of cells, and d represents the number of positive samples. i This represents the degree of cell i in graph G; The positive sample of cell i is defined as follows: a. the original cell i and its corresponding cell in the enhanced view; b. the cell connected to i in the original view via graph edges; c. the corresponding cell in the enhanced view of the cell connected to i in the original view via graph edges; τ2 is the temperature parameter; z is the feature dimension that initially characterizes F, M R It is a binary mask matrix with the same shape as F, F i This represents the i-th dimension of the feature characterizing F. Representing the reconstructed representation F C If the i-th feature in F is zero, then M R The elements in the list are set to 0, otherwise set to 1; S3.5 Finally, the joint graph constraint contrasts the learning loss. and reconstructed learning loss As the final loss of the GCL module Further optimize cell characterization to obtain the final cell characterization and perform clustering using the K-means clustering algorithm; Where λ is a balancing factor used to adjust the graph-constrained contrastive learning loss. and reconstruction loss The relative importance of.
9. A single-cell RNA sequencing data clustering system based on bilevel-graph-constrained contrastive learning, characterized in that, The system includes a module for performing a single-cell RNA sequencing data clustering method based on bilevel-graph-constrained contrastive learning as described in any one of claims 1-8.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the single-cell RNA sequencing data clustering method of bilevel-graph constraint contrastive learning as described in any one of claims 1-8.