Machine learning-assisted decoding of temporal transcriptional dynamics via fluorescent timer

Machine Learning


Overview of novel ML approaches to analyse flow cytometric tocky data

Figure 1a outlines the significant pitfalls and risks associated with manual gating, the most prevalent method in immunology for identifying cells of interest in cytometry analysis. The most widely used gating methods are rectangle, polygon and ellipse gates, all of which are arbitrarily hand-drawn and highly problematic. While these gates allow immunologists “flexible” identification of cell populations to test a hypothesis, they inherently introduce substantial arbitrariness and subjectivity, increasing variability and reducing transparency in data analysis37,38. Gates depend on predefined features of cell populations (e.g., a rectangle gate for CD25high Foxp3high), embedding various hidden and ambiguous assumptions and potential biases into the analysis. Designed to isolate populations of interest to test a hypothesis, such arbitrariness makes the analytical process prone to confirmation bias—the tendency to cherry-pick data that supports pre-existing beliefs29. These arbitrary and subjective elements undermine the transparency and rigour of data analysis, contributing to the reproducibility crisis, which is widespread in life sciences and preclinical studies39, including the research fields using flow cytometric analysis27.

Fig. 1: Research Framework and Overview of Machine Learning Methods.
figure 1

a Pitfalls and risks in manual gating are schematically presented, highlighting the major pitfalls and risks associated with manual gating, emphasising the hand-drawn nature of the methodology that introduces bias and undermines reproducibility. Unicode emojis for warning and hand symbols are included83. b Proposed research framework for Machine Learning (ML)-assisted decoding of transcriptional dynamics. This schematic outlines the comprehensive workflow employed to unravel transcriptional dynamics of Foxp3 within a functional system. It covers the experimental design, generation of independent training and test datasets, training of ML models, performance evaluation, and data-driven identification of group-specific feature cells through model behaviour analysis. The protein structure is adapted from82. c Implementation of the research framework as TockyMachineLearning, a novel machine learning suite designed for this study. Data preprocessing, performed by TockyPrep, normalises and transforms flow cytometric Timer data into standardised Timer Angle and Timer Intensity data. This pre-processed data then feeds into the TockyMachineLearning toolkit. Within this toolkit, TockyKmeansRF combines k-means clustering with Random Forest (RF) analysis, utilising the mean decrease Gini index to identify feature cells. TockyConvNet transforms Timer Angle and Intensity data into 2D grayscale images representing cell density. These images are batch-processed by ConvNet, with model behaviours monitored using Grad-CAM to enable identification of feature cells at the single-cell level.

In our strategic shift from manual gating to a data-oriented approach, we have developed a new research framework that utilises ML to enable coherent two-dimensional analysis of Timer Blue and Red fluorescence, departing from conventional two-variable analysis and significantly enhancing the power of Tocky. Figure 1b depicts a workflow within this framework, aimed at unravelling transcriptional dynamics in a functional system through ML-assisted identification of group-specific features. Using the Tocky system, transcriptional dynamics influenced by an enhancer are investigated by CRISPR-induced mutation of the enhancer within the Foxp3 Timer transgene. Independent experiments are conducted to generate training and test datasets through flow cytometric analysis of the Timer fluorescence profile of T cells. ML models are then trained to classify samples into experimental groups using the Timer fluorescence data. Subsequently, model performance analysis is conducted using the test data to obtain model performance metrics and validate the trained model. The behaviour of the trained model is then analysed by tailored methods, which enables the identification of group-specific feature cells. These feature cells represent the group-specific features that assist in the classification of samples across datasets. Importantly, our approach is designed to perform cross-dataset analysis by applying the trained ML model to new data inputs to dynamically identify group-specific feature cells. The robustness of the identified group-specific features is quantitatively supported by the model performance metrics, enhancing transparency and rigour of the data analysis process.

Under this novel research framework, we developed and implemented two primary ML approaches, TockyKmeansRF and TockyConvNet, each tailored to identify feature cells within Timer fluorescence data (Fig. 1c). Both methods are used to train ML models as classifiers, which are monitored and analysed to identify group-specific features. TockyKmeansRF integrates k-means clustering with Random Forest (RF) analysis, using the mean decrease Gini index to monitor model behaviour. Meanwhile, TockyConvNet converts this data into two-dimensional “images” for ConvNet analysis, employing Grad-CAM to identify key regions influencing network predictions40. In addition, we show the capability of TockyConvNet to establish a continuous scoring system for quantitatively analyse cellular phenotype.

To use these models, flow cytometric Timer Blue and Red fluorescence data are pre-processed and transformed into Timer Angle and Timer Intensity, as previously described7 and implemented as a computational tool41. Timer Angle is measured from the y-axis, represented by Timer Blue fluorescence, towards the x-axis, represented by Timer Red fluorescence. Timer Intensity is the magnitude (or norm) of the vector formed by these fluorescence values (Fig. 1c).

A novel experimental tool to investigate the roles of conserved non-coding sequence 2 (CNS2) in regulating temporal dynamics of Foxp3 transcription

