Main

In the past decade, immunotherapy has transformed cancer treatment, markedly improving patient outcomes across diverse tumour types2. Notably, beyond prolonging survival, immunotherapy can produce durable, complete responses, even in patients with advanced or metastatic disease4. Immunotherapy aims to unleash a host-derived T cell immune response against cancer cells, by blocking immune regulatory pathways and overcoming cancer immune evasion. With the introduction of immune checkpoint inhibitors (ICIs) that target programmed cell death protein 1 (PD-1), its ligand (PD-L1) or cytotoxic T-lymphocyte-associated protein 4 (CTLA-4), immunotherapy in the early or advanced setting has become standard of care across several tumour types, including melanoma5,6, non-small cell lung cancer (NSCLC)7, and renal cell carcinoma (RCC)8. However, only subsets of patients across tumour types have improved survival in response to ICIs9,10,11.

At present, biomarker research focuses on tumour-intrinsic factors, such as PD-L1 (ref. 12) or tumour mutation burden (TMB)13, but their utility as biomarkers is limited12,13,14, given that cancers across all biomarker levels may or may not have improved outcomes in relation to ICIs12,13. The poor performance of tumour-based biomarkers might be caused by a reliance on biopsies from tumours that are temporally and spatially heterogeneous15,16. However, it is also likely that the health of the patient’s immune system is important for immunotherapy response. No clinical test is at present performed to evaluate individual immune competence before immunotherapy.

Studies in recent years extend to tumour-extrinsic blood-based biomarkers, such as T lymphocytes, the T cell receptor repertoire, myeloid-derived suppressor cells or circulating tumour cells. This might pose a way forward, but research is still preliminary17,18. Indeed, the relevance of a patient’s immune health before treatment remains mostly unknown.

The thymus is an immune organ that is often overlooked in adults19. Because the thymus naturally decays through ageing, it is generally considered irrelevant in adults. However, the thymus is crucial for T cell maturation and for maintaining a diverse and specific adaptive immune response through life. Notably, previous studies suggest that the thymus is of pivotal relevance to health in adults20,21. However, the relevance of the thymus for cancer immunotherapy outcomes has never been investigated, and it remains unclear whether thymic health is associated with immuno-oncology outcomes and survival. The standard-of-care chest computed tomography (CT) scans obtained during routine cancer care capture the thymus in their field of view, which presents a unique opportunity to assess thymic health on the basis of radiographic characteristics. Especially given the breakthroughs in deep learning using self-supervised learning, this allows for detailed automated characterization of thymic health.

In this study, we investigate the associations of thymic health with outcomes to cancer immunotherapy in 3,476 real-world patients with various types of cancer (HARVARD-NSCLC and HARVARD-PAN; Fig. 1a). We further explore the immunological associations of thymic health in an independent deeply characterized NSCLC cohort from a prospectively enrolled lung cancer clinical trial (TRACERx, ClinicalTrials.gov: NCT01888601; Fig. 1a). We use a deep-learning system to automatically quantify thymic health on CT scans, and we demonstrate a significant positive association between thymic health and survival outcomes across cancer types. Notably, we show that thymic health is strongly associated with prolonged progression-free survival following immune checkpoint inhibitor therapy and prolonged overall survival (OS) in patients with NSCLC, performing similarly to TMB and PD-L1 for outcome prognostication. In the independent, prospectively recruited TRACERx study of treatment-naive patients with NSCLC, thymic health at diagnosis is associated with blood T cell receptor excision circle levels, T cell receptor diversity in blood and tumour and blood immune proteins, suggesting immunological relevance. Finally, in an analysis of real-world immunotherapy-treated patients with various cancer types, we observe a significant association between thymic health and survival outcomes, indicating the tumour-agnostic prognostic potential of thymic health. These results provide evidence of the crucial role of a patient’s thymic health for immunotherapy outcomes across cancer types, with key implications for precision medicine.

Fig. 1: Overview of real-world cohorts and study design.
Fig. 1: Overview of real-world cohorts and study design.
Full size image

a, Overview of training data and the real-world Harvard-NSCLC and Harvard-PAN (melanoma, renal, breast, bladder, oesophagus, others) evaluation cohorts (total, n = 3,476). Harvard-PAN tumours with fewer than 100 patients per entity were pooled as ‘Others’. All patients were treated with immunotherapy at the Dana-Farber Harvard Cancer Center (DFHCC). External and biological validation was done in the prospectively collected TRACERx NSCLC cohort (n = 464) b, Overview of model development. A deep-learning system able to automatically predict thymic health, as a proxy for thymic functionality, based on standard-of-care chest CT scans was developed using 5,674 independent CT scans of the training data. We applied the model to the standard-of-care CT scans from the Harvard-NSCLC and Harvard-PAN cohorts as well as the external prospectively collected TRACERx cohort for statistical analysis. SSL, self-supervised learning. c, Overview of cohort descriptions. d, Representative images of high, average and low thymic health. The anatomical overview of cancer types in a was created in BioRender; Birkbak, N. https://BioRender.com/aa6hkul (2026).

Quantifying thymic health in NSCLC

