Single cell recognition method and storage medium
By acquiring and processing single-cell data, and combining pre-trained gene features and multi-task loss to optimize the deep learning network, the problem of low accuracy in rare cell identification of large models in resource-constrained scenarios is solved, and efficient single-cell identification under resource-constrained conditions is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies face challenges in rapidly deploying large models in resource-constrained scenarios, including the overwhelming of rare cell states and the difficulty in balancing batch correction with biological differences.
By acquiring raw gene expression data of single cells, gene tag comparison table, and pre-trained prior gene feature data, and after standardization processing, single-cell corrected gene expression data is constructed to generate cell supervision tags. Cell multimodal deep learning network is then used for iterative training, and the network is optimized by combining multi-task loss to achieve cell recognition.
This technology improves the accuracy of single-cell recognition under resource-constrained hardware conditions, while taking into account batch robustness and biological interpretability. It solves the problem of rare cell states being overwhelmed and is suitable for resource-constrained scenarios such as hospitals and universities.
Smart Images

Figure CN121354689B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of single-cell data processing technology, and in particular to single-cell identification methods and storage media. Background Technology
[0002] Breakthroughs in single-cell RNA sequencing (scRNA-seq) technology have opened up entirely new dimensions for life science research. It can analyze transcriptome information at the single-cell level, helping researchers accurately capture cellular heterogeneity, trace cell developmental trajectories, and elucidate the molecular mechanisms of disease microenvironments. It has become a core technology in fields such as tumor subtyping, stem cell research, and immune regulation. While single-cell RNA sequencing can analyze transcriptome information in a single cell and help reveal key biological questions such as cellular heterogeneity, it is limited by the high-dimensional sparsity problem, only able to detect 10%–30% of transcripts per cell. This zero-count leads to the masking of true expression signals and biases in cell similarity calculations. Traditional imputation algorithms have poor adaptability to rare subtypes or cross-species data, and cell subtyping relying solely on single-gene expression values faces information bottlenecks. To overcome these limitations, large-scale single-cell models such as scGPT and scFoundation have emerged. These models rely on architectures like Transformer for self-supervised learning on massive datasets, providing high-quality gene-cell relationship embeddings and improving the accuracy of downstream tasks. However, while large models provide prior knowledge, they are limited by high computing power and highly coupled engineering frameworks, making it difficult to deploy quickly in resource-constrained scenarios. Existing algorithms lack explicit modeling of "biological activity" or "pathway modules," resulting in rare cell states being overwhelmed, and batch correction and biological differences are difficult to balance.
[0003] Currently, no effective solutions have been proposed to address the challenges of rapidly deploying large models in resource-constrained scenarios, the overwhelming of rare cell states, and the difficulty in balancing batch calibration with biological differences in related technologies. Summary of the Invention
[0004] This application provides a single-cell identification method and storage medium to at least solve the problem of low accuracy in single-cell identification in related technologies.
[0005] In a first aspect, embodiments of this application provide a single-cell identification method, the method comprising:
[0006] Acquire raw gene expression data of single cells, gene tag comparison table, and pre-training prior gene feature data;
[0007] Based on the raw gene expression data of the single cells, at least after standardization, single-cell corrected gene expression data is obtained; based on the single-cell corrected gene expression data, cell supervision tags are generated.
[0008] Based on the gene expression matrix obtained directly or after further processing of one of the single-cell raw gene expression data and the single-cell corrected gene expression data, and with the gene tag comparison table, a single-cell gene set activity matrix is constructed.
[0009] Based on the single-cell gene set activity matrix, the cell supervision label, the pre-training prior gene feature data, and the single-cell corrected gene expression data, a training dataset is generated, and the training dataset is input into the classifier and reconstruction module of the initial cell multimodal deep learning network to obtain cell prediction classification results and single-cell gene set reconstruction activity matrix;
[0010] The label loss is obtained based on the difference between the cell prediction classification result and the cell supervision label. The reconstruction loss is obtained based on the difference between the single-cell gene set reconstruction activity matrix and the single-cell gene set activity matrix. The label loss and the reconstruction loss are weighted and merged to calculate the total loss result. The gradient of the total loss result is backpropagated to the initial cell multimodal deep learning network for iterative training. The training is terminated based on the total loss result and a cell multimodal deep learning network is generated.
[0011] Single-cell corrected gene expression data are input into the cell multimodal deep learning network to infer cell fusion embedding results; based on the cell fusion embedding results, single-cell recognition results are obtained.
[0012] In some embodiments, the raw single-cell gene expression data includes an integer matrix between single cells and genes; the corrected single-cell gene expression data includes a floating-point matrix between single cells and genes; the gene tag lookup table includes the correspondence between gene sets and genes; the step of constructing a single-cell gene set activity matrix based on the gene expression matrix obtained directly or after further processing of one of the raw single-cell gene expression data and the corrected single-cell gene expression data, and the gene tag lookup table, includes:
[0013] For each single cell in the original gene expression data or the corrected gene expression data, the values of each gene in the gene expression matrix are combined and calculated using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set, thereby obtaining the relationship between the cell and the gene set and forming the single cell gene set activity matrix.
[0014] In some embodiments, the step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set includes:
[0015] The steps involve calculating the gene expression detection rate for each gene set, and then using the detection rate as a weight to process the combined calculation results to obtain the activity value of each gene set.
[0016] In some embodiments, the step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set includes:
[0017] For each gene set, the values of each gene in the gene expression matrix are first summed, then averaged according to the number of genes contained in the gene set, and then the average value is multiplied by the detection rate to obtain the basic activity value, thereby obtaining the activity value of each gene set based on the basic activity value.
[0018] In some embodiments, the step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set further includes the step of obtaining the activity value of each gene set based on the basic activity value through dispersion gain, which is specifically implemented by the following method:
[0019] ;
[0020] ;
[0021] ;
[0022] Where, n i Let μ be the base activity value of each gene in the matrix, N be the number of genes in the gene set, σ be the standard deviation, cv be the coefficient of variation, ε be a minimum value to avoid cv being uncalcifiable when μ is zero, sigmoid be the activation function based on cv value, and cv_factor be the dispersion gain. Then, the activity value of each gene set is obtained based on the cv_factor.
[0023] In some embodiments, the initial cellular multimodal deep learning network further includes a dual-branch fusion module. The step of inputting the training dataset into the classifier and reconstruction module of the initial cellular multimodal deep learning network to obtain cell prediction classification results and a single-cell gene set reconstruction activity matrix includes:
[0024] The training dataset is input into the initial cellular multimodal deep learning network, and the cell fusion embedding vector is generated via the dual-branch fusion module.
[0025] The cell fusion embedding vector is input into the classifier and the reconstruction module respectively to obtain the cell prediction classification result and the single-cell gene set reconstruction activity matrix.
[0026] In some embodiments, the step of inputting the training dataset into an initial cellular multimodal deep learning network and generating a cell fusion embedding vector via the dual-branch fusion module includes:
[0027] The single-cell corrected gene expression data and the pre-trained prior gene feature data are input into the first coding branch of the dual-branch fusion module to generate gene coding vectors.
[0028] The single-cell gene set activity matrix is input into the second coding branch of the dual-branch fusion module to generate a gene set activity coding vector.
[0029] The cell fusion embedding vector is generated based on the gene encoding vector and the gene set activity encoding vector.
[0030] In some embodiments, the process of generating the cell fusion embedding vector based on the gene coding vector and the gene set activity coding vector includes a step of splicing and linear projection.
[0031] In some embodiments, the first coding branch includes a gene weight generation module, an expression relabeling module, and a gene coding module, wherein:
[0032] The gene weight generation module is used to map the pre-trained prior gene feature data into a 0-1 weight vector of the same length as the number of input genes.
[0033] The expression relabeling module is used to multiply the weight vector element-wise with the single-cell corrected gene expression data to obtain a weighted gene expression vector.
[0034] The gene coding module is used to map the weighted gene expression vector into a fixed-dimensional gene coding vector.
[0035] In some embodiments, the expression remarking module is composed of an element-wise multiplier.
[0036] In some embodiments, the second coding branch includes a gene set activity input module and a linear mapping module, wherein:
[0037] The gene set activity input module is used to receive the single-cell gene set activity matrix;
[0038] The linear mapping module is used to map the gene set activity vector to the activity coding vector.
[0039] In some embodiments, the linear mapping module includes a fifth linear transformation layer, a second batch normalization layer, and a fourth activation layer.
[0040] In some embodiments, the single-cell corrected gene expression data is one of the following:
[0041] 1) The results of the standardized processing of the original gene expression data of the single cells;
[0042] 2) The results of the single-cell original gene expression data after standardization and logarithmic transformation;
[0043] 3) The results of the single-cell original gene expression data after standardization, logarithmic transformation, and numerical correction;
[0044] 4) The results of the single-cell original gene expression data after standardization, logarithmic transformation and numerical interpolation.
[0045] In some embodiments, generating cell supervision tags based on the single-cell corrected gene expression data includes:
[0046] Based on the single-cell corrected gene expression data, a neighbor matrix is constructed, and the neighbor matrix is clustered to generate the cell supervision label.
[0047] Secondly, embodiments of this application provide a storage medium storing a computer program that, when executed by a processor, implements the single-cell identification method as described in the first aspect above.
[0048] Compared to related technologies, the single-cell identification method and storage medium provided in this application acquire single-cell raw gene expression data, a gene tag lookup table, and pre-training prior gene feature data; based on the single-cell raw gene expression data, at least after standardization, obtain single-cell corrected gene expression data; based on the single-cell corrected gene expression data, generate cell supervision tags; based on a matrix obtained directly or after further processing of one of the single-cell raw gene expression data and the single-cell corrected gene expression data, construct a single-cell gene set activity matrix with the gene tag lookup table; based on the single-cell gene set activity matrix, cell supervision tags, pre-training prior gene feature data, and single-cell corrected gene expression data, generate a training dataset, and input the training dataset into the initial... In the classifier and reconstruction modules of the cell multimodal deep learning network, cell prediction classification results and single-cell gene set reconstruction activity matrices are obtained. Label loss is obtained based on the difference between the cell prediction classification results and cell supervision labels, and reconstruction loss is obtained based on the difference between the single-cell gene set reconstruction activity matrix and the single-cell gene set activity matrix. The label loss and reconstruction loss are weighted and merged to calculate the total loss result. The gradient of the total loss result is backpropagated to the initial cell multimodal deep learning network for iterative training. Training is terminated based on the total loss result, and a cell multimodal deep learning network is generated. Single-cell corrected gene expression data is input into the cell multimodal deep learning network, and cell fusion embedding results are obtained through inference. Based on the cell fusion embedding results, single-cell recognition results are obtained. Based on this, on the one hand, by acquiring three types of core data and standardizing the original gene expression data, and then combining it with calibration data to generate cell supervision labels, a gene set activity matrix is constructed based on the original / calibrated data and gene label comparison table. This process transforms high-dimensional sparse data at the single gene level into activity information at the functional module level, and superimposes the dynamic calibration of expression signals by pre-trained prior gene features, effectively overcoming the information bottleneck caused by zero expansion of single-cell data and solving the problem of rare cell states being submerged. On the other hand, by pre-training prior gene feature data and optimizing the initial cell multimodal deep learning network through multi-task loss (label loss + reconstruction loss) during the training phase, the network achieves both classification and reconstruction tasks with only <50MB of parameters, significantly reducing the hardware threshold. It can run on a single 8GB consumer-grade graphics card, making it suitable for resource-constrained scenarios such as hospitals and universities. On the other hand, the inference phase outputs cell fusion embedding results based on the trained network. These results integrate gene expression and functional module information, and combine Leiden clustering and UMAP visualization to obtain single-cell recognition results. Furthermore, the batch effect is corrected by scVI and the loss constraint functional information is reconstructed, which can take into account both batch robustness and biological interpretability, solve the black box problem of traditional models, and provide reliable support for accurate cell annotation.
[0049] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0050] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0051] Figure 1 This is a hardware structure block diagram of a terminal for a single-cell identification method according to an embodiment of this application;
[0052] Figure 2 This is a flowchart of a single-cell identification method according to an embodiment of this application;
[0053] Figure 3 It is a UMAP map generated based on cell embedding tags according to the embodiments of this application. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application. Furthermore, it is understood that although the efforts made in such a development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, modifications to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.
[0055] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0056] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application means two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The terms “first,” “second,” “third,” etc., used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.
[0057] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. Taking running on a terminal as an example, Figure 1 This is a hardware structure block diagram of a terminal for a single-cell identification method according to an embodiment of this application. Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0058] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the single-cell identification method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0059] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0060] This embodiment provides a single-cell identification method. Figure 2 This is a flowchart of a single-cell identification method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps:
[0061] Step S201: Obtain single-cell raw gene expression data, gene tag comparison table, and pre-training prior gene feature data.
[0062] Specifically, in the initial data preparation stage of the single-cell identification process, three types of core input data need to be systematically acquired to support subsequent model training and inference: The first is the initial raw gene expression data of single cells. This data is usually stored in matrix form (rows represent single cells, columns represent genes), and the matrix elements are integer UMI (Unique Molecular Identifier) counts or raw sequencing reads (reads refer to short sequence fragments obtained after the instrument sequences RNA fragments during the sequencing process). This directly reflects the transcript abundance of each gene in a single cell and is the basis for all subsequent data processing and analysis. Typical sources include 10x... The first is the raw data file (e.g., .h5ad, .mtx format) produced by single-cell sequencing technologies such as Genomics and Smart-seq2; the second is the initial gene tag mapping table. This table needs to clearly define the correspondence between genes and functional gene sets (e.g., signaling pathways, metabolic pathways, transcription factor regulatory networks, etc.). The common format is a table file containing two columns: gene symbol and gene set tag. Gene set tags can be sourced from authoritative databases such as KEGG, Reactome, and GO, and support the simultaneous association of a single gene with multiple functional gene sets (e.g., a gene can belong to both the glycolysis pathway and the energy metabolism module). This provides prior biological knowledge for subsequent construction of gene set activity matrices and mining of cellular functional module information. The third component is pre-training prior gene feature data. This data consists of gene-level feature representations extracted from large-scale single-cell pre-training models (such as scGPT, scFoundation, GenePT, etc.). It is typically provided in the form of a gene vector file (.npy format, shape [number of genes, feature dimension], commonly 512 dimensions) + a gene name list file (.csv format, corresponding one-to-one with the gene order in the vector file). The vectors contain general knowledge such as gene co-expression relationships and species conservation characteristics learned by the pre-training model from millions to tens of millions of single-cell data points. This knowledge can be used for subsequent dynamic calibration of gene expression signals, improving the model's ability to identify rare cell subtypes. Then, using gene names as a matching benchmark, the initial raw single-cell gene expression data and the initial gene label lookup table are matched to obtain an intersection gene set. Based on this intersection gene set, the original single-cell gene expression count and gene label lookup table are extracted separately. Meanwhile, for the pre-training prior gene feature data, gene features that match the intersection gene set are selected. For missing genes that do not appear in the intersection gene set, their feature dimensions are filled with zero vectors to ensure that the number of genes in the pre-training prior gene feature data is consistent with the intersection gene set and to maintain a fixed data dimension.
[0063] Step S202: Based on the original gene expression data of single cells, at least after standardization, obtain single-cell corrected gene expression data; based on the single-cell corrected gene expression data, generate cell supervision tags.
[0064] Specifically, core preprocessing operations are performed on the acquired raw single-cell gene expression data to obtain single-cell corrected gene expression data. This process requires at least standardization, which normalizes the total gene expression of each cell to a fixed target value, eliminating expression deviations caused by differences in cell sequencing depth. Depending on the data characteristics and downstream requirements, logarithmic transformation can be further applied to compress the dynamic range of values and reduce the impact of extreme values, or numerical correction can be performed using tools such as scVI and Seurat (to eliminate batch effects and technical noise), ultimately forming floating-point single-cell corrected gene expression data that meets the model input requirements. When generating cell supervision labels based on the above single-cell corrected gene expression data, the expression similarity between cells is first quantified by constructing a cell neighbor matrix. Then, unsupervised clustering algorithms (such as Leiden and Louvain algorithms) are used to perform cluster analysis on the neighbor matrix. By traversing the resolution parameters and combining the Silhouette coefficient, the optimal clustering results are selected, and each cluster is labeled as a unique category label, ultimately generating cell supervision labels for model training. These labels can accurately reflect the potential subtype division of the cell population, providing supervision signals for subsequent classification tasks of multimodal deep learning networks.
[0065] Step S203: Based on the matrix obtained directly or after further processing of one of the single-cell raw gene expression data and single-cell corrected gene expression data, and with the gene tag comparison table, construct a single-cell gene set activity matrix.
[0066] Specifically, the process begins by selecting either raw single-cell gene expression data (an integer UMI counting matrix) or corrected single-cell gene expression data (a floating-point matrix processed with standardization, log1p, etc.), and further processing as needed (e.g., batch correction of raw data, filtering of low-quality genes from corrected data) to obtain a core matrix in the cell-gene dimension. Next, a gene tag lookup table is used to match genes in the core matrix with the lookup table using standardized gene naming, thus identifying the gene set to which each gene belongs. Then, for each single cell, gene set values are calculated and merged, with the gene set as the dimension. Finally, the gene set activity values of all single cells are integrated to form a single-cell gene set activity matrix of "number of single cells × number of gene sets".
[0067] Step S204: Based on the single-cell gene set activity matrix, cell supervision labels, pre-training prior gene feature data, and single-cell corrected gene expression data, a training dataset is generated. The training dataset is then input into the classifier and reconstruction module of the initial cell multimodal deep learning network to obtain cell prediction classification results and single-cell gene set reconstruction activity matrix.
[0068] Specifically, the single-cell gene set activity matrix, cell supervision labels, pre-training prior gene feature data, and single-cell calibration gene expression data are first aligned: the single-cell gene set activity matrix and single-cell calibration gene expression data need to be matched by gene name, retaining genes that overlap with the pre-training prior gene feature data. Then, the training / validation sets are divided according to the combination of "single sample = calibration expression vector + gene set activity vector + gene feature vector + supervision label" to form the training dataset. Then, the training dataset is input into the initial cell multimodal deep learning network in batches. It first generates cell fusion embedding vectors through a two-branch fusion module, and then inputs them into the classifier and reconstruction module respectively: the classifier outputs class logits through linear layers to obtain the cell prediction classification result; the reconstruction module decodes through gating units and attention mechanisms, and combines linear layers and sigmoid activation to generate a single-cell gene set reconstruction activity matrix with the same dimensions as the original matrix.
[0069] Step S205: Obtain the label loss based on the difference between the cell prediction classification result and the cell supervision label; obtain the reconstruction loss based on the difference between the single-cell gene set reconstruction activity matrix and the single-cell gene set activity matrix; calculate the total loss result by weighted merging of the label loss and the reconstruction loss; backpropagate the gradient of the total loss result to the initial cell multimodal deep learning network for iterative training; terminate the training based on the total loss result and generate the cell multimodal deep learning network.
[0070] Specifically, the model training phase requires parameter iteration through multi-task loss calculation and gradient optimization: First, the label loss is calculated based on the cell prediction classification result and the cell supervision label. The classification error can be quantified using the cross-entropy loss function to reflect the accuracy of cell type discrimination. Next, the reconstruction loss is calculated based on the single-cell gene set reconstruction activity matrix and the single-cell gene set activity matrix. The numerical deviation can be calculated using the mean squared error loss function to ensure the model's learning function information. Then, the total loss is obtained by weighting and merging at α=0.7 (configurable), i.e., total loss = α × label loss + (1-α) × reconstruction loss. The gradient of the total loss is backpropagated to the initial network, and the parameters are updated using the AdamW optimizer for iterative training. At the same time, the change in the total loss is monitored, and training is terminated based on the total loss result, ultimately generating a converged cell multimodal deep learning network.
[0071] Step S206: Input the single-cell corrected gene expression data into the cell multimodal deep learning network to infer the cell fusion embedding result; based on the cell fusion embedding result, obtain the single-cell recognition result.
[0072] Specifically, during inference, single-cell corrected gene expression data is input into the cellular multimodal deep learning network. The data is processed by a two-branch fusion module: the first branch uses weighted corrected expression data generated from pre-trained prior gene features and then encodes it into gene vectors; the second branch transforms gene set activity information into activity vectors, and the two vectors are concatenated and compressed to obtain the cell fusion embedding result. Based on this result, cell clusters are divided using Leiden clustering, combined with UMAP visualization, and the cell types are labeled by matching the category mapping relationship during the training phase, ultimately obtaining single-cell recognition results with subtype classification.
[0073] Through steps S201 to S206, on the one hand, by acquiring three types of core data and standardizing the original gene expression data, and then combining the calibration data to generate cell supervision labels, a gene set activity matrix is constructed based on the original / calibrated data and gene label comparison table. This process transforms high-dimensional sparse data at the single-gene level into activity information at the functional module level, and superimposes the dynamic calibration of expression signals by pre-trained prior gene features, effectively breaking through the information bottleneck caused by the "zero expansion" of single-cell data and solving the problem of rare cell states being submerged. On the other hand, by using pre-trained prior gene feature data and optimizing the initial cell multimodal deep learning network through multi-task loss (label loss + reconstruction loss) during the training phase, and with the network using only <50MB of parameters to achieve both classification and reconstruction tasks, the hardware threshold is significantly reduced, requiring only a single 8GB consumer-grade graphics card to run, making it suitable for resource-constrained scenarios such as hospitals and universities. On the other hand, the inference phase outputs cell fusion embedding results based on the trained network. These results integrate gene expression and functional module information, and combine Leiden clustering and UMAP visualization to obtain single-cell recognition results. Furthermore, the batch effect is corrected by scVI and the loss constraint functional information is reconstructed, which can take into account both batch robustness and biological interpretability, solve the black box problem of traditional models, and provide reliable support for accurate cell annotation.
[0074] In some embodiments, the single-cell raw gene expression data includes an integer value matrix between single cells and genes; the single-cell corrected gene expression data includes a floating-point value matrix between single cells and genes; the gene tag lookup table includes the correspondence between gene sets and genes; the step of constructing a single-cell gene set activity matrix based on a matrix obtained directly or after further processing of one of the single-cell raw gene expression data and the single-cell corrected gene expression data, and the gene tag lookup table, includes:
[0075] For each single cell in the original gene expression data or the corrected gene expression data, the values of each gene in the gene expression matrix are combined and calculated using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set, thereby obtaining the relationship between the cell and the gene set and forming the single cell gene set activity matrix.
[0076] Specifically, when constructing the single-cell gene set activity matrix, each single cell in the original gene expression data or the corrected gene expression data needs to be processed one by one: First, the gene tag lookup table is called to identify the complete gene set to which each gene in the gene matrix corresponding to the single cell belongs; then, each gene set in the gene tag lookup table is used as an independent calculation dimension, and the original count values of all genes belonging to the same gene set in the single-cell gene matrix are merged and calculated; finally, the activity values of all gene sets corresponding to each single cell are integrated to form a single-cell gene set activity matrix with single cells as rows and gene sets as columns. Each element in the matrix accurately reflects the activity status of a specific functional gene set in a single cell, providing functional-level feature input for subsequent cell multimodal deep learning networks.
[0077] The above steps, by merging and calculating the gene values of each single cell using the gene set in the gene tag lookup table as the dimension, not only compress the high-dimensional gene dimension to the low-dimensional functional module dimension, reducing the computational complexity of subsequent models, but also highlight functional association signals (such as pathway activities specific to rare cell subtypes) that are masked by sparse noise at the single gene level through activity integration at the gene set level. At the same time, this process establishes a direct association between cells and functional gene sets, and the resulting single-cell gene set activity matrix not only preserves the functional state differences of individual cells, but also provides highly interpretable biological functional feature inputs for subsequent cell multimodal deep learning networks, laying the foundation for improving the resolution and biological significance of cell subtype identification.
[0078] In some embodiments, the step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set includes:
[0079] The steps involve calculating the gene expression detection rate for each gene set, and then using the detection rate as a weight to process the combined calculation results to obtain the activity value of each gene set.
[0080] Specifically, each functional gene set is processed separately. First, all genes in the set are traversed, and their corresponding expression values are located in the gene expression matrix. The number of genes with expression values greater than 0 is counted, and this number is compared with the total number of genes in the set to calculate the gene expression detection rate for that set in the current analysis scenario. Next, the gene expression values of all genes in the set are merged in the gene expression matrix. Common merging methods include summing the gene expression values and taking the average, or direct summation, to obtain the merged result. Finally, the previously calculated gene expression detection rate is used as a weight and multiplied by the merged result. The merged result is dynamically adjusted based on the detection rate to ultimately obtain the activity value of the gene set, thus realizing the transformation from single-gene expression data to quantitative gene set activity data.
[0081] The above steps, by calculating the gene expression detection rate for each gene set, can accurately determine the actual expression coverage of genes within that gene set in a single cell, avoiding false activity signals caused by the non-expression of some genes. Then, by weighting the merged calculation results with the detection rate, the activity values can be dynamically calibrated. When the detection rate is high (most genes are effectively expressed), the weights can strengthen the true functional activity reflected in the merged results; when the detection rate is low (most genes are not expressed), the weights can weaken the merged results under noise interference, reducing false positives. The final gene set activity values more closely match the true functional state of cells, providing reliable functional feature input for subsequent construction of single-cell gene set activity matrices and training of multimodal deep learning networks, thus helping to improve the resolution and interpretability of cell subtype identification.
[0082] In some embodiments, the step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set includes:
[0083] For each gene set, the values of each gene in the gene expression matrix are first summed, then averaged according to the number of genes contained in the gene set, and then the average value is multiplied by the detection rate to obtain the basic activity value, thereby obtaining the activity value of each gene set based on the basic activity value.
[0084] Specifically, each functional gene set is processed individually. First, the expression values of all genes in the gene set are located and extracted from the gene expression matrix. Then, the extracted gene expression values are summed to obtain the total expression value of all genes in the gene set. This total expression value is then divided by the total number of genes in the gene set to calculate the average expression value of the genes in the gene set, thus initially quantifying the overall expression level of the gene set. Subsequently, the detection rate of gene expression values for the gene set needs to be calculated in advance, and the average expression value of the gene set obtained above is multiplied by the detection rate to obtain the basic activity value of the gene set. Finally, based on the basic activity value, the activity values of each gene set that can accurately reflect the functional activation state of the gene set in the cell are obtained.
[0085] Through the above steps, the gene expression values within the gene set are first summed and averaged, which preliminarily integrates information at the single-gene level, reflecting the overall expression level of the gene set and avoiding information fragmentation caused by scattered single-gene data. Then, the mean is multiplied by the detection rate to obtain the baseline activity value. Noise can be dynamically filtered using the detection rate; if the detection rate is low (most genes are not expressed), the product will weaken any spurious signals that may exist in the mean; if the detection rate is high (most genes are effectively expressed), it will strengthen the true activity characteristics. Finally, the gene set activity value obtained based on the baseline activity value retains the overall expression pattern of the gene set and closely reflects the actual functional activation of cells. This solves the problems of traditional merging calculations ignoring gene expression coverage and being susceptible to sparse noise, laying the foundation for constructing a reliable single-cell gene set activity matrix and improving the recognition accuracy of subsequent multimodal deep learning networks.
[0086] In some embodiments, the step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set further includes the step of obtaining the activity value of each gene set based on the basic activity value through dispersion gain, which is specifically implemented by the following method:
[0087] ;
[0088] ;
[0089] ;
[0090] Where, n i Let μ be the base activity value of each gene in the matrix, N be the number of genes in the gene set, σ be the standard deviation, cv be the coefficient of variation, ε be a minimum value to avoid cv being uncalcifiable when μ is zero, sigmoid be the activation function based on cv value, and cv_factor be the dispersion gain. Then, the activity value of each gene set is obtained based on the cv_factor.
[0091] Specifically, calculate the corresponding numerical value (denoted as n) of each gene in the gene set in the expression matrix. i The standard deviation σ of ) is obtained through the formula The calculation is performed, where μ is the baseline activity value of the gene set obtained above, N is the total number of genes in the gene set, and the standard deviation is used to quantify the dispersion of the expression values of each gene in the gene set. Next, the coefficient of variation cv is calculated based on the standard deviation σ and the baseline activity value μ, using the formula cv = σ / (μ + ε), and a minimum value ε is introduced (taking a value of...). The purpose of this optimization is to avoid the situation where the denominator is zero and cv cannot be calculated when the baseline activity value μ is zero. The coefficient of variation cv can further standardize the discrete level of gene expression within the gene set, eliminating the interference of numerical magnitude on the discreteness judgment. Then, the calculated coefficient of variation cv is input into the sigmoid activation function to obtain the discreteness gain factor cv_factor. The sigmoid function can map the cv value to the 0-1 interval, so that cv_factor can reflect the difference in gene expression discreteness while avoiding the excessive influence of extreme discrete values on the activity value. Finally, the baseline activity value and cv_factor are fused and calculated to obtain the activity value of each gene set after discreteness gain optimization. This optimization step can further calibrate the activity value deviation caused by uneven gene expression distribution within the gene set, so that the activity value more accurately reflects the true functional state of the gene set.
[0092] The above steps quantify the dispersion of gene expression values within the gene set by calculating the standard deviation σ, and then calculate the coefficient of variation (cv) by combining the baseline activity value μ and the minimum value ε. This eliminates the influence of numerical magnitude on the dispersion judgment and avoids the calculation anomaly when μ is zero. Inputting cv into the cv_factor obtained by the sigmoid function maps the dispersion to a gain factor in the 0-1 interval, avoiding excessive interference of extreme dispersion values on the activity value. Finally, the baseline activity value is optimized based on cv_factor, which solves the problem that relying solely on the baseline activity value can easily ignore the uneven expression distribution. This provides more accurate functional feature input for subsequent construction of single-cell gene set activity matrix and training of multimodal deep learning networks for cells, helping to improve the reliability and biological interpretability of cell subtype identification.
[0093] In some embodiments, the initial cellular multimodal deep learning network further includes a dual-branch fusion module. The step of inputting the training dataset into the classifier and reconstruction module of the initial cellular multimodal deep learning network to obtain cell prediction classification results and a single-cell gene set reconstruction activity matrix includes:
[0094] The training dataset is input into the initial cellular multimodal deep learning network, and the cell fusion embedding vector is generated via the dual-branch fusion module.
[0095] The cell fusion embedding vector is input into the classifier and the reconstruction module respectively to obtain the cell prediction classification result and the single-cell gene set reconstruction activity matrix.
[0096] Specifically, after the training dataset enters the network, it is first fed into a dual-branch fusion module. This module processes the data through two independent and collaborative encoding branches. One branch generates gene weights based on pre-training prior gene feature data, dynamically weights the single-cell calibration gene expression data, and encodes it into a gene-dimensional feature vector. The other branch extracts and encodes the functional activity information in the single-cell gene set activity matrix, generating an activity-dimensional feature vector. Subsequently, the module concatenates, compresses dimensions, and performs feature interaction processing on the feature vectors output by the two branches, ultimately generating a cell fusion embedding vector that combines gene expression details and functional activity information. Next, the network routes the generated cell fusion embedding vector to the classifier and reconstruction module respectively: after receiving the cell fusion embedding vector, the classifier performs probability prediction on the subtype category of the cell and outputs the cell prediction classification result containing the probability distribution of each cell category; the reconstruction module, based on the cell fusion embedding vector, reverses the features of the single-cell gene set activity matrix through the decoding layer to restore the activity information at the gene set level, and finally outputs a single-cell gene set reconstructed activity matrix with the same dimensions as the original single-cell gene set activity matrix, completing the forward propagation process of the training data in the network.
[0097] In the above steps, the dual-branch fusion module can specifically process gene expression data and functional activity data. By encoding and fusing the data separately through two branches, it generates a cell fusion embedding vector that combines gene-level details and functional-level information, solving the problem of one-sided single-source feature information. Subsequently, this vector is input into the classifier and the reconstruction module respectively. The classifier can accurately predict the cell type based on the comprehensive features after fusion, improving the accuracy of cell subtype identification. The reconstruction module can reversely verify the degree to which the fusion features retain gene set activity information, ensuring that the fusion vector does not lose key functional features. This lays a key foundation for subsequent optimization of the network through loss functions and improvement of the final single-cell recognition effect.
[0098] In some embodiments, the step of inputting the training dataset into an initial cellular multimodal deep learning network and generating a cell fusion embedding vector via the dual-branch fusion module includes:
[0099] The single-cell corrected gene expression data and the pre-trained prior gene feature data are input into the first coding branch of the dual-branch fusion module to generate gene coding vectors.
[0100] The single-cell gene set activity matrix is input into the second coding branch of the dual-branch fusion module to generate a gene set activity coding vector.
[0101] The cell fusion embedding vector is generated based on the gene encoding vector and the gene set activity encoding vector.
[0102] Specifically, firstly, for the first encoding branch of the dual-branch fusion module, single-cell corrected gene expression data and pre-training prior gene feature data from the training dataset are input together. This branch first maps the pre-training prior gene features into a weight vector that matches the dimension of the single-cell corrected gene expression data, dynamically weights the corrected gene expression data to highlight high-value gene signals and suppress noise interference, and then multiplies the weight vector with the single-cell corrected gene expression data element-wise to obtain a weighted gene expression vector. Finally, the weighted gene expression vector is mapped to a fixed-dimensional gene encoding vector. Secondly, the single-cell gene set activity matrix from the training dataset is input into the second encoding branch of the dual-branch fusion module to generate a gene set activity encoding vector that reflects the activation state of cell functional modules. Finally, feature fusion processing is performed on the gene encoding vector and the gene set activity encoding vector. An attention mechanism is used to assign weights to the key features of the two vectors, followed by concatenation and feature compression layer integration to finally generate a cell fusion embedding vector that combines gene expression details and functional activity information.
[0103] Through the above steps, multi-dimensional features of single cells are accurately integrated, solving the problem of one-sided information from single-source data. The first encoding branch combines single-cell corrected gene expression data with pre-training prior gene features, dynamically weighting and highlighting high-value gene signals, and the generated gene encoding vector retains gene expression details. The second encoding branch processes the single-cell gene set activity matrix, mining functional association features, and the generated gene set activity encoding vector reflects the cell's functional state. The cell fusion embedding vector generated by the fusion of the two branches contains both gene-level details and functional-level information, laying the foundation for the subsequent classifier to accurately predict cell categories and the reconstruction module to reliably restore gene set activity, effectively improving the network's ability to represent cell features and helping to improve the final single-cell recognition accuracy.
[0104] In some embodiments, the process of generating the cell fusion embedding vector based on the gene coding vector and the gene set activity coding vector includes a step of splicing and linear projection.
[0105] Specifically, when generating cell fusion embedding vectors based on gene encoding vectors and gene set activity encoding vectors, the two are first concatenated along the feature dimension to form a high-dimensional vector containing gene expression details and functional activity information; then the vector is input into a linear projection layer, and linear transformation and dimensionality compression are performed using a learnable weight matrix, and batch normalization is used to eliminate feature distribution differences to obtain a cell fusion embedding vector adapted to subsequent modules.
[0106] Through the above steps, the key features of the dual vectors are fully preserved, avoiding the one-sidedness of single features; linear projection efficiently integrates features and optimizes dimensions, reducing the complexity of subsequent calculations; batch normalization reduces redundancy and distribution shift, making the fused vector have both strong representational ability and adaptability, providing high-quality input for cell classification and reconstruction.
[0107] In some embodiments, the first coding branch includes a gene weight generation module, an expression relabeling module, and a gene coding module, wherein:
[0108] The gene weight generation module is used to map the pre-trained prior gene feature data into a 0-1 weight vector of the same length as the number of input genes.
[0109] The expression relabeling module is used to multiply the weight vector element-wise with the single-cell corrected gene expression data to obtain a weighted gene expression vector.
[0110] The gene coding module is used to map the weighted gene expression vector into a fixed-dimensional gene coding vector.
[0111] Through the above embodiments, the first coding branch generates a 0-1 gene weight vector through the gene weight generation module, achieves weighted optimization through the expression relabeling module, and outputs a fixed-dimensional vector through the gene coding module. This synergistic effect accurately filters effective information in single-cell correction gene expression data, suppresses noise, and generates a gene coding vector that is both reliable and adaptable, providing high-quality gene dimension feature input for subsequent dual-branch fusion.
[0112] In some embodiments, the gene weight generation module includes a first linear transformation layer, a first normalization layer, a first activation layer, a first discard layer, a second linear transformation layer, and a sigmoid activation layer.
[0113] In the above embodiments, the module uses layered processing to accurately convert the pre-training prior gene features into a weight vector of equal length to the number of input genes. This not only highlights high-value gene signals and suppresses noise, but also avoids overfitting by discarding layers and stabilizes training by normalizing layers, providing a reliable basis for gene weights for the subsequent expression relabeling module.
[0114] In some embodiments, the expression remarking module is composed of an element-wise multiplier.
[0115] In the above embodiments, the expression relabeling module uses an element-wise multiplier to multiply the 0-1 weight vector output by the gene weight generation module with the single-cell corrected gene expression data element-wise, thereby enhancing the expression signal of high-weight genes and suppressing the interference of low-weight genes, efficiently generating a weighted gene expression vector that highlights effective information, and providing optimized gene expression data for the subsequent gene coding module.
[0116] In some embodiments, the gene encoding module includes a third linear transformation layer, a first normalization layer, a second activation layer, a second discard layer, a fourth linear transformation layer, a second normalization layer, and a third activation layer.
[0117] In the above embodiments, the gene encoding module accurately maps the weighted gene expression vector into a fixed-dimensional gene encoding vector through multi-level collaborative processing, which not only preserves effective gene features but also improves the generalization and adaptability of the vector, providing high-quality gene dimension features for dual-branch fusion.
[0118] In some embodiments, the second coding branch includes a gene set activity input module and a linear mapping module, wherein:
[0119] The gene set activity input module is used to receive the single-cell gene set activity matrix;
[0120] The linear mapping module is used to map the gene set activity vector to the activity coding vector.
[0121] In the above embodiments, the second encoding branch accurately receives the single-cell gene set activity matrix through the gene set activity input module and converts the gene set activity vector into an activity encoding vector through the linear mapping module. This efficiently completes the reception and encoding of activity features at the cellular functional level, generating an activity encoding vector that reflects the functional state of the gene set, and providing reliable functional dimension feature input for subsequent dual-branch fusion.
[0122] In some embodiments, the linear mapping module includes a fifth linear transformation layer, a second batch normalization layer, and a fourth activation layer.
[0123] In the above embodiments, the linear mapping module accurately maps the gene set activity vector to the activity coding vector, which not only preserves the functional activity characteristics of the gene set, but also improves the vector adaptability, providing high-quality functional dimension features for subsequent dual-branch fusion.
[0124] In some embodiments, the single-cell corrected gene expression data is one of the following:
[0125] 1) The results of the standardized processing of the original gene expression data of the single cells;
[0126] 2) The results of the single-cell original gene expression data after standardization and logarithmic transformation;
[0127] 3) The results of the single-cell original gene expression data after standardization, logarithmic transformation, and numerical correction;
[0128] 4) The results of the single-cell original gene expression data after standardization, logarithmic transformation and numerical interpolation.
[0129] Specifically, the generation method of single-cell corrected gene expression data is based on the differences in the preprocessing procedures of the original single-cell gene expression data, and presents one of the following four forms: The first is the result after performing standardization processing only on the original single-cell gene expression data. By eliminating the differences in the magnitude of different gene expression values, the data is placed in a uniform and comparable range, meeting the input requirements of the basic model. The second is the result after performing logarithmic transformation (commonly log1p transformation) on the basis of standardization processing. This operation can transform the skewed distribution of the original data into a form that is closer to the normal distribution, reducing the interference of extreme values on subsequent analysis. The third is the result after adding a numerical correction step (i.e., after scVI deep feature extraction, batch effect correction is completed to obtain low-dimensional embedding) on the basis of standardization processing and logarithmic transformation. The fourth is the result after adding a numerical imputation step after standardization processing and logarithmic transformation. To address the common missing value problem in single-cell gene expression data, mean imputation, K-nearest neighbor imputation, or matrix completion algorithms are used to fill in the missing values, ensuring data integrity and providing high-quality input for the feature extraction of the subsequent first coding branch.
[0130] In some embodiments, generating cell supervision tags based on the single-cell corrected gene expression data includes:
[0131] Based on the single-cell corrected gene expression data, a neighbor matrix is constructed, and the neighbor matrix is clustered to generate the cell supervision label.
[0132] Specifically, the similarity between cells is first calculated based on the data to construct a neighbor matrix with cells as nodes and similarity as weights; then, a clustering algorithm (such as Leiden clustering) is used to cluster the neighbor matrix, grouping cells with similar expression patterns into one class, with each class corresponding to a cell supervision label.
[0133] The above steps capture inter-cell relationships using a neighbor matrix and combine clustering to mine common cell expression patterns. The generated supervision labels can accurately reflect cell subtype differences, providing reliable supervision signals for subsequent training of multimodal deep learning networks and helping to improve cell classification accuracy.
[0134] The complete usage process is explained in detail below using a "small demo dataset":
[0135] 1. Instantiate the pipeline.
[0136] Input: 3 file paths (as shown in Table 1) + config object;
[0137] Output: At this point, h5ad is not loaded; only the gene → module dictionary and the 512-D vector dictionary are read into memory.
[0138] Table 1 Input Files
[0139]
[0140] 2. Generate cell tags (scVI+Leiden), as shown in Table 2.
[0141] Table 2 Internal call chain and input / output of the cell tag generation process.
[0142]
[0143] 3. Train EnhancedBioNet, as shown in Table 3.
[0144] Table 3 Internal call chain and input / output of the model training process
[0145]
[0146] 4. Extract cell embeddings (inference), as shown in Table 4.
[0147] Table 4. Internal call chain and input / output of the cell embedding process.
[0148]
[0149] 5. Save the final results, as shown in Table 5.
[0150] Table 5 Save Files
[0151]
[0152] 6. Visualization.
[0153] Input: adata.obs["bionet_clusters"] (2000);
[0154] Output: PNG file (2000-point color scatter UMAP plot);
[0155] This embodiment includes the following functional modules:
[0156] The configuration center (DefaultConfig) is used to centrally store all adjustable hyperparameters, paths, and environment variables, avoiding "magic numbers" scattered throughout the code. It also automatically detects hardware (CUDA → MPS → CPU) and sets the thread count to prevent multi-threaded crashes on macOS / Win. It outputs a config object with over 20 fields, including embedding_dim=512, lr=1e-4, umap_n_neighbors=15, and k_folds=5. Highlights: It uses @property to delay device type calculation, ensuring PyTorch is not triggered during instantiation; and it centralizes environment variable settings, benefiting all subsequent NumPy / PyTorch operations.
[0157] The data lazy loader (adata property) is used to postpone reading large h5ad operations until they are actually needed, reducing memory spikes, reading only once and reusing all subsequent reads, thus avoiding redundant I / O.
[0158] The preprocessing module (preprocess_data) is used for quality filtering, normalization, log1p, preserving the raw counts layer, and automatically completing missing batch columns to prevent downstream scVI errors. Highlight: Idempotent design; multiple calls will not result in repeated normalization.
[0159] The gene-module aligner is used to find the intersection of "single-cell var_names" and "SYMBOL in the module file" to ensure that the dimensions of the subsequent matrix are consistent. It is also used to establish a bidirectional mapping: gene→list[module] and module→index.
[0160] The 512-D gene feature loader is used to read pre-trained gene vectors (such as scGPT and Gene2Vec) into memory and align them with the gene names. It is also used to pad missing gene vectors with zeros to ensure that the dimensions are fixed.
[0161] The scVI automatic trainer (generate_cell_labels) is used to automatically calculate latent dimensions and train scVI to perform batch effect correction, obtaining low-dimensional embeddings. It also uses a resolution grid and Silhouette sampling to search for the optimal Leiden resolution, avoiding arbitrary human intervention. Highlights: It directly uses 30 dimensions for samples under 2000 cells, increasing the dimension only for larger samples to prevent overfitting; during resolution search, it first samples 10% of the cells, increasing speed tenfold.
[0162] The adjacency matrix pre-computation module (leiden_clustering) is used to construct a sparse KNN graph in one go based on scVI embedding using NearestNeighbors + scipy.sparse.lil_matrix, which can be called by Leiden multiple times to avoid recalculating the distance every time the resolution changes.
[0163] The dataset builder (EnhancedSCNDataset) is used to package gene expression, module activity, 512-D gene features, and cell tags into a single sample for DataLoader iteration; it is also used for module activity calculation: the raw count of single cells is accumulated according to the gene → module many-to-many relationship to obtain a cell × module matrix; and it is also used for gene feature weighting: the normalized expression values of cells are used to perform a weighted average of the 512-D vector to generate cell-level regulatory characterization.
[0164] The model skeleton (EnhancedBioNet) includes dual-tower encoding: gene expression tower + module activity tower → fusion embedding; gene feature recalibrator: dynamically generating 01 weights using 512-D vectors to perform attention-based reweighting on input genes; multi-task head: classification branch (cross-entropy) + reconstruction branch (MSE restores module activity); decoder includes DualPathAttention: self-attention + cross-attention, improving reconstruction accuracy.
[0165] The training controller (EnhancedTrainer) is used for k-fold cross-validation + early checkpointing (storing .pt files every 5 epochs); it is also used for automatic training continuation: find_latest_checkpoint() parses the filename and returns to the broken fold / epoch; it is also used for multi-task loss: loss = α × CE + (1 - α) × MSE, where α is adjustable in the config.
[0166] The embedding inference (infer_cell_embeddings) is used to set the trained model as eval, pass the entire dataset forward once, and extract fused_emb as cell embeddings; it is also used to perform Leiden clustering again based on the new embeddings to obtain the BioNet version of the cluster; it is also used to calculate UMAP and write it back to adata.obsm["X_umap_bionet"].
[0167] The results persistence module (save_results) is used to write the final h5ad, csv, model weights, and gene feature dictionary; if the file already exists, it is skipped to achieve idempotent saving; it is also used to generate multi-panel UMAP comparison plots (scVI vs BioNet vs batch); and it is also used to calculate the ARI matrix and write it to disk.
[0168] The visualization suite (plot_umap / plot_multi_umap) is used to uniformly encapsulate matplotlib logic, automatically identify discrete / continuous annotations, and automatically switch to viridis for more than 20 categories; it also supports legend truncation and long label omission to prevent graph overflow.
[0169] Among the modules above, the model skeleton (EnhancedBioNet) is the core of the model, and its specific structure is as follows: B = batch size; G = number of common genes (2500 in the example after alignment); M = number of modules, i.e. number of gene sets (378 in the example); E = embedding_dim = 512 (given by the configuration); H = hidden_dim = 1024 (given by the configuration).
[0170] The gene feature recalibrator (gene_feat_recalibrator), also known as the gene weight generation module, is used to dynamically generate the weight of each gene for the current data from pre-trained 512-D gene vectors. This achieves data-dependent Attention reweighting, and the output means that each gene in each cell receives a calibration coefficient w_g between 0 and 1. Table 6 shows the calculation process of the gene feature recalibrator.
[0171] Table 6. Calculation flow of the gene feature recalibrator
[0172]
[0173] Gene expression reweighting (extraproduct, no parameters), also known as expression relabeling module, is used to multiply the weight vector with the single-cell corrected gene expression data element by element to obtain the weighted gene expression vector.
[0174] The gene-encoder module is used to compress the weighted high-dimensional gene expression into a 512-D latent space. Table 7 shows the calculation process of the gene-encoder module.
[0175] Table 7 Calculation Flow of Gene Coding Module
[0176]
[0177] The gene set encoding module (module_encoder), also known as the second encoding branch, is used to compress the module activity vector to 512-D, symmetrical to the gene tower. Table 8 shows the computation flow of the gene set encoding module.
[0178] Table 8 Calculation Flow of Gene Set Encoding Module
[0179]
[0180] The feature fusion layer is used to concatenate and compress bi-branch features (gene coding and gene set coding) to obtain a unified cell representation. Table 9 shows the calculation process of the feature fusion layer.
[0181] Table 9 Feature Fusion Layer Calculation Flow
[0182]
[0183] The classifier takes fused_emb(B, E) as input and outputs logits(B, n_classes) after being processed by nn.Linear(E, n_classes).
[0184] The decoder (DecoderBlock) is used to reconstruct module activity using fused embeddings to achieve self-supervised signals; at the same time, dual attention is introduced to improve accuracy.
[0185] Gated residual blocks are used to enhance feature representation, prevent overfitting, stabilize training, and improve model performance through linear transformation, GELU activation, gating mechanism, Dropout regularization, residual connections, and layer normalization.
[0186] DualPathAttention is used to first linearly project module_input(B,M), i.e., the single-cell gene set activity matrix, onto (B,E), then perform MHA, output (B,E), and add it to the residual of the self result.
[0187] The output projection transforms the input data of shape (B, E) into an output gene activity matrix of shape (B, M) with a range of (0,1) through the nn.Linear(E,M) linear transformation and the Sigmoid activation function.
[0188] Finally, the shape flow is summarized as follows: 1) Cells first enter the model with their G-dimensional gene expression and 512-dimensional pre-trained gene vectors; the model uses the gene vectors to generate G 0-1 weights, and re-weights the gene expression based on data dependence; 2) The weighted gene expression (still G-dimensional) is fed into the gene tower: two layers of linear + BN / LeakyReLU → compressed into a 512-dimensional gene_emb; 3) At the same time, the cell's M-dimensional module activity is fed into the module tower: one layer of linear + BN / LeakyReLU → also compressed into a 512-dimensional mod_emb; 4) The two 512-dimensional vectors are concatenated to form 1024, and then compressed through a fusion layer to obtain the final cell representation fused_emb (512-dimensional); 5) From this version of "condensed cell vectors", two branches are generated: one branch goes directly into the classification head, outputting n_classes-dimensional logits for cell type discrimination; the other branch goes into the decoder, first through gated residuals + dual-path attention, and then projected back to M-dimensional to generate module activity reconstruction recon, which is used for self-supervised loss. Throughout the process, the tensor shape gradually converges from the high-dimensional space of "gene-module (gene set)" to a 512-dimensional unified embedding, and then bifurcates to complete the two major tasks of classification and reconstruction.
[0189] Another example: using Tabula_Sapiens data, sampling it and inputting it into the model.
[0190] Tabula Sapiens is a comprehensive single-cell atlas of normal adult humans. It samples from 24 organ donors aged 22-74 years, across 28 major tissues and organs (heart, lung, liver, kidney, colon, skin, etc., both male and female), using the same experimental procedure. This yielded transcriptome data from over 1.1 million live cells, which were then manually annotated by experts, resulting in approximately 475 cell types. Because all organs originated from the same group of individuals, their genetic background, age, environment, and phenotypic state are highly comparable. Therefore, it can be used to study two key questions: "differences in the same cell type across different tissues" and "shared cell populations across different tissues." The data was sequenced using a dual-platform approach of Smart-seq2 (plate) and 10x droplet sequencing, ensuring both gene detection depth and throughput. Furthermore, it preserved complete mRNA, including unspliced copies, thus enabling the first systematic analysis of alternative splicing at a large-scale single-cell level. The project provides quality-controlled h5ad files, cell annotations, clinical metadata, and the CZ CELLxGENE portal for online browsing, which can be downloaded directly or accessed via API. TabulaSapiens 2.0, released in 2024, adds four tissues and nine donors to version 1.0 and includes specialized analyses of transcription factor expression, aging-related genes, and sex-specific characteristics. It has become a "benchmark" resource for normal human cell reference maps, widely used for cell type identification, characteristic gene discovery, disease control studies, and as a training baseline for AI cell models. The final cell embedding results obtained from the model are shown in Table 10, with 512 dimensions. Only the first five dimensions are displayed in the table, with the first column showing cell labels. Figure 3 The UMAP diagram generated based on cell embedding tags according to the embodiments of this application shows the distribution of cell data in a two-dimensional space after UMAP dimensionality reduction. Different colors can correspond to different cell categories or clusters, which can intuitively reflect the clustering characteristics and structural relationships of cell populations and help analyze cell heterogeneity and other characteristics.
[0191] Table 10 Cell embedding results
[0192]
[0193] Another example: gene vector extraction from current pre-trained large models, taking scGPT as an example.
[0194] The first step is to load the model and vocabulary. First, read `vocab.json` to obtain the mapping from gene symbols to integer numbers; this file contains both actual genes and special markers like `<gene>` and `<gene>`. Next, initialize a Transformer shell with the exact same parameters as during training: the values of `d_model`, `nhead`, and `nlayers` must be consistent with the training phase; otherwise, the weights will not match. Then, load `best_model.pt` from disk. Here, filtering is required—only keys with matching shapes are retained to prevent errors caused by redundant heads or optimizer states from old checkpoints. After loading, immediately set the model to eval mode, disable Dropout and BatchNorm statistical updates to ensure that the subsequently extracted vectors are stable and reproducible. Finally, to facilitate the removal of special markers later, create a reverse mapping `id_to_gene` to convert the integer numbers back to gene symbols.
[0195] The second step is to extract the "pure gene vectors". The gene embedding layer weights have a shape of vocab_size × 512, with each row being a vector of tokens. The script first lists a hard-coded list of special markers, then classifies tokens enclosed in angle brackets as special markers as well, and removes all their corresponding row numbers. The remaining row numbers are recorded as valid_ids, which are used to slice the embedding weights, resulting in an ndarray containing only real genes, with a shape of N_genes × 512. Simultaneously, a gene-to-vector dictionary is created, mapping gene names to vectors for easy retrieval by name later. This step also prints how many special markers were removed.
[0196] The third step is to calculate the cosine similarity. To see the most similar neighbors of a gene (default TP53), first convert the gene name back to its original vocab number, then check its position in valid_ids. If the input is a special marker, or the gene is not in the vocabulary, it will automatically fall back to the first valid gene to avoid program crashes. Next, only the "1-to-N" cosine similarity is calculated, instead of the entire N×N list, which is both faster and saves memory. After obtaining the similarity array, the top K highest scores (excluding the gene itself) are taken, and the corresponding gene name and score are returned together. A leaderboard is then printed in the terminal.
[0197] The fourth step is to save the results. The script simultaneously writes the results in two formats in the output directory: an npy binary file that maintains floating-point precision, suitable for subsequent loading by Python; and a csv expanded table with one gene per row and 512 columns, easy to open and view in Excel. If a similarity query has been run previously, an additional top_similarities.csv file will be created, containing only the gene and similarity columns, which can be directly used for downstream analysis. The directory will be automatically created if it does not exist. The entire saving process is idempotent, and repeated runs will not result in errors.
[0198] The technical solution also includes three layers of exception handling: if a file is missing, it will indicate which one is missing; if the JSON format is incorrect, it will prompt you to check the vocabulary; any other exceptions will print the complete stack information and indicate whether the model and vocabulary were successfully loaded, making it easier for users to locate the problem. In this way, whether you want to extract vectors immediately after training or reproduce the problem after several months on a different server, you can run a single command and obtain a clean, directly reusable gene vector library. The extracted gene vectors are shown in Table 11, with 512 dimensions. Only the first 5 dimensions are shown in the table, and the first column is the gene name.
[0199] Table 11 Gene Vectors
[0200]
[0201] In addition, in conjunction with the single-cell identification method in the above embodiments, this application embodiment can provide a storage medium for implementation. The storage medium stores a computer program; when executed by a processor, the computer program implements any of the single-cell identification methods in the above embodiments.
[0202] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0203] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0204] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0205] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A single-cell identification method, characterized in that, include: Acquire raw gene expression data of single cells, gene tag comparison table, and pre-training prior gene feature data; Based on the raw gene expression data of the single cells, at least after standardization, single-cell corrected gene expression data is obtained; based on the single-cell corrected gene expression data, cell supervision tags are generated. Based on the gene expression matrix obtained directly or after further processing of one of the single-cell raw gene expression data and the single-cell corrected gene expression data, and with the gene tag comparison table, a single-cell gene set activity matrix is constructed. Based on the single-cell gene set activity matrix, the cell supervision label, the pre-training prior gene feature data, and the single-cell corrected gene expression data, a training dataset is generated, and the training dataset is input into the classifier and reconstruction module of the initial cell multimodal deep learning network to obtain cell prediction classification results and single-cell gene set reconstruction activity matrix; The label loss is obtained based on the difference between the cell prediction classification result and the cell supervision label. The reconstruction loss is obtained based on the difference between the single-cell gene set reconstruction activity matrix and the single-cell gene set activity matrix. The label loss and the reconstruction loss are weighted and merged to calculate the total loss result. The gradient of the total loss result is backpropagated to the initial cell multimodal deep learning network for iterative training. The training is terminated based on the total loss result and a cell multimodal deep learning network is generated. Single-cell corrected gene expression data are input into the cell multimodal deep learning network to infer cell fusion embedding results; Based on the cell fusion embedding results, single-cell recognition results are obtained.
2. The single-cell identification method according to claim 1, characterized in that, The single-cell raw gene expression data includes an integer value matrix between single cells and genes; the single-cell corrected gene expression data includes a floating-point value matrix between single cells and genes; the gene tag lookup table includes the correspondence between gene sets and genes; the step of constructing a single-cell gene set activity matrix based on the gene expression matrix obtained directly or after further processing of one of the single-cell raw gene expression data and the single-cell corrected gene expression data, and the gene tag lookup table, includes: For each single cell in the original gene expression data or the corrected gene expression data, the values of each gene in the gene expression matrix are combined and calculated using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set, thereby obtaining the relationship between the cell and the gene set and forming the single cell gene set activity matrix.
3. The single-cell identification method according to claim 2, characterized in that, The step involves merging and calculating the activity values of each gene in the gene expression matrix, using the gene sets in the gene tag lookup table as the dimension, to obtain the activity values of each gene set, including: The steps involve calculating the gene expression detection rate for each gene set, and then using the detection rate as a weight to process the combined calculation results to obtain the activity value of each gene set.
4. The single-cell identification method according to claim 3, characterized in that, The step involves merging and calculating the activity values of each gene in the gene expression matrix, using the gene sets in the gene tag lookup table as the dimension, to obtain the activity values of each gene set, including: For each gene set, the values of each gene in the gene expression matrix are first summed, then averaged according to the number of genes contained in the gene set, and then the average value is multiplied by the detection rate to obtain the basic activity value, thereby obtaining the activity value of each gene set based on the basic activity value.
5. The single-cell identification method according to claim 4, characterized in that, The step of merging and calculating the values of each gene in the gene expression matrix using the gene set in the gene tag lookup table as the dimension to obtain the activity value of each gene set, further includes the step of obtaining the activity value of each gene set based on the basic activity value and through dispersion gain, which is specifically implemented by the following method: ; ; ; Where, n i Let μ be the base activity value of each gene in the matrix, N be the number of genes in the gene set, σ be the standard deviation, cv be the coefficient of variation, ε be a minimum value to avoid cv being uncalcifiable when μ is zero, sigmoid be the activation function based on cv value, and cv_factor be the dispersion gain. Then, the activity value of each gene set is obtained based on the cv_factor.
6. The single-cell identification method according to claim 1, characterized in that, The initial cellular multimodal deep learning network further includes a dual-branch fusion module. The step of inputting the training dataset into the classifier and reconstruction module of the initial cellular multimodal deep learning network to obtain cell prediction classification results and a single-cell gene set reconstruction activity matrix includes: The training dataset is input into the initial cellular multimodal deep learning network, and the cell fusion embedding vector is generated via the dual-branch fusion module. The cell fusion embedding vector is input into the classifier and the reconstruction module respectively to obtain the cell prediction classification result and the single-cell gene set reconstruction activity matrix.
7. The single-cell identification method according to claim 6, characterized in that, The step of inputting the training dataset into the initial cellular multimodal deep learning network and generating cellular fusion embedding vectors via the dual-branch fusion module includes: The single-cell corrected gene expression data and the pre-trained prior gene feature data are input into the first coding branch of the dual-branch fusion module to generate gene coding vectors. The single-cell gene set activity matrix is input into the second coding branch of the dual-branch fusion module to generate a gene set activity coding vector. The cell fusion embedding vector is generated based on the gene encoding vector and the gene set activity encoding vector.
8. The single-cell identification method according to claim 7, characterized in that, The process of generating the cell fusion embedding vector based on the gene encoding vector and the gene set activity encoding vector includes the step of linear projection after splicing.
9. The single-cell identification method according to claim 7, characterized in that, The first coding branch includes a gene weight generation module, an expression relabeling module, and a gene coding module, wherein: The gene weight generation module is used to map the pre-trained prior gene feature data into a 0-1 weight vector of the same length as the number of input genes. The expression relabeling module is used to multiply the weight vector element-wise with the single-cell corrected gene expression data to obtain a weighted gene expression vector. The gene coding module is used to map the weighted gene expression vector into a fixed-dimensional gene coding vector.
10. The single-cell identification method according to claim 9, characterized in that, The expression remarking module is composed of element-wise multipliers.
11. The single-cell identification method according to claim 7, characterized in that, The second coding branch includes a gene set activity input module and a linear mapping module, wherein: The gene set activity input module is used to receive the single-cell gene set activity matrix; The linear mapping module is used to map the gene set activity vector to the activity coding vector.
12. The single-cell identification method according to claim 11, characterized in that, The linear mapping module includes a fifth linear transformation layer, a second batch normalization layer, and a fourth activation layer.
13. The single-cell identification method according to claim 1, characterized in that, The single-cell corrected gene expression data is one of the following: 1) The results of the standardized processing of the original gene expression data of the single cells; 2) The results of the single-cell original gene expression data after standardization and logarithmic transformation; 3) The results of the single-cell original gene expression data after standardization, logarithmic transformation, and numerical correction; 4) The results of the single-cell original gene expression data after standardization, logarithmic transformation and numerical interpolation.
14. The single-cell identification method according to claim 1, characterized in that, The generation of cell supervision tags based on the single-cell corrected gene expression data includes: Based on the single-cell corrected gene expression data, a neighbor matrix is constructed, and the neighbor matrix is clustered to generate the cell supervision label.
15. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the single-cell identification method according to any one of claims 1 to 14 when it is run.
Citation Information
Patent Citations
Cell data annotation method, device, equipment and medium
CN115116549A
Single cell classification method, device, equipment and storage medium
CN116525006A