To identify a biologically significant enhancer sequence and establish a prototypic approach to studying Foxp3 transcriptional dynamics, we analysed Chromatin Immunoprecipitation sequencing (ChIP-seq) data. Our analysis demonstrated that both Foxp3 and Runx1 proteins uniquely bound to the CNS2 region of the Foxp3 gene (Fig. 2a) as reported previously20. Importantly, our investigations using Foxp3-Tocky revealed that Foxp3 protein is required for sustaining Foxp3 transcription9 and that the CNS2 region is actively demethylated at the moment when Foxp3 transcription is sustained and persistent in the CD4 single-positive thymocytes7. Therefore, we hypothesised that CNS2 functions as a platform for critical transcription factors, including Foxp3 itself and Runx1, to dynamically regulate the Foxp3 transcriptional activities. Deleting the CNS2 sequence should therefore elucidate the temporal phases of Foxp3 transcriptional regulation that are dependent on CNS2 (Fig. 2b).

Fig. 2: Development of the CRISPR-mediated CNS2 KO Foxp3-Tocky Mouse Model.
figure 2

a ChIP-seq profiles showing aligned sequence reads for Runx1 and Foxp3 binding in Foxp3+ and Foxp3 − CD4 + T cells. b Working model of CNS2-dependent Foxp3 transcriptional regulation by Runx1 and Foxp3. c CRISPR-Cas9 strategy for CNS2 deletion within the Foxp3-Timer locus, showing the targeting oligonucleotide design. d Two PCR-based genotyping approaches: one detects CNS2 deletion in both endogenous and transgenic Foxp3 loci; the other discriminates WT and CNS2 KO Foxp3-Timer alleles. Screening of founder mice using e Common CNS2 Deletion PCR and f Foxp3 Timer-specific PCR. Screening was performed once during founder selection following embryonic injections. g Sanger sequencing confirming deletion in founder mice. h Breeding strategy illustrating how CNS2 KO Foxp3-Tocky mice were successively bred with WT animals over several generations to establish a stable mouse colony while ensuring that the endogenous Foxp3 gene remains free from mutations. i Established genotyping PCR for discriminating CNS2 KO Foxp3-Tocky and WT Foxp3-Tocky mice; representative result from >3 independent tests. j Sanger sequencing to validate specificity of the Foxp3 Timer-specific PCR shown in h. k Representative flow cytometric plots of Timer Blue vs. Timer Red and Timer Angle vs. Intensity for WT and CNS2 KO Foxp3-Tocky mice. l Box plots showing MFI of Timer Blue and Timer Red fluorescence in CD4+ T cells. The box represents the interquartile range (IQR; 25th–75th percentile), showing the median, and whiskers up to 1.5× IQR from the box. Statistical significance was assessed using a two-sided Student’s t-test (p  <  0.01). Exact p-values: Timer Red = 0.004; Timer Blue = 0.053. n  =  14 KO and 12 WT samples. m Percentage of cells within each Timer locus in CD4 + T cells from superficial lymph nodes. Locus definitions: New (0˚), NPt (0˚–30˚), Persistent (30˚–60˚), PAt (60˚–90˚), Arrested (90˚). Error bars show standard deviations. Two-sided Mann–Whitney test with p-value adjustment used. Adjusted p-values for Tocky loci: Persistent = 2.1 × 10-6, PAt = 6.2 × 10-6, Arrested = 1.3 × 10-2. n  =  14 KO and 12 WT samples.

The deletion of a sequence within a bacterial artificial chromosome (BAC) transgene could be done in vitro, followed by the creation of a new mouse strain. However, such an approach is susceptible to between-founder variations, an inherent issue in BAC reporter systems42. Meanwhile, modifying the endogenous Foxp3 sequence could make any output reporter measurement secondary to the modified dynamics of the Foxp3 protein43. Therefore, it was essential to delete the CNS2 sequence within the BAC Foxp3-Tocky transgene only, without disturbing the endogenous Foxp3 gene.

We achieved this by using a CRISPR KO method combined with a dedicated breeding strategy. Fertilised eggs from Foxp3-Tocky mice underwent CRISPR-based electroporation (Materials and Methods). To facilitate the deletion of CNS2, a single-stranded oligodeoxynucleotide carrying homology arms was used to enable homologous recombination and replace the CNS2 region with a short oligo (Fig. 2c). Critically, we established two distinct PCR assays: a CNS2 deletion-specific PCR to detect both the endogenous and BAC Foxp3-Timer loci (“Common CNS2 Deletion”) and Foxp3 Timer-specific PCR to discriminate WT Foxp3 Timer and CNS2 KO Foxp3 Timer (“Foxp3 Timer-Specific Discrimination PCR”, Fig. 2d). These assays identified founder mouse #87, which carried the CNS2 KO Foxp3 Timer without any evidence of CRISPR editing in the endogenous Foxp3 gene (Fig. 2e–f). Sanger sequencing further confirmed the successful deletion and homologous recombination of the CNS2 locus in the BAC transgene (Fig. 2g).