We obtained imaging and clinical data from 1,218 real-world patients with NSCLC from the Harvard-NSCLC cohort (Fig. 1). All patients with NSCLC were treated with checkpoint inhibitor immunotherapy, either as immunotherapy (IO) monotherapy (n = 793; n = 245 (31%) as first-line treatment) or in combination with chemotherapy (chemo-IO; n = 425; n = 407 (96%) as first-line treatment). The demographic and clinical characteristics of the cohort are shown in Table 1. We applied a newly developed and independently validated deep-learning system to quantify imaging characteristics of the thymus on CT scans as a surrogate for thymic functionality. The system takes a CT scan as input and automatically outputs a continuous quantification of thymic health (Fig. 1b), in which higher thymic-health values are hypothesized to correspond to higher thymic functionality. For outcome analyses, patients were categorized into low (bottom 25%), average (middle 50%) and high (top 25%) thymic-health groups. These thresholds were supported by cut-point iterations (Extended Data Fig. 1).

Table 1 Clinical and epidemiological characteristics of the Harvard-NSCLC cohort

Thymic health and outcomes in NSCLC

To investigate the associations of thymic health with progression-free survival (PFS) in patients treated for NSCLC, we used Kaplan–Meier and Cox proportional hazards analyses in the HARVARD-NSCLC cohort. Patients with average or high thymic health had significantly lower risks of progression or death following immune checkpoint inhibitor therapy than did those with low thymic health across both treatment groups (chemo-IO and IO monotherapy) (high versus low thymic health: hazard ratio, 0.65; 95% confidence interval (CI), 0.54–0.77; average versus low thymic health: hazard ratio, 0.67; 95% CI, 0.58–0.78; type III P < 0.001) (Fig. 2a), in patients treated with chemo-IO (high versus low thymic health: hazard ratio, 0.58; 95% CI, 0.41–0.82; average versus low thymic health, hazard ratio, 0.62; 95% CI, 0.47–0.82; type III P = 0.002) (Extended Data Fig. 2a) and in patients treated with IO monotherapy (high versus low thymic health: hazard ratio, 0.66; 95% CI, 0.54–0.80; average versus low thymic health: hazard ratio, 0.71; 95% CI, 0.59–0.85; type III P < 0.001) (Extended Data Fig. 2b). The effect sizes of these associations were stronger in first-line settings for patients treated with chemo-IO or IO monotherapy (Fig. 2b,c). All associations were preserved after adjustments that included—among others—sex, age, Eastern Cooperative Oncology Group (ECOG) performance status, histological subtype, PD-L1 and TMB (chemo-IO, first-line, type III P = 0.031; IO monotherapy, first-line, type III P = 0.016). Similar results were found after additional adjustments for body mass index (BMI) and smoking status (Supplementary Fig. 1), and also in subgroup analyses stratified by sex and age (Extended Data Fig. 3). Weaker associations of thymic health with prolonged PFS were found in patients who received immunotherapy as second-line or later treatment (Extended Data Fig. 2c,d).

Fig. 2: Association of thymic health with progression-free and overall survival in patients with NSCLC.
Fig. 2: Association of thymic health with progression-free and overall survival in patients with NSCLC.
Full size image

af, Kaplan–Meier estimates and Cox proportional hazards models of PFS (ac) and OS (df) according to thymic health (an imaging-based proxy for thymic functionality). Analyses show the comparison of high or average thymic health to the reference of low thymic health. The forest plots show the same data after multivariate adjustments. a,d, All patients with NSCLC who were treated with immunotherapy. Adjustments included sex, age, ECOG performance status, histological analysis, PD-L1, TMB, treatment line and stratification by treatment type (IO monotherapy or chemo-IO combination therapy). b,c,e,f, Subgroups of patients with NSCLC after excluding second-line-plus patients who were treated with chemo-IO combination therapy (b,e) or IO monotherapy (c,f). Adjustments included sex, age, ECOG performance status, histological analysis, PD-L1 and TMB. af, Age, PD-L1 and TMB were used as continuous covariates. Cox proportional hazards regression was used to estimate hazard ratios (HRs). In the forest plots, the centre of each box represents the estimated HR, and the whiskers denote the corresponding 95% CI; arrowheads indicate that the 95% CI extends beyond the visualized limits; shaded box size is for visualization only and does not encode statistical weight. The overall contribution of thymic health to uni- or multivariable models was evaluated using likelihood ratio tests (χ² tests) comparing full models with nested models excluding thymic health (type III test, two-sided), with no adjustments for multiple comparisons.

Next, we investigated the associations of thymic health with OS in the same patient cohort treated for NSCLC. In line with the associations with PFS, we found significantly lower risks of death among patients with average or high thymic health than among those with low thymic health, in all patients (high versus low thymic health: hazard ratio, 0.56; 95% CI, 0.46–0.68; average versus low thymic health: hazard ratio, 0.64; 95% CI, 0.55–0.76; type III P < 0.001) (Fig. 2d), in patients treated with chemo-IO (high versus low thymic health: hazard ratio, 0.54; 95% CI, 0.36–0.81; average versus low thymic health: hazard ratio, 0.54; 95% CI, 0.40–0.75; type III P < 0.001) (Extended Data Fig. 4a) and in patients treated with IO monotherapy (high versus low thymic health: hazard ratio, 0.56; 95% CI, 0.45–0.70; average versus low thymic health: hazard ratio, 0.70; 95% CI, 0.58–0.85; type III P < 0.001) (Extended Data Fig. 4b). Also here, the effect sizes of these associations were stronger after excluding patients who received immunotherapy as second-line or later treatment among patients treated with IO monotherapy, and similar for those who received chemo-IO as first-line treatment (Fig. 2e,f). All associations were preserved after adjustments that included—among others—sex, age, ECOG performance status, histological subtype, PD-L1 and TMB (type III P < 0.005 for both). Again, the associations were similar after additional adjustments for BMI and smoking status (Supplementary Fig. 1), and also in subgroup analyses stratified by sex and age (Extended Data Fig. 3). Weaker associations of thymic health with OS were found in patients who received second-line or later treatment (Extended Data Fig. 4c,d). We observed a consistent—although non-significant—trend towards an interaction between thymic health and immunotherapy treatment line, in which the association of thymic health with outcomes seemed to be stronger in first-line patients (Supplementary Fig. 2).

