dataesr/scientific-paragraphs-categorization huggingface dataset:
1b ), extra-telencephalic projecting neurons (L5 ET), near-projecting neurons (L5/6 NP), corticothalamic projection neurons (L6 CT) and layer 6b neurons (L6b) (Fig. 2h ). It should be noted that the number of cell types, the number of measured genes, relative abundance of cells in various cell types and the gene dropout rate differ in the snRNA-seq 10x v3 B dataset and the MOP ST dataset. For example, smooth muscle cells (SMC) and Sncg cells are depleted in the snRNA-seq 10x v3 B dataset, while Sncg cells are depleted in the MOP ST dataset. Besides, L6 IT Car3 and L4/5 IT are not provided in the snRNA-seq 10x v3 B dataset, thus these cell types are not considered in direct comparisons. Compared with the control methods, Spatial-ID could effectively identify the cell types (Fig. 2c )and achieve better performance (Fig.
2f ). On all 12 MERFISH SRT samples, Spatial-ID achieves the highest mean accuracy 92. 75% (Fig. 2f ), and the differences with the control methods are very significant (Wilcoxon test p-value<<0. 001 for all other methods). Besides, Spatial-ID achieves the highest mean weighted F1 score 0. 9209 (Extend Fig. 2a ), where weighted F1 score of each sample is calculated by weighted averaging the F1 score of each cell type, in order to mitigate the effects of cell type imbalance. In addition, Cell-ID achieves mean accuracy 17. 08% and mean weighted F1 score 0. 1521 that is far below other methods and is therefore not shown in Fig. 2f  and Extend Fig. 2a. From this, each cell in MOP SRT dataset have both a predicted cell type from the snRNA-seq 10x v3 B dataset and a MERFISH ground truth label. Cells in MOP SRT dataset are grouped based on their MERFISH ground truth labels, and then the fraction of predicted cell type for each group is determined (Fig.
2g  and Extend Fig. 2d ). Except the smooth muscle cells (SMC) and Sncg cells, Spatial-ID achieves outstanding recall rates on other cell types. The depleted SMC and Sncg cell types in the snRNA-seq 10x v3 B dataset lead to weaker identification ability of models on these cell types, because there are no sufficient samples to train models. Moreover, the integration of spatial information enables Spatial-ID to reveal that neuronal cells have specific spatial organization pattern (Fig. 2e ). For the excitatory neurons, we can observe a laminar appearance for the overall cellular organization along the direction of the cortical depth, especially the IT neurons (Extend Fig. 1b ). Obviously, the L2/3 IT, L5 IT, L6 IT neurons, identified by Spatial-ID, appear as discretely laminar cell populations, and L5 ET, L5/6 NP, L6 CT and L6b neurons also appear as discrete cell populations (Fig.
2b , Extend Fig. 2c , Extend Fig. 3  and Extend Fig. 4 ), Spatial-ID also achieves high consistent of neighborhood complexity and neighborhood purity with ground truth. Different SRT technologies usually have different rates of gene capture, especially the spot-based SRT technologies. To verify the robustness of Spatial-ID in the application of SRT datasets with different gene dropout rates, we conduct simulation experiments on MOP SRT dataset by randomly discarding part of genes. Under the same configuration, Spatial-ID could achieve better performance of cell type identification than the control methods (Fig. 2j ). Especially in the low dropout rates (e. g. , less than 0. 6), the performance degradation of Spatial-ID is less than that of the top control methods (Fig. 2j  and Extend Fig. 5a ).
Specifically, on all 12 MERFISH ST samples, Spatial-ID achieves the highest mean accuracy 85. 76% at the dropout rate of 0. 5 (Fig. 2j ), and the differences with the control methods are very significant (Wilcoxon test p-value<<0. 001 for all other methods). While Spatial-ID achieves the highest mean weighted F1 score 0. 8466 at the dropout rate of 0. 5 (Extend Fig. 5b ). These results suggest that the spatial information is not only beneficial to help cell type identification, but also improve the robustness of Spatial-ID against the variation of gene dropout (Fig. 2j , Extend Fig. 5c  and Extend Fig. 5d ). Thus, Spatial-ID shows a promising perspective to transfer knowledge from available reference datasets (e. g. , scRNA-seq datasets or other SRT datasets), even if their gene dropout rates differ from that of target datasets.
L4/5 IT and L6 IT Car3 neurons are not provided in the snRNA-seq 10x v3 B dataset, thus Spatial-ID predicts the L6 IT Car3 neurons as L6 IT neurons, and L4/5 IT neurons as L2/3 IT and L5 IT neurons (Fig. 2c  and Fig. 2e ). The ground truth of MOP SRT dataset shows that L4/5 IT neurons populate in the continuous region between L2/3 IT and L5 IT neurons (Fig. 2d ), and L6 IT Car3 neurons populate near the L6 IT neurons at L6 layer (Fig. 2d ). These results suggest that the gene expression profiles of L4/5 IT neurons present gradual transition between the L2/3 IT and L5 IT neurons, and the characteristics of L6 IT Car3 neurons are similar to the L6 IT neurons (Fig. 2c ). To further distinguish these new cell types, we conduct an experiment that some cell types are presented in the MOP SRT dataset but unseen in the snRNA-seq 10x v3 B dataset.
Based on the prediction results of Spatial-ID, a pipeline of new cell type discovery (Fig. 2k ) is performed to determine whether there are new cell types in the MOP SRT dataset, including thresholding, clustering, mapping and filtering. Finally, the discovery of L4/5 IT and L6 IT Car3 neurons achieves F1 score of 0. 405 and 0. 904, respectively (Fig. 2k ).
Application to mouse hypothalamic preoptic region dataset measured by MERFISH. For 3D SRT dataset, we also perform a quantitative comparison on the mouse hypothalamic preoptic region (1. 8mm×1. 8mm×0. 6mm, Fig. 3a ) dataset  44  measured by MERFISH. This dataset measures a panel of 155 genes. We select 3 samples with naive behavior, including total 213,192 cells collected from 2 female mice and 1 male mouse (Fig. 3b ). Each sample (Bregma 0. 26 to -0. 29) contains 12 slices with 50um interval. The reference scRNA-seq dataset (GSE113576)  44  is collected from the hypothalamic preoptic region (~2. 5mm×2. 5mm×1. 1mm) across 3 replicates of an adult female mouse and a male mouse, including 31,299 cells and 27,998 genes. The delineation of major cell classes includes inhibitory neurons, excitatory neurons, microglia, astrocytes, immature oligodendrocytes, mature oligodendrocytes, ependymal cells, endothelial cells, macrophages and mural cells.
Spatial-ID achieves the highest mean accuracy 87. 74% (Fig. 3c  and Fig. 3e ) that significantly outperforms the control methods (Wilcoxon test p-value<<0. 001 for all other methods) on all 3 samples with naive behavior (Fig. 3d  and Fig. 3e ). Besides, Spatial-ID achieves the highest mean weighted F1 score 0. 8773 (Extend Fig. 7a ). These results suggest that Spatial-ID can be effectively applied on 3D SRT dataset. The cell types annotated by Spatial-ID (Fig. 3f ) show better correspondence to ground truth than those annotated by control methods. Specifically, in the 2D views (Extend Fig. 6a  and Extend Fig. 6b ), the annotation results of Spatial-ID show more obvious advantage than other control methods.
Application to mouse spermatogenesis dataset measured by Slide-seq. Next, we perform a quantitative comparison on the mouse spermatogenesis dataset  45  (Fig. 4a ) measured by Slide-seq. The mouse spermatogenesis SRT dataset is acquired from three leptin-deficient diabetic (ob/ob) mice and three wild-type (WT) mice, including 207,335 cells in total and 24,105 genes in common. All cells are divided into 9 testicular cell types 69 : elongating/elongated spermatid (ES), round spermatid(RS), spermatocyte(SPC), spermatogonium(SPG), Endothelial, Sertoli, Leydig, Myoid and Macrophages (Fig. 4a ). Testicular cell types are organized in a spatially segregated fashion at the level of seminiferous tubules. By comparison in previous study  45  , diabetic induces testicular injuries through disrupting the spatial structures of seminiferous tubules and changing the expression pattern of many genes at molecular level (Fig.
4e ). The reference scRNA-seq dataset (GSE112393)  48  includes 34,633 cells and 37,241 genes from the adult mouse testis. The quantitative comparison on mouse spermatogenesis dataset also demonstrates the superiority of Spatial-ID for cell type identification molecularly (Fig. 4c , Fig. 4d  and Fig. 4e ). On all 6 SRT samples, Spatial-ID achieves the highest mean accuracy 60. 45% (Fig. 4c ), and the differences with the control methods are very significant (Wilcoxon test p-value<<0. 001 for all other methods). These results suggest that Spatial-ID can also effectively handle the spot-based Slide-seq dataset with tens of thousands of genes, even if the area of a spot span more than one cell. Besides, Spatial-ID achieves a mean weighted F1 score 0. 55 (Extend Fig. 7b ). In this comparison, all 24,015 common genes are used in Spatial-ID and control methods.
Interestingly, Cell-ID presents outstanding performance in this SRT dataset, which achieves the highest mean weighted F1 score 0. 5727 (Extend Fig. 7b ) that indicates Cell-ID requires abundant genes for cell type annotation. SciBet) is much higher than that of correlation-based methods. The same results can be obtained for other SRT datasets (See Table  3 ). To further analyze the running efficiency of Spatial-ID on different number of cells, we crop 10 percent to 100 percent radius field views of 4 samples (other 2 samples have non-circular field views) in this SRT dataset (Fig. 4g ), respectively. Then, we statistically analyze the running efficiency of Spatial-ID on these cropped field views. As the number of cells increases, the runtime of Spatial-ID increases linearly (Fig. 4g ).
Application to large field mouse brain hemisphere dataset measured by Stereo-seq. Many currently available sequencing-based SRT technologies such as Slide-seq, DBiTseq  49   Based on the predictions of Spatial-ID, the identified cell types of 3 coronal sections present a high consistency (Fig. 5b ) that an average of 99% cells in each section are assigned to their common cell types (Extend Fig. 8e ). Besides, by color-coding our identified cell types in low dimension feature space (i. e. , UMAP), most identified cell types congregate into separable communities (Fig. 5b ). For example, DGGRC2, VLMC2, and MBDOP2 can be easily segregated because they are driven by large differences of gene expression. Some similar cell types populate in mixed communities, such as the cortical pyramidal neuron (TEGLUs).
According to the cell type taxonomy of reference dataset, 65,174 cells (50. 8%) are identified as excitatory neurons, 20,267 cells (15. 8%) are identified as inhibitory neurons, and 42,840 cells (33. 4%) are identified as non-neuronal cell types (Fig. 5c ). Specifically, most of the identified excitatory neurons are telencephalon projecting neurons with glutamatergic neurotransmitter (TEGLU) and populate in cerebral cortex and 5j), TEGLU24 (Extend Fig. 9a ) and DGGRC2 (Fig. 5k ) in hippocampus. The other excitatory neurons with glutamatergic neurotransmitter (MEGLU, HBGLU) populate in midbrain and hindbrain. The identified inhibitory neurons mainly consist of TEINH19 and MEINH8 (Fig. 5i ), where the identified TEINH19 neurons scatter across cortical layers and hippocampus CA3 region and the identified MEINH8 populate in midbrain.
By quantifying the cells among these 8 regions, we can observe that different functional regions have different combinations of the identified cell types (Fig. 5d ). For example, in the isocortex region (Fig. 5e ), the identified cortical pyramidal neurons (TEGLU7, TEGLU8, TEGLU10, TEGLU4, TEGLU3, TEGLU2, etc. ) display a layered laminar appearance along the direction of the cortical depth  52, 53, 54. Moreover, we further illustrate a continuous gradient of cells along the cortical depth from L2/3 to L6 in the VISp and AUD regions (Fig. 5e ). The cell type compositions of the VISp and AUD regions have significant differences, where fewer TEGLU3 and TEGLU8 populate in the AUD region than the VISp region (Fig. 5e ). For the mainly identified cell types, we further analyze the gene expression specificity of typical marker genes provided by the reference dataset  51  (Fig.
Discussion In this work, we propose Spatial-ID to perform cell type annotation for SRT datasets molecularly. We first conduct a series of comparisons on 3 public available SRT datasets with different characteristics (See Table  1 ). By comparing the accuracy and weighted F1 score calculated from predictions and ground truth, the proposed Spatial-ID demonstrates superior performance than the state-of-the-art methods (See Table  2 ) on two FISH-based SRT datasets with hundreds of genes measured by MERFISH technology and a spotbased SRT dataset with tens of thousands of genes measured by Slide-seq technology. Specifically, the better performance of Spatial-ID on the 3D FISH-based SRT dataset (i. e. , mouse hypothalamic preoptic region) further confirms that Spatial-ID can be effectively applied to 3D SRT dataset.
Moreover, the comparisons on the randomly gene dropout simulations of the FISH-based SRT dataset (i. e. , mouse primary motor cortex) additionally demonstrates the better robustness of Spatial-ID against the variation of gene dropout. Besides, the extended experiment of new cell type discovery shows the adaptability of Spatial-ID in the situation of transfer learning from an incomplete reference dataset. These results suggest that embedding spatial information can not only improve the accuracy of cell type identification substantially, but also improve the robustness against the variation of sequencing technologies, such as different gene dropout rates, different number of measured genes. In addition, the running efficiency of Spatial-ID on all SRT datasets (See Table  3 ) is much higher than that of correlation-based methods (i.
Scmap and Cell-ID). As the application of Spatial-ID on the large field mouse brain hemisphere dataset measured by Stereo-seq technology, we investigate the spatial organization of identified cell types that show high consistency with previous studies at spatial anatomical structure level, such as Allen Brain Atlas. By analyzing the gene expression specificity of typical marker genes reported in reference dataset, i. e. , the single-cell mouse brain atlas of cell types from the Linnarsson Lab 51 , most of these pre-defined marker genes have the highest expression in their corresponding cell types. Besides, by mapping the identified cell types with identified spatial gene patterns, the significant GO terms of the spatial gene patterns further reveal the functions and underlying biological processes of the identified cell types in mouse brain.
Therefore, Spatial-ID shows a promising perspective to build a large-field spatial transcriptomic brain atlas. In principle, the proposed Spatial-ID is a reference-based supervised cell typing method, therefore Spatial-ID is influenced by the characteristics of the reference datasets such as cell number, cell heterogeneity, the gene set used as features. For example, the depleted cell types in reference dataset lead to insufficient knowledge transfer of Spatial-ID, that may present weaker identification ability on these cell types. Besides, the Spatial-ID is influenced by the hyperparameters of constructing graph network such as the number of nearest cells and coefficient of inverse distance weight, that also indicates the intensity of spatial information used. The excessive use of spatial information may lead to reduce differences between local cells.
Therefore, we anticipate that the more spatial information used enables the Spatial-ID to enhance the identification of locally enriched cell types and inhibit the identification of rare cell type. In addition, the Spatial-ID demonstrates well robustness against the variation of gene dropout, but it is inevitably influenced by the high dimensionality and biological noise associated with SRT sequencing technologies. Beside optimizing the data preprocessing, integrating the SRT datasets with scRNA-seq datasets, that have been determined with rich mRNA transcripts, or other modalities, such as microscopy data and proteomics data, is potential to mitigate the sequencing noise.
Overview of Datasets. Our proposed Spatial-ID was performed on different SRT datasets generated by MERFISH, Slide-seq, Stereo-seq SRT technologies. For each group of applications, we also collected reference scRNA-seq datasets. Except the self-collected large field mouse brain hemisphere dataset measured by Stereo-seq, all other SRT datasets and reference scRNA-seq datasets are publicly available, as shown in Table  1. Notably, the mouse hypothalamic preoptic region dataset measured by MERFISH and the self-collected mouse brain hemisphere measured by Stereo-seq are 3D SRT datasets. In addition, the field size of the self-collected mouse brain hemisphere is much larger than other public datasets.
Data collection of large field mouse brain hemisphere. The large field mouse brain hemisphere dataset was measured by Stereo-seq  17  (Fig. 5a ) Briefly, three adjacent coronal sections (10μm thick, without intervals) along the anteriorposterior axis (Bregma -3. 56 to -3. 66) were cut from the brain of a 5-week-old C57BL/6J male mouse (Fig. 5a ). First, these sections were adhered to the DNA nanoball (DNB, i. 8a ). To recall the genes from the cytoplasm surrounding the nucleus, a Gaussian mixture model was employed to adjust the cell boundaries. Thus, a single cellbased gene expression matrix was generated for each section by aggregating the spots included in each cell (Extend Fig. 8a ). To facilitate the analysis of anatomical function of mouse brain, these 3 sections were aligned to the three-dimensional (3D) standard Allen Brain Atlas (Extend Fig.
8b ) by Wholebrain (https://github. com/tractatus/wholebrain). QC and Gaussian smoothing for large field mouse brain hemisphere. The 3 adjacent coronal sections captured 53,310 cells, 61,910 cells and 61,857 cells, respectively. Pearson coefficient was used to evaluate the consistency between them (Extend Fig. 8c ). Low-quality cells and genes were discarded according to the following quality control (QC) criteria: 1) cells with total counts lower than 300 and higher than 98% quantile, 2) cells with percentage of mitochondrial genes larger than 10%, 3) genes presented in less than 10 cells. Thus, 41,766 cells, 48,721 cells, 50,329 cells were remained for the 3 adjacent coronal sections (~434 genes per cell), respectively. Next, a Gaussian smoothing strategy was introduced to alleviate the noise and gene dropout associated with the Stereo-seq technology (Extend Fig.
Deep neural networks for transfer learning. The transfer learning strategy of Spatial-ID employs reference scRNA-seq datasets to train the deep neural network (DNN) model (Fig. 1a ) that is used to generate the probability distribution of each cell in SRT data. It should be noted that the DNN model only take the gene expression profile as input, whereas the available spatial information of SRT data is not used. The DNN provides nonlinear dimensionality reduction for the input gene expression matrix, that consists of 4 stacked fully connected layers, as well as a GELU layer (nonlinear activation function) and a dropout layer followed by each fully connected layer in sequence. Moreover, to alleviate the class imbalance of cell types, the loss function of Focal Loss is employed in DNN models training.
To perform transfer learning, the gene sets of reference scRNA-seq dataset and SRT dataset should be matched. We first compare the measured genes to find the common gene set. If the reference scRNA-seq datasets or SRT datasets provide marker genes of cell types, we further select the subset of marker genes from the common gene set. This process can simplify the implementation of transfer learning. Then, the raw counts of selected genes from reference scRNA-seq dataset and SRT dataset are normalized to unit length vector for each cell. If there is no marker gene available (e. g. , mouse spermatogenesis), we additionally perform a stage of 1 operation to raw counts of genes before the normalization, that intends to inhibit the negative effects of very highly expressed genes.
Deep autoencoder for latent representation learning. A deep autoencoder  39  is used to learn encoded gene representation through reducing the dimension of the gene expression matrix (Fig. 1c ). If the SRT datasets contains tens of thousands of genes, the gene expression matrix is generated by extracting hundreds of principal components (e. g. , 200) of principal component analysis (PCA). The encoder part consists of 2 stacked fully connected layers, as well as a batch normal layer, a ELU layer (nonlinear activation function) and a dropout layer followed by each fully connected layer in sequence. The decoder part consists of one fully connected layer and same followed layers as encoder. The deep autoencoder employs the mean squared error (MSE) loss function to maximize the similarity between the input gene expression matrix and the output gene expression matrix reconstructed by decoder.
Self-supervised learning using pseudo-labels. We additionally perform a self-supervised learning strategy to train a classifier using the final latent representations and pseudo-labels. In this strategy, the DNN model is the teacher model and the classifier is the student model. Formally, the pseudo-labels = { , … , , … , } are derived from the output = { , … , , … , } of last fully connected layer of the DNN model by a modified layer = ( / ) ∑ ( / ) , where is the temperature parameter that adjusts the smoothness of distribution (Fig. 1b ), and = , if = 1. Obviously, a higher value for produces softer distribution of pseudo-labels over all classes. The softer distribution of pseudo-labels could transfers more information from the reference scRNA-seq datasets.
Simulation of different gene dropout rates. Many spot-based ST technologies usually have lower mRNA capture efficiency due to the limited number of probes. Therefore, the gene dropout rates of spot-based SRT datasets are usually higher than the state-of-the-art scRNA-seq technologies and FISH-based SRT technologies. To verify the adaptability of Spatial-ID in different gene dropout rates, we conduct simulation experiments on FISH-based mouse primary motor cortex SRT dataset (Fig. 2j ). A random-gene-discard strategy, that randomly clears part of value in gene expression matrix, is employed to generate simulated SRT datasets. Then, we compare cell type annotation of Spatial-ID and control methods on these simulated SRT datasets. New cell type discovery. The discovery of new cell populations has biologically important implication for omics analysis.
Technically, the new cell type discovery is an anomaly detection task, because the trainset does not contain the new cell types to be detected. To perform new cell type discovery, we introduce an extended postprocessing strategy for Spatial-ID that includes thresholding, clustering, mapping and filtering. For each cell, the maximum score ∈ [0,1] of predicted probability vector = { , … , , … , }, ∑ = 1 is first examined by a threshold. If the score of the cell is less than the threshold (e. g. , 0. 9 in Fig. 2k ), the cell is recognized as an unassigned cell. After a set of unassigned cells are retrieved in the SRT dataset, a clustering stage is performed to distinguish these unassigned cells into different clusters in gene expression feature space, because the new cell type should populate in a relatively isolated area.