The founder mouse #87 was used to establish a breeding line through successive matings with WT mice. Over multiple generations spanning more than two years, we selectively bred progeny that expressed the CNS2 KO Foxp3 Timer, consistently backcrossing them to the B6 background. This extensive breeding and selection process confirmed that the CNS2 KO Foxp3-Tocky transgene was stably inherited in a Mendelian manner (Fig. 2h), reassuring that the modification involved a single transgene in an autosomal chromosome. Our breeding strategy and the backcrossing ensured the CNS2 deletion was specific to the Foxp3 Timer transgene, thereby effectively eliminating any possibility of CRISPR-induced alterations to the endogenous Foxp3 locus. The specificity of the Foxp3 Timer-Specific Discrimination PCR was further validated by Sanger sequencing (Fig. 2i–j). Based on these validations, we used hemizygous Foxp3-Tocky and hemizygous CNS2 KO Foxp3-Tocky mice as parents in all experiments, excluding double transgenics, and ensured that littermate analysis was consistently employed throughout the study.

Analysis of CNS2 KO Foxp3-Tocky using established methods

After establishing the CRISPR mutant strain, we first examined the effects of CNS2 deletion with conventional flow cytometric analyses (Fig. 2k). Mean fluorescence intensity (MFI) measurements revealed only a moderate, albeit significant, decrease in Timer Red fluorescence in KO T cells (p < 0.01), with Timer Blue largely unchanged (Fig. 2l). We next applied a trigonometric transformation7,44, converting Timer fluorescence into Timer Angle and Intensity. Although the Timer Locus categorisation method44 indicated that active Foxp3 transcription, identified as NPt, Persistent, and PAt categories, was reduced in KO T cells (Fig. 2m), these existing approaches rely on predominantly one-dimensional analyses and failed to capture the nuanced dynamics of CNS2-mediated Foxp3 transcription. This limitation underscored the need for more comprehensive methods to dissect Foxp3 transcriptional regulation.

TockyKmeansRF: Clustering and random forest analysis of timer fluorescence

Figure 3a illustrates the TockyKmeansRF implementation, a combinatorial ML method that integrates k-means clustering with RF classification45. TockyKmeansRF constructs an RF model using training flow cytometric Timer fluorescence data, which is subsequently tested on an independent test dataset. Initially, TockyKmeansRF applies k-means clustering separately to both training and test datasets, producing two tables that show the percentage of cells in each cluster. Clusters between these datasets are matched based on the Euclidean distances between them (Materials and Methods). The cluster percentage table from the training set is then utilised to build an RF model, which is evaluated using the corresponding table from the test set. The mean decrease Gini (MDG) index helps identify significant clusters and, consequently, feature cells within the original Tocky data46.

Fig. 3: TockyKmeansRF: Combinatorial analysis using clustering and random forest.
figure 3

a Schematic overview of the TockyKmeansRF framework combining k-means clustering and Random Forest (RF) classification to model Timer fluorescence in flow cytometry data. b Training and test datasets generated from lymph node samples of WT and CNS2 KO Foxp3-Tocky mice. c Area Under the Curve (AUC) analysis of model performance across varying numbers of clusters (top) and RF trees (bottom). d Visualisation of CNS2-dependent feature clusters in the test dataset. Timer Angle–Intensity and original Timer fluorescence spaces are shown. Top: feature importance by Mean Decrease Gini (MDG); bottom: feature cells defined as top 60th percentile by MDG. e Density-based clustering of feature cells. f Violin plots showing kernel density estimates of the percentage of cells in each cluster per sample (n  =  22 KO, 27 WT). Each point represents a biological replicate. The box indicates the interquartile range (IQR; 25th–75th percentile), the centre line denotes the median, and whiskers extend to the most extreme values within 1.5× IQR; outliers beyond this are plotted. Samples lacking cells in Cluster 3 (KO) were excluded from that cluster’s plot. g Violin plots showing mean fluorescence intensity (MFI) of CD25, CD44, PD-1, and CD69 for two identified clusters and remaining Timer+ cells (“others”) in WT samples (n  =  27). Statistical analysis used the Kruskal-Wallis test followed by Dunn’s test with Bonferroni correction. Timer-negative cells were included only as a baseline reference and excluded from statistical testing. The box shows the IQR, the centre line indicates the median, and whiskers extend to the most extreme values within 1.5× IQR. Exact p-values are provided in Supplementary Data 1. h Computational performance of TockyKmeansRF, showing runtime and memory usage with progressively increased CNS2 KO training data.

To validate the effectiveness of the ML approaches in the current study, we generated two independent datasets by conducting flow cytometric analysis on lymph node samples from WT Foxp3 Tocky and CNS2 KO Foxp3 Tocky littermates. This process produced the initial training and test datasets discussed in the following sections (Fig. 3b, Supplementary Table 1).