Thymic health versus PD-L1 and TMB

To compare thymic health with established clinical biomarkers, we first investigated thymic health across the clinically established PD-L1 and TMB subgroups. We found that average or high thymic health was associated with improved PFS and OS in each of the PD-L1 and TMB subgroups, as compared with low thymic health (Table 2 and Extended Data Fig. 5). Notably, among patients with the lowest PD-L1 expression (less than 1%), those who had high thymic health had a 44% lower risk of progression following immune checkpoint inhibitor therapy, compared with those who had low thymic health. Next, to benchmark the performance of thymic health against PD-L1 and TMB for their associations with clinical outcomes, we compared each biomarker’s relationship with PFS and OS, individually. We found that the average effect sizes of thymic health were similar to those of PD-L1 and TMB, for both PFS and OS in Cox models extensively adjusted for clinical variables (Fig. 3a,b and Supplementary Fig. 3). Patients who received first-line therapy for tumours with PD-L1 expression of 50% or higher had a risk of progression of 0.77 (95% CI, 0.62–0.96; P = 0.02) and a risk of death of 0.64 (95% CI, 0.49–0.83; P < 0.001), as compared with those with PD-L1 expression of less than 50%. By contrast, patients with high thymic health had risks of progression or death of 0.57 (95% CI, 0.42–0.78; type III P < 0.001) or 0.50 (95% CI, 0.35–0.72; type III P < 0.001), respectively, as compared with those with low thymic health (Extended Data Fig. 6a,b). There was no significant interaction between thymic health and PD-L1 (Supplementary Fig. 4) and no significant correlation with PD-L1 or TMB (Extended Data Fig. 6c,d). In addition, excluding thymic health from multivariate Cox models did not markedly alter the hazard ratio estimates of the remaining covariates (Supplementary Fig. 3). Together, these data indicate that thymic health provides independent and potentially complementary prognostic information beyond clinical variables and tumour-centric biomarkers.

Fig. 3: Association of thymic health, PD-L1 and TMB with progression-free and overall survival in patients with NSCLC.
Fig. 3: Association of thymic health, PD-L1 and TMB with progression-free and overall survival in patients with NSCLC.
Full size image

Cox proportional hazards models of PFS and OS according to thymic health, PD-L1 and TMB, with adjustments for sex and continuous age. a,b, PFS (a) and OS (b) analyses for all patients with NSCLC who were treated with immunotherapy. Analyses according to PD-L1 and TMB were done at clinically relevant cut-points of 1% or 50% for PD-L1 and 10 mutations per Mb (mut per Mb) for TMB. a,b, Cox proportional hazards regression was used to estimate HRs. In the forest plots, the centre of each box represents the estimated HR, and the whiskers denote the corresponding 95% CI; shaded box size is for visualization only and does not encode statistical weight. The overall contribution of thymic health to multivariable models was evaluated using likelihood ratio tests (χ² tests) comparing full models with nested models excluding thymic health (type III test, two-sided). Statistical significance of individual covariate coefficients was assessed using two-sided Wald z-tests without adjustments for multiple comparisons.

Table 2 Overall and progression-free survival in patients with NSCLC treated with immunotherapy according to thymic health across PD-L1 and TMB subgroups

Thymic health reflects thymic output

To determine the biological correlates of our image-based thymic-health quantification, we investigated thymic health in 464 prospectively enrolled, treatment-naive and operable stage I–IIIB patients with NSCLC from the TRACERx study22. Details of TRACERx patient selection and the number of patients with available data per analysis are shown in Supplementary Fig. 5.

Signal joint T cell receptor excision circles (sjTRECs), a by-product of VDJ recombination during T cell maturation in the thymus23, are an established marker of thymic output20,23,24. To investigate the link between thymic output and thymic health, we quantified the levels of sjTRECs in blood from 45 patients with either low or high thymic health and available blood. Patients with high thymic health had significantly higher levels of sjTRECs (Fig. 4a), linking high thymic health with increased thymic output. These findings indicate that, in many individuals, thymic production of naive T cells persists into advanced age, potentially sustaining the T cell receptor (TCR) repertoire diversity24. To further investigate how thymic health may relate to T cell dynamics, we gathered tumour and blood-based immunological data for patients with available thymic health scores (Supplementary Fig. 5). We analysed peripheral blood TCR diversity in 50 TRACERx patients for whom data were available25. Our analysis revealed that patients with higher thymic health had greater peripheral blood α- and β-chain TCR diversity (Fig. 4b,c). Finally, we estimated the fraction of T cells in blood using T cell ExTRECT26. We found that patients with higher thymic health exhibited increased circulating T cell abundance (Fig. 4d), providing further evidence of higher thymic output in these patients.