First, we assessed the robustness of the TockyKmeansRF model by varying the number of clusters in k-means clustering and the number of trees in the Random Forest model. We confirmed stable performance across a range of cluster and tree numbers by conducting area under the curve (AUC) analysis (Fig. 3c). The TockyKmeansRF model demonstrated a commendable classification accuracy. Constructed using training data with 18 clusters and subsequently tested on an independent dataset, the model achieved an out-of-bag (OOB) error rate of 7.69%. The confusion matrix from the test dataset indicates a high predictive accuracy, with an overall accuracy of 91.18%. This performance underscores the model’s robustness and its capability to distinguish effectively between the KO and WT classes within the testing framework, supporting the significance of the feature cells as follows.

Using the MDG index as an importance score, CNS2-dependent feature cells were identified among individual single cells within the test dataset, specifically in the Timer Angle and Intensity space and within the original Timer fluorescence data (Fig. 3d). Density-based clustering of these feature cells revealed three distinct clusters (Fig. 3e). Cluster 1 was predominantly found in KO mice, whereas Clusters 2 and 3 were more prevalent in WT mice in the training data (Fig. 3f). Notably, cells in Cluster 2 from WT Foxp3 Tocky mice exhibited high expression levels of CD25 (Interleukin-2 receptor alpha chain) and PD-1. Meanwhile, cells in Cluster 3 showed increased expression of CD69 and CD44 (Fig. 3g). Thus, each cluster had a unique activation profile and CNS2 KO T cells shifted from Clusters 2 and 3 to Cluster 1, markedly reducing Timer Intensity and approaching to the Timer Angle 90, which indicates the arrested transcription7.

Computational performance metrics, such as runtime and memory usage, were evaluated during the execution of TockyKmeansRF on the scaled CNS2 KO dataset (Fig. 3h). During training, the maximum runtime was approximately 3 s per training session, and peak memory usage did not exceed 30 MB, even as the sample size increased to 136. Notably, the number of trees in the RF model did not significantly impact either runtime or memory usage.

These findings underscore the efficacy of TockyKmeansRF in identifying unique CNS2-dependent feature cells and classifying CNS2 KO-specific patterns. This demonstrates the model’s robustness and precision in analysing complex dynamics of Timer fluorescence profiles, which are crucial for establishing a data-oriented approach to studying temporal transcriptional dynamics using the Tocky system.

TockyConvNet: A ConvNet approach using Grad-CAM for discriminating WT and CNS2 KO Foxp3 Timer

The successful deployment of TockyKmeansRF, coupled with the optimisation of a relatively high number of clusters, indicates that transforming Timer fluorescence data into image data could open new avenues for ML applications, particularly by leveraging ConvNet technologies. The conversion process involved binning the data into 100 × 100-pixel images (Fig. 4a), effectively preserving the essential visual characteristics of the Timer data after conversion (Fig. 4b).

Fig. 4: TockyConvNet: Deep learning-based analysis via image conversion and gradient mapping.
figure 4

a Schematic of the image conversion process applied to Timer fluorescence data. b Representative dot plots (left) and pseudocolour images (right) after conversion. c Architecture of the TockyConvNet model, comprising four convolutional layers used for Gradient-weighted Class Activation Mapping (Grad-CAM) shown in g, h. d Learning curve from three-fold cross-validation. Receiver Operator Characteristics (ROC) e and Precision–Recall f analyses for benchmarking TockyConvNet with manual gating strategies. Differential Grad-CAM heatmaps for WT vs. CNS2 KO samples across convolutional layers, shown in Timer Angle-Intensity g and Timer Blue-Red h spaces. Colour range is normalised per panel. Violin plots showing kernel density estimates of CNS2 feature cell percentages in WT (i; top 90th percentile) and KO (j; bottom 10th percentile) based on differential Grad-CAM maps. Each point represents a biological replicate. Statistical analysis used the two-sided Mann–Whitney test; **p  <  0.01, ****p  <  0.001. The box shows the interquartile range (25th–75th percentile), centre line indicates the median, and whiskers extend to the most extreme values within 1.5× IQR. n  =  22 KO and 27 WT samples. Exact p-values are in Supplementary Data 1. k Violin plots of mean fluorescence intensity (MFI) for indicated markers in WT feature cells, other Timer-positive and -negative cells in WT samples (n  =  27). Statistical significance was assessed using the Kruskal-Wallis test with Dunn’s post-hoc test (Bonferroni correction); **p  <  0.01, ***p  <  0.005, ****p  <  0.001. Timer-negative cells were included for reference only and not in statistical testing. Box and whisker definitions as above. Exact p-values are in Supplementary Data 1.

To prevent overfitting, for TockyConvNet we designed a compact ConvNet model consisting of two convolutional layers. Each layer features a sigmoid-activated pointwise convolution, termed “Spatial Attention”, enhancing spatially relevant feature extraction (Materials and Methods). The architecture includes two dense layers (Fig. 4c). The model successfully learnt through three-fold cross-validation using a relatively small number of training epochs (Fig. 4d).