Fig. 4: Biological associations with thymic health in TRACERx.
Fig. 4: Biological associations with thymic health in TRACERx.
Full size image

a, Comparison of sjTREC to ribonuclease P protein subunit P30 (RPP30) ratio for patients with high or low thymic health. Split based on the full cohort. b,c, Comparison of TCR β-chain (b) and α-chain (c) normalized Shannon diversity for patients with above-median and below-median thymic health. Split based on median thymic health among patients for whom TCR data were available. d, Comparison of blood T cell fraction for patients with above-median and below-median thymic health. Split based on median thymic health among patients for whom data were available. e, Correlation between thymic health and blood protein levels, measured by Olink (n = 108). Associations were quantified using Spearman’s rank correlation, using algorithm AS 89 for P value calculation (two-sided). Associations were considered significant at a false discovery rate (FDR) < 0.25 (Benjamini–Hochberg method). f,g, REACTOME pathway enrichment analysis showing the top ten enriched pathways based on proteins associated with higher thymic health (f; n = 8 proteins, 6 in pathways) or proteins associated with lower thymic health (g; n = 91 proteins, 60 in pathways). P values were calculated using a hypergeometric test (one-sided) and adjusted using FDR (Benjamini–Hochberg method). GPCR, G-protein-coupled receptor; TNF, tumour necrosis factor. ad, Box plots show the median (centre line), interquartile range (25th–75th percentiles; box), and whiskers extending to the minimum and maximum values within 1.5 × the interquartile range; statistical comparisons between groups were performed using two-sided Wilcoxon rank-sum tests; no adjustment for multiple comparisons was applied.

Next, we investigated the association of thymic health with tumour T cell infiltration. Notably, higher thymic health was correlated with a higher intratumoral β-chain TCR diversity, whereas this was not observed in the adjacent normal lung tissue (Extended Data Fig. 7a–d). In addition, we observed a higher fraction of T cells—estimated using T cell ExTRECT26—in tumours from patients with higher thymic health (Extended Data Fig. 7e). Splitting the data on the basis of the three thymic-health groups showed similar trends (Extended Data Fig. 7f–m). Together, these data suggest that thymic health is associated with the adaptive immune system, including peripheral blood abundance and diversity and the tumour-specific immune response.

Next, we analysed blood protein levels in 108 TRACERx patients with available Olink data27, to examine the associations between the plasma proteomic landscape and thymic health (Fig. 4e). Notably, pathway enrichment analysis revealed signalling pathways of the adaptive immune system that were positively correlated with thymic health (Fig. 4f,g). Furthermore, we investigated protein–protein interactions using the STRING database28. We found that proteins associated with higher thymic health were significantly enriched for protein–protein interactions (P = 0.017), and after expanding the network to include closely connected nodes, we identified interactions with several molecules involved in T cell regulation (Extended Data Fig. 8a). This indicates that there is a positive correlation between thymic health and proteomic mediators of adaptive immunity.

Finally, we investigated the association between thymic health and clinical factors, and found that thymic health was higher in female individuals and decreased with age (Extended Data Fig. 8b,c). As observed in the Harvard-NSCLC cohort for progression-free and overall survival, in the TRACERx cohort, patients with average to high thymic health had longer disease-free survival, as compared with those with low thymic health (high versus low thymic health: hazard ratio, 0.62; 95% CI, 0.43–0.89; average versus low thymic health: hazard ratio, 0.69; 95% CI, 0.51–0.93; type III P = 0.019; Extended Data Fig. 8d). The estimated effect size was preserved after multivariable adjustments (sex and age adjusted: high versus low thymic health: hazard ratio, 0.71; 95% CI, 0.49–1.05; average versus low thymic health: hazard ratio, 0.74; 95% CI, 0.54–1.00; type III P = 0.12; sex, age, stage and adjuvant treatment: high versus low thymic health: hazard ratio, 0.84; 95% CI, 0.57–1.24; average versus low thymic health: hazard ratio, 0.78; 95% CI, 0.49–1.25; type III P = 0.56; Extended Data Fig. 8d).

Together, these biological data provide evidence that radiographic quantification of thymic health is a proxy of thymic functionality and immune competence, and support the clinically relevant role of the thymus in patients with cancer—particularly in the context of immunotherapy.

Thymic health and pan-cancer survival

To investigate tumour-agnostic associations of thymic health with immunotherapy outcomes, we obtained imaging and clinical data from the Harvard-PAN cohort, consisting of an additional 2,258 real-world patients who were treated with ICIs for cancers of types other than NSCLC, including melanoma (n = 309), renal (n = 247), breast (n = 136), bladder (n = 133) and oesophageal (n = 120) cancers (Fig. 1). Smaller cohorts with fewer than 100 patients each were pooled as ‘others’ (n = 1,313). The demographic and clinical characteristics of the cohort are shown in Supplementary Tables 16, and associations between thymic health and age, sex and smoking in the pooled Harvard cohorts are shown in Extended Data Fig. 9. To investigate the association of thymic health with OS, we used Kaplan–Meier and Cox proportional hazards analyses across the different cancer types. We found lower risks of death in patients with average or high thymic health than in those with low thymic health across all examined cancer types, and significance was reached for patients with melanoma, breast cancer, renal cancer and pooled smaller types (Fig. 5). All associations were preserved with similar effect sizes after adjustments for sex and age. Together, these pan-cancer investigations suggest that thymic health has a clinically relevant role in determining outcomes to immunotherapy, and that this role is tumour-agnostic.

Fig. 5: Association of thymic health with overall survival in patients treated with immunotherapy for various cancer types.
Fig. 5: Association of thymic health with overall survival in patients treated with immunotherapy for various cancer types.
Full size image

af, Kaplan–Meier estimates and Cox proportional hazards models of OS according to thymic health (an imaging-based proxy for thymic functionality). Analyses show the comparison of high or average thymic health to the reference of low thymic health. The forest plots show the same data after multivariate adjustments for sex and continuous age. Patients with melanoma (a), breast (b), renal (c), bladder (d), oesophageal (e) and pooled other cancer types with fewer than 100 cases per entity (f). af, Cox proportional hazards regression was used to estimate HRs. In the forest plots, the centre of each box represents the estimated HR, and the whiskers denote the corresponding 95% CI; arrowheads indicate that the 95% CI extends beyond the visualized limits; shaded box size is for visualization only and does not encode statistical weight. The overall contribution of thymic health to uni- or multivariable models was evaluated using likelihood ratio tests (χ² tests) comparing full models with nested models excluding thymic health (type III test, two-sided), with no adjustments for multiple comparisons.

Discussion

In this study we provide evidence for the clinical relevance of thymic health in immuno-oncology. We found that high thymic health was consistently associated with improved outcomes across a real-world cohort of 3,476 patients with various cancer types who were treated with ICIs. In our analysis, thymic health was a particularly strong indicator of outcome in lung cancer and melanoma—cancer types that are commonly treated with immunotherapy. Associations of thymic health and outcomes were also found in patients with breast and renal cancer, indicating that the prognostic relevance of thymic health is tumour-agnostic. Analyses in the independent and prospectively collected TRACERx cohort provide evidence that radiographic quantification of thymic health is a proxy of thymic functionality and related to immune competence. These findings suggest that an individual’s immune health relates to immunotherapy outcomes, highlighting the potential importance of considering host-specific factors as biomarkers, rather than relying solely on the tumour-centric biomarkers that at present dominate the field.

Although immunotherapy is increasingly being applied in oncology, only a subset of patients respond9,10,11. To optimize treatments and expand the population of patients who benefit from immunotherapy, improved biomarkers are needed to better estimate individual prognosis in this context. Despite the fact that ICIs derive their anti-tumour properties from T cells and their capability to invade and potentially destroy neoplasms, precision medicine in immuno-oncology has so far focused on biomarkers that predominantly capture cancer-specific biology12,13,14. We define thymic health as a universal prognostic biomarker on the basis of the radiographic characteristics of the thymus itself—an immune organ that is crucial for T cell maturation and generating a diverse T cell repertoire. These characteristics are essential for detecting foreign antigens and required for immunotherapy response.

Our results show that thymic health enables robust immuno-oncology prognostication using routine, standard-of-care thoracic CT scans without additional imaging, patient burden or delay. Although further studies are required to define biomarker-specific thresholds and assess negative and positive predictive values, our results nevertheless provide evidence that thymic health could serve as an instantly available, integral biomarker for immuno-oncology, either as a stand-alone measure or in combination with measures of PD-L1 and TMB. PD-L1 remains a well-established predictor of response, and, as expected, patients with low PD-L1 expression had worse survival following immunotherapy in NSCLC. However, our results suggest that thymic health adds independent prognostic value beyond PD-L1 by capturing the host’s immune competence. Together, these markers reflect distinct biological axes, tumour immune evasion and immune competence, and their combined assessment might offer a more complete framework for precision immuno-oncology. Our findings thus suggest that host-based biomarkers that quantify the state of adaptive immunity should be incorporated into the precision-medicine-based stratification of patients.

We show that we can identify patients with different cancer types who are likely to benefit from immunotherapy. It is conceivable that our approach could further accelerate the adoption of immunotherapy in new indications in which only a small subset of patients might benefit, and for which no biomarkers currently exist. Although higher thymic health was consistently associated with improved outcomes, the threshold for benefit seemed to vary across cancer types. In some cancers, both high and average levels of thymic health were associated with better outcomes; in others, only high levels were. This suggests that thymic health acts along a gradient, with tumour-type-specific factors, immune responsiveness and specific treatment protocols also being important factors18,29. A similar pattern has been reported for TMB, which showed stronger predictive value in some cancers, such as melanoma or NSCLC, than in others, such as breast or oesophageal cancer29. Similarly, our results suggest that thymic health assessment could facilitate the identification of patients at risk of poor outcomes following immunotherapy. Indeed, preventing non-beneficial immunotherapy is essential. It increases quality of life by reducing the risk of unnecessary adverse events, and facilitates and speeds up the selection of more favourable alternative treatments. Furthermore, it reduces population healthcare costs by avoiding unbeneficial, toxic21 and expensive therapy among these individuals.

The biological mechanism behind the observed poorer clinical outcomes seen in individuals with low thymic health is most likely to be a reduction in the output of naive T cells. This is supported by our findings in the TRACERx cohort, in which we found that relative to patients with low thymic health, those with high thymic health had significantly higher levels of sjTRECs, a by-product of thymic T cell production that is considered to be a direct readout of thymic activity23. Moreover, we showed a correlation between higher thymic health and increased T cell diversity. A similar link between the state of the thymus and T cell diversity has been reported previously20,24. Our findings thus suggest that the state of the adaptive immune system is crucial for outcomes and that adaptive immune capacity is reflected in thymic characteristics.