The model’s efficacy was validated through ROC analysis on an independent test dataset. Furthermore, we benchmarked the TockyConvNet model against traditional manual gating methods employed in Fluorescent Timer analysis. These manual methods include Quadrant gating for distinguishing Timer Blue and Red positivity, and Polygons for cells with high Blue levels above and below the diagonal line between Timer Blue and Red, Polygon-Blue(high) and Polygon-Red(high), respectively (Supplementary fig. 1). TockyConvNet achieved excellent performance metrics, with both the Area Under the Curve (AUC) of the ROC and Average Precision scoring 1.0. In contrast, manual gating methods demonstrated significantly lower performance: the polygon gate scored 0.87 for AUC and 0.76 for Average Precision, while the quadrant gate scored 0.5 for AUC and 0.41 for Average Precision (Fig. 4e–f).

Grad-CAM analysis of CNS2-Dependent Foxp3 timer dynamics

To elucidate CNS2-dependent Foxp3 transcription dynamics, Grad-CAM was applied across various convolutional layers to visualise transcriptional features that distinguish two genotypes. Precisely, for each layer, gradients for each pixel across all feature maps were calculated, globally averaged, and weighted. These weighted feature maps were then transformed into a single heatmap through pixel-wise summation, retaining only positive activations using the ReLU function (Materials and Methods).

To analyse the features of CNS2-dependency effectively, we generated differential heatmaps from Grad-CAM outputs of WT and KO samples using each convolutional layer of our model (Fig. 4g). These heatmaps identified pixels critical for classification, illustrating how Grad-CAM progressively reveals these pixels across convolutional layers. The outputs were then reverse-mapped to their respective positions in the Timer Angle-Intensity space and to their original locations in the raw Timer Blue and Red fluorescence space (Fig. 4h).

Quantitative comparisons between the two genotypes were conducted by analyzing cells in the top 90th percentile as WT CNS2 feature cells (CNS2-dependent), and those in the bottom 10th percentile as KO feature cells (CNS2-independent). This analysis revealed that while all convolutional layers discerned differences between the two Foxp3 Tocky variants, the most pronounced differences were observed in the last convolutional layer, Attention2-Conv (Fig. 4i). In contrast, the cells increased in the KO group were predominantly captured by the first three convolutional layers (Fig. 4j).

The CNS2-dependent feature cells identified across all convolutional layers, as shown in Fig. 4i, exhibited higher CD44 expression compared to other Timer+ cells (Fig. 4k). Notably, the cells highlighted by the Attention2-Conv layer displayed significantly elevated expression of CD69 and PD1, distinguishing them from other Timer+ cells.

Gene regulation in CNS2-Dependent feature cells

To further explore the biological significance of CNS2-dependent feature cells in relation to the temporal regulation of Foxp3 transcription, we analysed RNA-seq data from flow-sorted Timer-positive cells from WT Foxp3 Tocky mice, fractionated into B1, B2, R1, and R2 fractions9 (Fig. 5a). Utilising TockyPrep for data preprocessing41, we converted Timer fluorescence data from these sorted cells into Timer Angle and Intensity values. This conversion facilitated the application of Grad-CAM analyses in Fig. 4g to dynamically identify CNS2-dependent and independent cells as CNS2 WT and KO feature cells, based solely on Timer distribution within the flow cytometric data linked to RNA-seq data.

Fig. 5: Gene Expression Analysis of CNS2-Dependent Feature Cells by Cross-Analysis of Grad-CAM Output from TockyConvNet and RNA-seq Data.
figure 5

a Timer expression profile (Upper) and Timer Angle and Intensity profile (Lower) of pre-sort CD4+ T cells and fractionated Foxp3 Timer+ cells from WT Foxp3 Timer mice. b Grad-CAM heatmap using the TockyConvNet, trained as shown in Fig. 4, applied to RNA-seq flow cytometric data. (Upper) Visualisation of WT feature analysed via Attention-Conv2 Grad-CAM, highlighted by red on heatmap (Upper); (Lower) KO feature cells visualised through Conv2 Grad-CAM, highlighted with a blue on heatmap. Colour range is normalised per panel. c Bar charts showing the percentage of WT feature cells (i.e. CNS2-dependent cells, left) and KO feature cells (i.e. CNS2-independent cells, right) in pre-sort CD4+ T cells and fractionated Foxp3 Timer+ cells. Error bars indicate standard deviations. n  = 3 biological replicates. Expression dynamics of key genes in fractionated Foxp3 Timer+ cells: d transcription factors downstream of TCR signalling; e genes associated with IL-2 and TGF-β signalling, along with prototypic upstream and downstream Foxp3 genes. p-values were obtained by two-sided Wald tests of the R package DESeq2 and adjusted by the Benjamini & Hochberg method. Asterisks indicate statistical significance (adjusted p-value < 0.05) and shown for comparisons involving B2 only. Error bars indicate standard deviations. n  = 3 biological replicates. Exact p-values are provided in Supplementary Data 1.