Notably, thymic health was prognostic in patients with advanced NSCLC receiving immunotherapy, including those who had previously been treated with cytotoxic chemotherapy. Effect sizes were strongest in the first-line immunotherapy setting, with a consistent—although non-significant—trend towards thymic health and pretreatment interaction, suggesting that the association of thymic health with outcomes is particularly relevant before chemotherapy-induced immune suppression. Given previous evidence that chemotherapy can impair thymic function19,30, our results raise the possibility that maintaining thymic health could influence the long-term benefit derived from systemic cancer therapies. Of note, the persistence of prognostic value in pretreated patients receiving immunotherapy underscores the robustness of thymic health as a host immune-competence marker even in this subset of patients. Our results might have broader implications for personalized cancer treatment31. It has previously been shown that the balance between myeloid and lymphoid cells changes with age, favouring an innate immune response. Work in mice has shown that specific depletion of myeloid precursor stem cells can restore the balance between lymphoid and myeloid compartments and reinvigorate the immune system32. Similar results could potentially be obtained in humans using similar approaches, or through specific treatments aimed at restoring thymic function33. However, any such approach to manipulate the basic elements of the immune system will require rigorous preclinical trials.

Previous studies found that thymic involution—that is, a reduction in thymic health—was a driver of immunosenescence and increased disease risk in adults34,35,36. Attempts have been made to visually score thymic involution on CT scans by estimating the degree of fatty degeneration in the thymic bed, and although no outcome implications were reported, these studies found basic associative results that are consistent with our study, such as differences in thymic involution depending on sex, age and smoking status24,37,38. Conversely to our results, these studies estimated that most adults have a fully fatty degenerated thymus24,37, whereas we found significantly improved health outcomes in association with high and average thymic health, representing 75% of the examined pan-cancer population. This indicates that using an automated deep-learning approach allows for a more detailed thymic health assessment. Indeed, our findings of maintained thymic function in most adults are supported by our findings of positive associations with T cell output in the independent TRACERx cohort; by previously reported sustained T cell output in presumed fully fatty degenerated thymic glands24; and by mathematical modelling35. Consistent with our findings and our accompanying article39, lifestyle might be directly associated with thymic health, emphasizing the need for studies that address potential preventive or regenerative strategies34,40,41.

In our study, we investigated various cancer types across independent cohorts, comprising the real-world Harvard-NSCLC and Harvard-PAN cohorts for outcome analyis and the prospective observational TRACERx study for biological correlations. We provide robust evidence of a positive association between thymic health and outcomes in patients with various cancer types who were treated with immunotherapy, strongly suggesting that thymic health should be assessed for the stratification of patients for immunotherapy treatment. This has crucial implications beyond cancer and for current clinical practice; for example, in cardiothoracic surgery and radiation oncology, the thymus is currently not considered an essential organ, and could potentially be removed20 or included in high-dose irradiation fields. However, in both instances, the thymus might be preserved with minimal adjustments to current clinical practice. Our results, supported by those of others20, suggest that there may be benefits to preserving the thymus. However, further studies are required to define the specific clinical context in which this applies. We emphasize the importance of the thymus for adult health in our accompanying article39, in which we demonstrate the relevance of the thymus for long-term health and lifespan in more than 25,000 presumably healthy individuals.

One limitation of our study is that although the included patients encompass a wide age range for both sexes, they are predominantly white, and further testing in diverse ethnic populations is required. Before the thymic-health model can be applied in clinical settings, it is essential to prove generalizability across scanners, institutions, countries and populations. Given these limitations, the presented thymic-health analyses were done using population-specific thresholding, and no universal cut-offs can be assumed at this time. However, because the development and application of the thymic-health model were performed in fully independent datasets, with high robustness as demonstrated by test–retest stability, successful external validation is likely. The next steps will include international and external validation in diverse populations of people with cancer.

Although our study design, which did not include a matched non-immunotherapy comparator, prevents the direct assessment of the predictive implications of thymic health, our analysis is consistent across multiple cohorts and cancer types. However, further work in properly powered cohorts will be required to determine whether a patient’s thymic health could serve as an independent biomarker of immunotherapy response that is equal to established tumour-intrinsic biomarkers such as PD-L1 or TMB, and that extends to cancer types other than NSCLC. This argues strongly that thymic health is a functionally important and independent component of tumour-agnostic immunotherapy efficacy.

In summary, this study provides evidence of the previously unknown importance of the thymus for immuno-oncology. Together, our work, supported by that of others19,20,24,35,37, indicates that the state of the immune system is highly individualized, varies by age and sex and associates with survival following immunotherapy.

Most current biomarkers are cancer-type-specific and are commonly derived from tumour tissue. Conversely, thymic health is host-specific and measured independently of the tumour. At present, the thymus is not examined in routine clinical care, and no established clinical standards exist. Our approach is based on CT scans and provides fast, non-invasive and personalized assessments that can be applied widely across oncology. Our observations could provide a starting point for additional studies investigating the relevance of the thymus and the immune system in maintaining health in the face of cancer and other diseases. This might lead to a more holistic approach to personalized medicine in cancer, in which the overall health of the patient and the immune system are considered together with relevant tumour biomarkers to improve treatment outcomes.

Methods

Patient cohorts

Patients from the Harvard-NSCLC and Harvard-PAN cohorts were included for the application of thymic-health quantification (see Supplementary Fig. 6 for a flow chart of patient inclusion). Patients were eligible for inclusion if they were 18 years of age or older and had baseline chest CT imaging within three months before the start of immunotherapy. This resulted in a total of 3,476 eligible patients (Harvard-NSCLC, n = 1,218; Harvard-PAN, n = 2,258). Patients had NSCLC or cancers of different entities and were treated with immunotherapy at the Dana-Farber Harvard Cancer Center (DFHCC). Clinical and imaging data were obtained using the Mass General Brigham Research Patient Data Registry (RPDR), the Oncology Data Retrieval System (OncDRS) and Medical Imaging Data As A Service (MIDAS), and, for Harvard-NSCLC, additional manual chart reviews. Patient inclusion was retrospective, and all patients with cancer who consented and were treated with the US Food and Drug Administration (FDA)-approved ICIs atezolizumab, pembrolizumab, nivolumab, ipilimumab, durvalumab, avelumab, cemiplimab, relatlimab or dostarlimab were screened for study inclusion.

For external and biological validation, we analysed 464 treatment-naive and operable patients with stage I–IIIB NSCLC from the TRACERx study, where scans and complementary data were made available (Supplementary Fig. 5). The TRACERx22 study (‘Tracking non-small cell lung cancer evolution through therapy (Rx)’; ClinicalTrials.gov: NCT01888601) is an ongoing observational trial in NSCLC that began in 2014. Data collection takes place at several hospitals across the UK, and is overseen by the sponsors of the study (Cancer Research UK and UCL Cancer Trials Center). All participants provide written informed consent. Participants are followed for up to five years from the point of primary diagnosis, through surgical resection to cure, cancer progression(s) and death. In this paper, we use disease-free survival as an outcome measure—measured from the time of study registration to the date of first lung recurrence or death from any cause. Patients who do not have these events are censored at the date they were last known to be alive or after five years. The study protocol with inclusion and exclusion criteria has been published previously42. Further details about settings and participants are provided elsewhere27,43.

Patients from all datasets were imaged with thoracic CT with or without intravenous contrast and with hard or soft kernel reconstruction according to clinical or trial protocols, generating a diverse and heterogeneous dataset ideally suited for generalizable deep-learning model application.

Inclusion and ethics

This study was approved by the respective institutional review boards at the DFHCC (DFHCC-approved protocols; 13-055, 02-180, 17-000, 20-000 and 11-117). All patients provided written informed consent at study enrolment. The TRACERx study was approved by an independent research ethics committee (13/LO/1546).

Model development and application

We developed a deep-learning system that automatically extracts a thymic-health quantification ranging from zero (complete thymic decay with fatty involution) to one (no thymic decay) from a given CT scan that covers the thoracic region. A detailed description of the model development, including training data and architecture, can be found in Supplementary Methods section S1 and Supplementary Fig. 7. In short, the deep-learning system (1) identifies the thymus centre-of-mass through seed-point annotation; (2) uses self-supervised learning-based encoding of the thymic region to capture intrinsic information in the imaging data; and (3) uses supervised prediction of thymic health from representations learned through self-supervised learning. Model development was done in a completely independent collection of 5,674 CT scans covering the thoracic region. All patients analysed and reported in this study were defined as test sets and remained unseen until the fully independent and externally developed model was locked. A technical evaluation of the performance of the end-to-end deep-learning system can be found in Supplementary Methods section S2, Supplementary Figs. 817 and Supplementary Tables 711.

Biological validation in TRACERx