Precisely, using the extensive Grad-CAM analyses shown in Figs. 4g – j, CNS2-dependent cells were identified using WT Feature of Attention-Conv2, while CNS2-independent, inactive cells were pinpointed using KO Feature of Conv2 (Fig. 5b). This cross-dataset analysis revealed that the fraction B2 was highly enriched with CNS2-dependent cells, comprising over 40% of the cells in this fraction, while the other fractions contained only a few such cells (Fig. 5c). Conversely, CNS2-independent cells were predominantly found in the fraction R2, representing over 50% of the cells, while more than 30% in the fraction R1 as well.

The CNS2-dependent fraction B2 were characterised by uniquely high expression of NFAT genes (Nfatc1 and Nfatc2), distinctly among TCR signal downstream genes. In contrast, the CNS2-independent fractions R1 and R2 highly expressed other TCR signal downstream genes including Egr1, Nr4a1, Nr4a3, Rel, and Rela, but notably not the NFAT genes (Fig. 5e). These findings suggest that each fraction is associated with unique TCR signal dynamics, which may be also influenced by additional signalling pathways. Importantly, Foxp3 expression was highest in fraction B2, aligning with the high-frequency transcriptional dynamics observed by Foxp3 Tocky. In addition, CNS2-dependent B2 cells also showed elevated expression of genes associated with Foxp3 function, such as Tnfrsf4, Tnfrsf18, Ctla4, Icos, and the TGF-β receptor component Tgfbr1. Intriguingly, the dynamics of IL-2 signal-related genes in the B2 fraction showed a distinctive pattern, with upregulation of IL-2 receptors (Il2ra and Il2rb) and repression of Stat5a (Fig. 5f).

Collectively, our results confirm that CNS2-dependent cells exhibit the highest Foxp3 expression, aligned with the highest-frequency of Foxp3 transcription revealed by Tocky (Figs. 4c, 5b, and g). In addition, the gene expression profile of CNS2-dependent cells supports that CNS2 orchestrates Foxp3 transcription under finely tuned and unique TCR signalling dynamics predominantly mediated by NFAT. The downstream activities of TCR signalling notably exclude other well-characterised genes downstream of TCR signalling such as NF-kB and Nr4a genes and are potentially influenced by unique dynamics of IL-2 signalling as well (Figs. 4c and 5g).

Expanding the application of TockyConvNet to understand developmental and ageing Foxp3 transcription dynamics

Having demonstrated the utility of TockyConvNet with the CNS2 KO datasets, we aimed to further generalise the ConvNet method by generating and analysing independent flow cytometric datasets using Foxp3-Tocky mice. To this end, we analysed CD4+ T cells from the spleen and the thymus of WT Foxp3-Tocky mice across various ages, including neonates and aged mice, to capture the full spectrum of Foxp3 Timer dynamics throughout the mouse lifespan.

We discovered notable variations in Foxp3 Timer profiles, influenced by age and organ (Fig. 6a). Thymic T cells displayed new and active Foxp3 transcription, which decreased over time, resembling splenic Timer profiles in older mice. Particularly in neonates at days 3 and 4 post-birth, we observed high levels of new Foxp3 transcription in both thymus and spleen. On days 1 and 2 post-birth, the thymus included substantial numbers of CD4-single positive cells, whereas the spleen had too few CD4 + T cells to permit meaningful analysis (Supplementary Table 1b).

Fig. 6: Generation of Foxp3 Timer Neonatal-to-Ageing Benchmarking Data across developmental and ageing stages in WT Foxp3-Tocky mice.
figure 6

a Timer Blue and Timer Red expression in CD4 + T cells from the thymus and spleen of WT Foxp3 Timer mice at various ages. All samples within the training dataset were concatenated per group and shown as pseudocolour plots. Days and weeks since birth are indicated. b Normalised Timer fluorescence data from the flow cytometric analysis in a. c Timer Angle and Intensity transformed from the normalised Timer fluorescence data in b. d Percentage of CD4+ T cells in each of the indicated gates or the mean Timer Angle. e Percentage of mean Timer Angle plotted against logarithmically transformed age, with axis labels indicating actual age in days. Each line represents a quadratic regression model for each organ’s data. Shaded areas indicate 95% confidence intervals around the fitted regression lines.

The flow cytometric Foxp3 Timer data were normalised and transformed into Timer Angle and Intensity formats to quantitatively analyse the datasets (Fig. 6b, c), revealing dynamic and gradual changes between the tissues across different ages.

Notably, as mice aged, Timer Blue fluorescence in both splenic and thymic Foxp3 transcription diminished, while Timer expressing cells accumulated, particularly those with low Blue and high Red fluorescence (Figs. 6a, b) with high Timer Angles (Fig. 6c).

Thus, we generated independent training and test datasets (designated as Foxp3 Neonatal-to-Ageing Benchmarking Data). The aim of the analysis was to understand the tissue-specific and age-dependent dynamics of Foxp3 Timer profiles. Traditional manual gating methods, including quadrant and polygon gates (Supplementary Fig. 1), along with mean Timer Angle, captured some aspects of these dynamics, especially when the age scale is transformed logarithmically (Fig. 6d, e). These observations support significant changes in Foxp3 transcription dynamics from early life into old age (Fig. 6d, e). In aged mice, Timer+ cells accumulated, reflecting the impact of ageing on Foxp3 transcription.