We acquired preoperative CT scans for 464 patients from the TRACERx cohort with matching clinical or biological data (Supplementary Fig. 5). Immune health was estimated using our deep-learning system. For biological analysis, we excluded patients with non-fat non-thymic-soft-tissue attenuation (such as fat stranding, oedema or scarring) in the thymic bed, because we assumed potential alteration of biological mechanisms among these patients19,34,44 (Supplementary Methods section 1.3). The abundance of sjTRECs was assessed from buffy-coat samples in a subset of 45 patients (25 with high thymic health and 20 with low thymic health). Buffy coat (100 µl) was isolated and DNA extracted using a modified protocol of the QIAGEN DNeasy Blood & Tissue Kit (69506, QIAGEN). In brief, samples were lysed with proteinase K and buffer AL, followed by ethanol precipitation and purification on QIAGEN spin columns, with elution in 50 µl EB buffer. DNA concentration was measured spectrophotometrically, and 600 ng DNA per reaction was used. For droplet digital PCR (ddPCR), DNA was pre-digested with HindIII (BioNordika) to linearize sjTREC molecules (20 min at 37 °C, enzyme inactivation at 80 °C for 10 min). sjTREC levels were quantified using primers from a previously published assay24: 5′-CACATCCCTTTCAACCATGCT-3′ (forward), 5′-GCCAGCTGCAGGGTTTAGG-3′ (reverse) and probe 5′-ACACCTCTGTTTTTGTAAAGGTGCCCACT-3′ (5′6-FAM, Iowa Black quencher). As a reference, the housekeeping gene RPP30 was amplified in parallel using forward primer 5′-AGATTTGGACCTGCGAGCG-3′, reverse primer 5′-GAGCGGCTGTCTCCACAAGT-3′ and probe 5′-TTCTGACCTGAAGGCTCTGCGCG-3′ (5′6-HEX, Iowa Black quencher). Each 20-µl reaction contained 10 µl ddPCR Supermix for Probes (no dUTP, Bio-Rad, 1863024), 1 µl sjTREC assay, 1 µl RPP30 assay and 8 µl digested DNA. Droplets were generated on a QX200 Automated Droplet Generator (Bio-Rad), sealed and amplified on a C1000 Touch Thermal Cycler (Bio-Rad) with the following cycling protocol: 95 °C for 10 min; 40 cycles of 94 °C for 30 s and 55 °C for 1 min (ramp rate 2 °C per s); 98 °C for 10 min; and hold at 12 °C. Plates were read on a QX200 Droplet Reader (Bio-Rad), and data were analysed using QuantaSoft and QX Manager software (Bio-Rad). All samples were run in triplicate. sjTREC abundance was normalized to RPP30 copy number, and results presented as the sjTREC/RPP30 ratio. TCR diversity was calculated on the basis of previously published TCR-sequencing data25. In short, TCR α- and β-chain sequencing were performed on whole RNA extracted from each tissue type: tumour tissue, adjacent normal lung tissue and cryopreserved peripheral blood mononuclear cell (PBMC) samples. TCR data were analysed in a tissue-specific manner and were not combined across tissues. Raw reads were processed using Decombinator45 to assemble TCR clones. Normalized Shannon diversity was calculated from productive TCR sequences using the formula: −1/log(N) × ∑((N, i = 1) pi × log (pi)), where N is the total number of TCRs in a sample and pi is the frequency of TCR i. Median TCR diversity was used for patients with multiple tumour regions available. For TCR analysis, we included an additional patient (CRUK0291) with TCR-sequencing data and a CT scan available, who was excluded from clinical follow-up owing to incomplete resection. Blood and tumour T cell fractions were calculated from available whole-exome sequencing (WES) data using T cell ExTRECT, as described previously26. In brief, T cell ExTRECT estimates the fraction of T cells in a WES sample by quantifying the amount of TCR excision at the TCRA locus, on the basis of the drop in read depth at this site. For blood T cell fraction, samples with a fraction of 0 were considered to be technical artefacts and excluded from the analysis (n = 31). In tumour samples, the T cell fraction was adjusted based on TCRA copy number and purity. Median T cell fraction was used for patients with multiple tumour regions available. Olink Explore 3072 proteomics data, measuring the relative plasma concentration of a panel of proteins in blood plasma samples, were available for 108 patients as part of a previous publication27. Proteins associated with thymic health were found by calculating Spearman’s rank correlation coefficients (P values from algorithm AS 89, two-sided) between our thymic-health score and the relative plasma concentration of proteins across all patients, using the rstatix package (v.0.7.2). To ensure accurate correlation estimates, we excluded proteins with Normalized Protein eXpression (NPX) levels below the limit of detection in more than 20% of patients, resulting in 2,743 included proteins.

Pathway enrichment analysis was performed on the basis of REACTOME46 pathway gene sets (v.78, from MSigDB v7.5.1). UniProt IDs were mapped to ENTREZ IDs using org.Hs.eg.db (v.3.14.0) To use a panel-specific null hypothesis, pathways were filtered to only include proteins that were included in the filtered Olink Explore 3072 panel. Enrichment score was calculated using the clusterProfiler package (v.4.2.0), using pathways that included at least ten genes. Protein–protein interactions were determined using the STRING protein–protein association database (v.12.028), using the STRING web-based user interface (https://string-db.org/), with an interaction confidence threshold of 400. The five most closely related proteins were added by using the ‘add more proteins to your network’ functionality once. Enrichment analysis used the STRINGdb package (v.2.6.0), with proteins from the filtered Olink panel as background.

Statistical analysis

To facilitate thymic-health interpretation, the raw thymic-health values were calibrated across the study population by applying matched-percentile ranking. This transformed the raw thymic-health values to a range from 0 to 100, matching the individual distribution rank; that is, a patient with a calibrated thymic-health value of 50 would be found in the median of the patient population distribution. Furthermore, to facilitate potential clinical translation, we categorized thymic health into low, average and high, based on the first and third population quartiles; that is, patients with calibrated thymic health ≤25, 25–75 and >75 were categorized as low, average and high thymic health, respectively. Summary statistics for continuous variables used the mean, median or range; categorical variables were summarized as proportions or percentages. PFS was determined from the start date of immunotherapy until the date of disease progression or death. OS was determined from the start date of immunotherapy until the date of death. If patients were alive at the last contact, they were censored accordingly. The follow-up was truncated at five years. Associations were computed using Wilcoxon rank-sum tests and linear regression as appropriate. Time-to-event distributions used the Kaplan–Meier estimator, and Cox proportional hazards models were used to calculate estimates of hazard ratios in univariate and multivariate modelling. The Schoenfeld residuals were assessed, and the proportional hazards assumptions were met. P values are two-sided, the level of significance was pre-defined at <0.05 and CIs are at the level of 95%. No statistical methods were used to predetermine sample size. Statistical analyses were performed using R v.4.2.2 (R Project for Statistical Computing).

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.