These nuanced, continuous, and dynamic changes in Timer profiles across a broad range of samples make them ideal targets for analysis using TockyConvNet. To further validate this ConvNet method, we generated a training dataset and an independent test dataset, both consisting of splenic and thymic T cells from mice of various ages (Supplementary Table 1).

Development of the TockyConvNet for quantitative assessment of thymus and spleen characteristics in Foxp3 transcriptional dynamics

First, we aimed to develop a TockyConvNet model that captures the features of thymic Foxp3 dynamics and enables classification of samples given the age of mice. Accordingly, we adapted the TockyConvNet model to classify spleen and thymus samples by including age as an input for model training (Fig. 7a). This model effectively learnt the training dataset using three-fold cross-validation and showed high performance metrics including Area under curve of ROC 0.9 and Average Precision 0.95 (Fig. 7b). Furthermore, by transferring the learned parameters from all layers and removing the softmax activation from the final dense layer, we constructed a continuous score model that captures the smooth and continuous dynamics of Foxp3 transcription (Thymus-Spleen model score, Fig. 7c).

Fig. 7: Development of the TockyConvNet for Quantitative Assessment of Thymus and Spleen Characteristics in Foxp3 Transcriptional Dynamics.
figure 7

a Diagram of the ConvNet architecture for the age-adjusted TockyConvNet classifier and continuous score models. b ROC and Precision-Recall curve analysis using the TockyConvNet classifier. c Thymus-Spleen Continuous Score data from the TockyConvNet continuous score model analysing an independent test dataset, using linear age values (left) and log2-transformed age values (right).

The Thymus-Spleen model score data fit better with a quadratic regression using logged age rather than raw age (Fig. 7c, Supplementary Table 2), suggesting that changes are more pronounced in early developmental stages and diminish in adult mice. Interestingly, splenic T cells from neonatal mice, particularly at 3–4 days postpartum, showed high Thymus-Spleen model scores, comparable to those of adult thymic T cells, indicating that their Timer profiles closely resemble those found in thymic T cells. In contrast, thymic T cells from aged mice, especially those older than 10 weeks, demonstrated Timer profiles more characteristic of spleen-like T cells (Fig. 7c). These dynamics, reflecting gradual changes observed in two-dimensional plots of the raw data (Fig. 6), illustrate the model’s capability to capture the spectrum of changes from neonatal stages through to and ageing process.

Optimising and benchmarking of the TockyConvNet four-class classifier

The successful development of the TockyConvNet classifier and the continuous model scoring system demonstrates that specific patterns of Timer fluorescence dynamics are associated with Foxp3 transcriptional dynamics in both the spleen and thymus, adjusted for the age of mice. This is particularly noteworthy as the thymus in adult and aged mice, typically over 6-7 weeks old47, may include peripheral T cells that have recirculated into the organ. Despite this, the model has successfully classified aged thymus samples correctly, confirming that T cells within the thymus of aged mice exhibit distinctive Foxp3 transcriptional dynamics, distinct from both young thymic T cells and aged splenic T cells. To comprehensively capture the compositions and real-time transcriptional dynamics across the lifetime of mice in these two major immunological organs—and to fully utilise this resource to benchmark the TockyConvNet approach—we extended the TockyConvNet approach from two-class classifier into four-class-classifier categorising samples by both organ type (thymus and spleen) and age (young, <30 days postpartum; aged, ≥30 days), aligned with standard definition of young adult thymus48. Consequently, the benchmarking dataset has been biologically optimised and exhibits balanced class distribution for ML modelling and analysis (Supplementary Table 1).

We assessed three distinct ConvNet architectures varying in the number of convolutional layer blocks (one, two, or three), resulting in the development of Conv1-Layer, Conv2-Layers, and Conv3-Layers TockyConvNet 4-Classifiers, respectively (Supplementary Figs. 2a–c and 3a, b). Each convolutional layer block consists of a 3×3 convolutional layer followed by a 1×1 convolutional layer serving as a spatial attention mechanism, similar to the structure used in the TockyConvNet model for CNS2 KO Foxp3 Tocky data (Supplementary Fig. 2 and Fig. 8a, Materials and Methods section). Among these, the Conv3-Layers model (Fig. 8a) demonstrated superior performance, as evidenced by ROC and Precision-Recall analyses (Fig. 8b). While the Conv2-Layers model exhibited comparable, albeit slightly reduced performance, the Conv1-Layer model showed a marked decrease in effectiveness.

Fig. 8: Optimising and Benchmarking of the TockyConvNet Four-Class Classifier.
figure 8

a Diagram of the 3 Conv-Layer TockyConvNet architecture as a four-class classifier for classifying the two organs (Spleen vs. Thymus) and stratified ages (Young [<30 days old]; vs. Aged ( > 30 days old)). b Optimisation of the TockyConvNet architecture, comparing models with one, two, and three convolutional layer blocks by ROC and Precision-Recall curve analysis. c Benchmarking results of TockyConvNet against other methods including TockyKmeansRF and manual gating strategies in differentiating the four classes using ROC (left) and Precision-Recall curves (right). The data generated in Fig. 6 were used.

Next, we examined the impact of data preprocessing on model performance. Converting Timer Fluorescence into Timer Angle and Intensity was crucial as raw fluorescence data was challenging for the ConvNet to process, leading to suboptimal performance (Supplementary Fig. 4a). Additionally, experimenting with different data resolutions, we found that neither low (25 × 25) nor high (400 × 400) resolution grids were effective (Supplementary Fig. 5a). This suggests that a resolution of 100 ×100 strikes the optimal balance by maintaining sufficient detail for accurate feature extraction and ensuring a good density of cells across pixels, which is critical for reducing meaningless variability in the data.

Finally, we benchmarked the TockyConvNet models against conventional manual gating methods, specifically polygon and quadrant gates, which have been widely utilised in prior studies using Fluorescent Timer proteins (Fig. 8c, Supplementary Fig. 1)49,50. These traditional methods yielded satisfactory results for categorising Thymus-Young and Spleen-Aged samples, yet they faltered in accurately classifying the other two classes. Although the TockyKmeansRF method demonstrated notable efficiency with Thymus-Young and Spleen-Aged samples, it was less effective for Spleen-Young. Notably, TockyConvNet consistently outperformed all the other methods in both ROC and Precision-Recall analyses (Fig. 8b), establishing the TockyConvNet approach as a robust classifier using image-converted Timer data.

Optimising Grad-CAM method for analysing Foxp3 timer dynamics

To further explore and develop the Grad-CAM method for flow cytometric Timer data, we analysed each convolutional layer’s output by Grad-CAM using the optimised TockyConvNet model (Fig. 9). Heatmaps of the Grad-CAM outputs illustrate these distinctions, showing the progression of feature capture across layers (Fig. 9a). ROC analysis identified the efficacy of each convolutional layer in differentiating the four classes. The Thymus-Young and Spleen-Aged classes were distinctly recognised throughout the layers, while and Thymus-Aged and Spleen-Aged classes were the most distinctly recognised in the Conv2 layer (Fig. 9b).

Fig. 9: Optimising Grad-CAM method for analysing Foxp3 timer dynamics.
figure 9

a Heatmaps of Grad-CAM for each convolutional layer, visualising pixels used for discriminating each indicated class. Colour range is normalised per panel. b ROC curves showing class-discriminative capacity of each of the convolutional layers by Grad-CAM. c Heatmap visualisation of the Grad-CAM outputs for each class in both Timer Angle and Intensity space, and original Timer fluorescence space. Colour range is normalised per panel.

Visualisation of the most informative convolutional layers in both Timer Angle and Intensity space, as well as the original Timer fluorescence space, provided further insights into important features in the transcriptional dynamics of different classes with single-cell granularity (Fig. 9c). Notably, Grad-CAM high cells in the Spleen-Aged class were predominantly located on the lower edge within the Timer Blue-Red space, with high Timer Intensity within the high 80°–90° Timer Angle range (Fig. 9c), mirroring the marked accumulation of cells within BlueRed+ (Fig. 6e). This suggests their substantially attenuated and infrequent Foxp3 transcription after culminating Foxp3 proteins. In contrast, Grad-CAM high cells in the Spleen-Young class included both new Timer expression (Timer Blue+Red, Angle = 0 °) and low Timer Intensity within the ~90° Timer Angle arrested class, suggesting that some spleen cells newly and moderately express Timer protein but may rapidly transition to arrested transcription states without sustained Foxp3 transcription. Meanwhile, the Thymus classes are both characterised by newly induced Foxp3 transcription, with Thymus-Young cells predominantly featured by remarkably high new transcription to intermediate Timer Angles with high Timer Intensity (Fig. 9c). Thymus-Aged cells are characterised by both new expression and high Timer Angle cells with high Timer Intensity, suggesting their ability to activate Foxp3 transcription as well as the accumulation of spleen-like cells, presumably due to the recirculation of peripheral T cells in aged mice47.

Runtime and memory usage for TockyConvNet model learning

Lastly, the computational efficiency of TockyConvNet model learning was evaluated by analysing the runtime and memory usage. For the CNS2 KO Foxp3 Tocky data, processed with the established Conv 2-Layer model, the runtime ranged from approximately 1 to 6 s, and memory usage spanned from about 2 GB using sample sizes between 52 and 416 (Supplementary fig. 6). Similarly, using the Developmental and Ageing WT Foxp3 Tocky dataset to train the Conv 3-Layers model, runtime and memory usage also increased with larger sample sizes, ranging from around 10 to 70 s for runtime and significantly higher memory usage from approximately 1.5 to 3 GB. Together with the model complexity information in Supplementary Table 3, the analysis highlights the scalability of the TockyConvNet model, albeit with increasing computational demands for larger datasets.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *