Abstract Multiple sclerosis (MS) is a prevalent neurological disorder with a complex etiology, often associated with thyroid function. However, the causal relationship between these two conditions remains poorly understood. This study aimed to elucidate the causal relationship between thyroid function and MS using a bidirectional Mendelian randomization (MR) approach and to investigate the potential mediating role of immune cells. We conducted a two-sample MR analysis using summary statistics from large-scale genome-wide association studies (GWAS). We included results from sensitivity tests such as MR-Egger, weighted median, and leave-one-out analyses to support the robustness and reliability of the findings. The inverse variance-weighted (IVW) method was the primary approach, with sensitivity analyses conducted using seven additional MR methods. Furthermore, multivariable MR and mediation analysis were conducted to uncover potential mediating immune cells underlying the observed associations. The MR analysis showed that Hypothyroidism and elevated Thyroid-Stimulating Hormone (TSH) levels(normal) reduced the risk of MS (P = 0.012, OR (95%CI) :0.914(0.851, 0.98); P = 0.020, OR (95%CI) :0.88(0.789, 0.98)). Free thyroxine (FT4) increased the risk of MS (P = 0.020, OR (95%CI) :1.268(1.051, 1.53)). Mediation analysis showed evidence of indirect effect of FT4 on MS through “HLA DR on CD33br HLA DR + CD14” and “IgD- CD27- %B cell” with a mediated proportion of 39.16% (positive effect), 78.53% (reverse effect) of the total effect. This study provided genetic evidence that FT4 may increase the risk of developing MS. “HLA DR on CD33br HLA DR + CD14” and “IgD- CD27- %B cell”, mediated the causal relationship between thyroid function and MS, highlighting the importance of further investigating their roles in these conditions. Supplementary Information The online version contains supplementary material available at 10.1038/s41598-025-89888-z. Keywords: Thyroid function, Multiple sclerosis, Mendelian randomization, Immune cells, Mediation analysis Subject terms: Multiple sclerosis, Autoimmunity Introduction Multiple sclerosis (MS) is an autoimmune disorder of the central nervous system (CNS), characterized by inflammatory demyelination and axonal degeneration^[30]1. MS is a widespread neurological disease with varying prevalence across different regions and countries, and it brings about increasing healthcare demands and costs^[31]2–[32]4. The etiology of MS is multifactorial, involving genetic susceptibility as well as environmental factors^[33]5. Early studies demonstrated the role of T cells in the development of inflammation and demyelination in MS. Recent research has found the possibility that B cells play a pathogenic role by regulating T cells^[34]6. MS is frequently comorbid with autoimmune diseases, particularly thyroid disorders, which underscores the need to clarify their interplay^[35]7. Thyroid hormones are crucial factors regulating neuroglia generation, with their roles spanning multiple aspects such as cell proliferation, determination, differentiation, and cell death^[36]8. Additionally, Thyroid hormones play a crucial role in myelin formation, a process perturbed in MS^[37]9. However, it remains unclear whether there is a causal relationship between thyroid function and MS, as previous observational studies may be subject to selection bias, reverse causality, and residual confounding. TSH, as a key hormone regulating thyroid function, its synthesis and secretion are strictly regulated by the hypothalamic-pituitary-thyroid axis. In recent years, with the continuous development of GWAS, more and more genetic loci have been discovered to be associated with TSH levels^[38]10. To address this gap, we conducted a bidirectional Mendelian randomization (MR) study leveraging large-scale GWAS data. MR is an emerging method that leverages the advancements in large-scale GWAS to explore potential causal relationships. MR draws upon Mendel’s genetic laws, including the laws of segregation and independent assortment^[39]11. By using genetic variants as instrumental variables (IVs), this method can establish potential causal relationships between variables^[40]12. It circumvents the drawbacks of traditional methods. MR leverages the principle of random allocation of alleles at conception, thereby mimicking the randomization process of a randomized controlled trials (RCTs)^[41]13. By using genetic variants as IVs, we reduce confounding and the likelihood of reverse causation. Given the logistical and ethical challenges associated with large-scale RCTs on thyroid diseases and MS, MR provides a practical and robust alternative for inferring causality, offering valuable insight into disease mechanisms and potential therapeutic targets. Our primary objective was to elucidate the causal relationship between thyroid function and MS, with a focus on TSH, FT4, and hypothyroidism as exposures, and MS as the outcome. Furthermore, to explore the potential mediating role of immune cells in this relationship, we used the Multivariable Mendelian Randomization (MVMR) method. This study provided genetic evidence using IVs to investigate the causal relationship between thyroid function and MS. Methods Research design and data sources The data on hypothyroidism were sourced from FinnGen R9 ([42]https://r9.finngen.fi/), encompassing 40,926 cases and 274,069 controls^[43]14. Details of the data sources and basic information were provided in Supplementary file 2: Table [44]S1. The data on thyroid function levels within the normal range were derived from a large-scale meta-analysis of GWAS targeting thyroid function. This study tested up to 8 million genetic variants across as many as 72,167 individuals, revealing a total of 109 independent genetic variants associated with these traits^[45]15. The data on overall TSH levels were obtained from a meta-analysis of GWAS involving up to 119,715 individuals and 22.4 million genetic markers. This analysis identified 74 significant genome-wide TSH loci^[46]16. The MS data were sourced from a GWAS study that analyzed a total of 32,367 MS cases and 36,012 controls across Australia, 10 European countries, and multiple states in the United States^[47]17. The study utilized a mixed linear model for association analysis implemented in GCTA, incorporating genotype principal components of common variants, chip type, and gender as covariates in the association analysis. Inverse variance-weighted(IVW) meta-analysis was employed to merge statistical data across layers. This research identified four novel SNPs that may influence MS risk independently of shared genetic signals. The aggregated summary statistics for 731 immune cell phenotype GWAS datasets were obtained from the GWAS catalog (IDs ranging from GCST0001391 to GCST0002121)^[48]18. Immune cell phenotypes encompassed absolute cell (AC) counts (n = 118), median fluorescence intensity (MFI) reflecting surface antigen levels (n = 389), morphological parameters [MP] (n = 32), and relative cell (RC) counts (n = 192). MFI, AC, and RC features included B cells, CDCs, T cell maturation stages, monocytes, bone marrow cells, TBNK, and Treg panels. MP features comprised CDC and TBNK panels. The immune trait GWAS was conducted on 3,757 Europeans, with covariates including sex, age, and age squared. Approximately 22 million SNPs genotyped using high-density arrays were estimated using a reference panel based on the Sardinian sequence. IV selection criteria To ensure the validity of our analysis, we conducted quality control on the SNPs, including the removal of non-biallelic SNPs, SNPs with ambiguous strand alleles, SNPs lacking reference SNP ID number (rsID), duplicated rsID or base pair positions, SNPs not in the Phase 3 of the 1000 Genomes Project, SNPs with base pair positions or alleles mismatching with those in phase 3 of the 1000 Genomes Project, SNPs with imputation information score<0.9, and all SNPs on chromosomes X and Y. The number of selected IVs for FT4 (normal) is 23, for Hypothyroidism is 116, for TSH (normal) is 40, and for TSH (total) is 75. Standard MR assessed the causal effect of a single exposure on an outcome, whereas Multivariable Mendelian Randomization (MVMR) allowed for simultaneous adjustment of multiple exposures, enabling the isolation of the independent causal effect of each exposure. This distinction led to differences in the selection of IVs: in standard MR, IVs were selected solely based on their association with the primary exposure, while in MVMR, IVs could be shared across exposures or specific to one exposure. Statistical analysis We employed the clumping procedure in the PLINK software to filter out all significantly associated genetic loci with the phenotype as IVs (P < 5 × 10^^−8), with an r^2<0.001 and a window size of 10,000 kb. Some SNPs that were directly associated with the outcomes (P < 5 × 10^^−8) were excluded in the MR analysis to ensure the validity of the results. The number of index SNPs was 23 for FT4 (normal), 116 for Hypothyroidism, 40 for TSH (normal), 75 for TSH (total), and 74 for MS. For genetic variants to serve as valid IVs, it requires that IVs meet three assumptions:^[49]1 IVs should be associated with the exposure;^[50]2 IVs should not be associated with confounding factors related to both the exposure and the outcome;^[51]3 the effect of IVs on the outcome is entirely mediated through the exposure^[52]19,[53]20. When these assumptions hold, IVW is the most powerful method for MR. However, if certain instruments violate the IV assumptions, MR analysis may yield erroneous results. We conducted several sensitivity analyses. Firstly, the Q-test of IVW and MR-Egger was used, which allowed the detection of potential violations of assumption by assessing the heterogeneity across individual instrumental variables^[54]21. Secondly, MR-Egger was applied to estimate horizontal pleiotropy based on its intercept, ensuring that genetic variants were independently associated with the exposure and outcome. Additional analyses using MR methods with different modeling assumptions and strengths (weighted median and mode) were employed to enhance the stability and robustness of the results^[55]22. Thirdly, MR-PRESSO was used to detect outliers and correct for horizontal pleiotropy^[56]23. Fourthly, single SNP analysis and leave-one-out analysis were conducted to evaluate the possibility of individual SNPs driving the observed associations. Multivariable mendelian randomization (MVMR) MVMR analysis further excluded potential horizontal pleiotropy. MVMR analysis utilized the IVW method to assess whether the association between multiple exposures and outcome risk was primarily influenced by other potential confounders. Effects of other traits were incorporated into the linear model based on the following formula, and instrumental variables present in all three datasets were retained: Inline graphic Here, Inline graphic represented the marginal effect size of the instrument, σ^2 denoted the variance of the residual term, Inline graphic signified the causal effect of exposure 1 on the outcome, and Inline graphic represented the causal effect of exposure 2 on the outcome. Subsequently, MVMR analysis was conducted to estimate the causal effects of multiple exposure factors on the outcome after adjusting for confounding factors. Mediation mendelian randomization To explore the potential mediating role of immune cells in this relationship, we employed the Multivariable Mendelian Randomization (MVMR) method. This mediation effect estimation and hypothesis testing were performed in a multivariate MR Framework using aggregated association statistics of thyroid markers, immune cells, and MS^[57]24–[58]26. We employed the IVW method to estimate the causal effect of thyroid indicators on 731 immune cell phenotypes and conducted MVMR analysis to assess the causal impact of immune cells on MS (adjusting for causal thyroid indicators). To estimate the mediation effect, we applied the Bootstrap method, which was widely used for assessing the significance of indirect effects in mediation analyses. Specifically, we tested the null hypothesis (H0) that the product of the indirect path coefficients a and b equaled zero (H0: ab = 0). Here, a represented the effect of the exposure on the mediator, while b represented the effect of the mediator on the outcome, adjusted for the exposure. The Bootstrap approach involved resampling the data with replacement to create numerous pseudo-samples, from which the distribution of the product ab was derived. This allowed for the computation of confidence intervals and significance testing of the mediation effect without assuming normality of the sampling distribution^[59]27,[60]28. Enrichment analysis of immune cell-related genes To further explore the significant immune cell-related SNPs identified in the Mendelian Randomization analysis, we conducted gene mapping and functional annotation using FUMA (Functional Mapping and Annotation) ([61]https://fuma.ctglab.nl/) and Metascape ([62]https://metascape.org/) tools. Lead SNPs associated with significant immune cell traits were mapped to their corresponding genes based on positional and expression quantitative trait locus (eQTL) annotations, with a focus on regulatory variants. Functional annotation included an assessment of the expression patterns of mapped genes across various tissues, particularly those relevant to the immune and CNS. Gene expression profiles were evaluated to identify potential tissue-specific roles using data from GTEx ([63]https://www.gtexportal.org/) and other publicly available datasets. We also performed pathway enrichment and protein-protein interaction (PPI) analyses to identify biological processes and molecular interactions associated with the mapped genes. Pathway enrichment was conducted using Metascape, incorporating Gene Ontology (GO)^[64]29, Kyoto Encyclopedia of Genes and Genomes (KEGG)^[65]30–[66]32, and Reactome databases, while PPI networks were constructed to highlight key functional hubs and potential gene interactions underlying the immune cell-mediated effects on MS. The statistical analyses were conducted in R version 4.4.1 software. MR analysis was performed using the MendelianRandomization package^[67]33, while MR-PRESSO utilized the MRPRESSO package. Result First, a bidirectional causal association assessment was conducted. IVs are detailed in Supplementary file 2: Tables [68]S1 and [69]S2. Hypothyroidism and elevated TSH levels reduced the risk of MS, while increased FT4 levels increased the risk of MS. Patients with MS had an increased risk of hypothyroidism and elevated TSH levels, but MS did not significantly affect FT4 levels (Fig. [70]1). The reference line indicated protective factors on the left and risk factors on the right. Fig. 1. [71]Fig. 1 [72]Open in a new tab The forest plot for the causal relationship between thyroid function and MS. Left, MS was the outcome; Right, MS was the exposure. The causal effect of thyroid function on MS The causal association determined by the IVW method was robust to other MR methods (Fig. [73]2 and Supplementary file 2: Table [74]S4), demonstrating the stability of the association. The intercept term of MR-Egger method ruled out potential horizontal pleiotropy. Hypothyroidism and elevated TSH levels(normal) reduced the risk of MS (P = 0.012, OR (95%CI) :0.914(0.851, 0.98); P = 0.020, OR (95%CI) :0.88(0.789, 0.98)). FT4 increased the risk of MS (P = 0.020, OR (95%CI) :1.268(1.051, 1.53)). Fig. 2. [75]Fig. 2 [76]Open in a new tab The forest plot for the sensitivity analysis of the causal relationship between thyroid function and MS. However, hypothyroidism and TSH failed to pass the MR-PRESSO global test, indicating potential horizontal pleiotropy between the two indicators. Only the relationship between FT4 and MS was a stable causal relationship. Both scatter plots and funnel plots excluded potential outliers and horizontal pleiotropy, further supporting the robustness of the study results (Fig. [77]3). LOOCV was shown in Supplementary file 2: Table [78]S5. Fig. 3. [79]Fig. 3 [80]Open in a new tab (A) Scatter plot of the causal effect of hypothyroidism on MS; (B) FT4 on MS; (C) TSH (normal) on MS; (D) TSH (total) on MS; (E) Funnel plot of the causal effect of hypothyroidism on MS; (F) FT4 on MS; (G) TSH (normal) on MS; (H) TSH (total) on MS. The causal effect of MS on thyroid function MS reduced the risk of Hypothyroidism, TSH levels(normal) and TSH (total) (P = 5.67E-06, OR (95%CI): 0.043 (0.025, 0.062); P = 0.019, OR (95%CI): 0.016 (0.003, 0.03); P = 0.002, OR (95%CI): 0.015 (0.005, 0.025)). However, MS did not significantly affect FT4 levels (P = 0.990, OR (95% CI): 0 (-0.013, 0.013)). The reverse causal association also passed the majority of sensitivity analyses (Fig. [81]4 and Supplementary file 2: Table [82]S7); While TSH (normal) and TSH (total) did not pass the MR-Egger test, the causal association of MS with hypothyroidism also failed to pass the global test of MR-PRESSO. Furthermore, scatter plots and funnel plots excluded the possibility of potential outliers for the identified causal associations (Fig. [83]5). LOOCV was shown in Supplementary file 2: Table [84]S8. Fig. 4. [85]Fig. 4 [86]Open in a new tab The forest plot illustrated sensitivity analyses of the causal effect of MS on thyroid function. Fig. 5. [87]Fig. 5 [88]Open in a new tab (A) Scatter plot of the causal effect of MS on hypothyroidism; (B) MS on FT4; (C) MS on TSH (normal); (D) MS on TSH (total); (E) Funnel plot of the causal effect of MS on hypothyroidism; (F) MS on FT4; (G) MS on TSH (normal); (H) MS on TSH (total). MVMR analysis We conducted MVMR analysis to correct for potential pleiotropic effects among nominally significant thyroid function and MS. The results were as follows (Fig. [89]6 and Supplementary file 2: Table [90]S6). Fig. 6. [91]Fig. 6 [92]Open in a new tab MVMR analysis for the causal effect of thyroid function on MS. Mediation mendelian randomization We conducted comprehensive mediation analyses with thyroid function as the exposure variable, immune cells as mediators, and MS as the outcome variable. The results demonstrated that various immune cells could serve as intermediate factors mediating the causal association between thyroid function and MS (Table [93]1; Fig. [94]7). Further detailed results are presented in Supplementary file 2: Tables [95]S9–[96]S12. Additionally, comprehensive mediation analyses were performed with MS as the exposure variable, immune cells as mediators, and thyroid function as the outcome variable. The results indicated that various immune cells could act as intermediate factors mediating the causal association between MS and thyroid function (Table [97]1; Fig. [98]7). Additional detailed results can be found in Supplementary file 2: Tables [99]S13–[100]S16. Table 1. Mediation analysis of immune cell subsets as mediating factors. Trait pairs Mediators Total effect Direct effect Indirect effect Proportion (%) Beta (95% CI) Beta (95% CI) Beta (95% CI) FT4 (normal)-MS HLA DR on CD33br HLA DR + CD14- 0.063 (− 0.094, 0.22) 0.244 (− 0.584, 1.073) − 00.05 (− 0.113, − 0.004) 78.53 FT4 (normal)-MS IgD- CD27- %B cell 0.063 (− 0.094, 0.22) 0.014 (− 0.178, 0.207) 0.025 (0.001, 0.057) 39.16 Hypothyroidism-MS HLA DR on CD33br HLA DR + CD14- − 0.135 (− 0.243, − 0.028) − 0.162 (− 0.413, 0.09) − 0.017 (− 0.038, − 0.001) 12.48 Hypothyroidism-MS IgD- CD27- %B cell − 0.135 (− 0.243, − 0.028) − 0.117 (− 0.223, − 0.012) − 0.013 (− 0.033, − 0.001) 9.80 TSH (normal)-MS CD38 on IgD + CD38dim − 0.115 (− 0.263, 0.033) − 0.126 (− 0.249, − 0.002) 0.012 (0, 0.028) 10.11 MS-Hypothyroidism HLA DR on DC 0.047 (0.01, 0.084) 0.047 (0.025, 0.069) − 0.018 (− 0.033, − 0.007) 38.17 MS-Hypothyroidism CD28 on CD45RA + CD4+ 0.047 (0.01, 0.084) − 0.021 (− 0.052, 0.011) 0.007 (0.001, 0.015) 14.94 MS-Hypothyroidism HLA DR on myeloid DC 0.047 (0.01, 0.084) − 0.001 (− 0.026, 0.024) − 0.004 (− 0.009, − 0.001) 9.21 MS-Hypothyroidism CD28 on resting Treg 0.047 (0.01, 0.084) 0.041 (0.009, 0.072) 0.006 (0, 0.013) 12.86 MS-TSH (normal) CD19 on IgD- CD27- 0.003 (− 0.008, 0.015) 0.001 (− 0.01, 0.013) 0.002 (0, 0.004) 56.67 MS-TSH (normal) CD19 on IgD- CD24- 0.003 (− 0.008, 0.015) 0.002 (− 0.009, 0.013) 0.001 (0, 0.004) 41.68 MS-TSH (total) CD19 on IgD- CD24- 0.007 (− 0.003, 0.017) 0.005 (− 0.004, 0.014) 0.001 (0, 0.003) 15.48 MS-TSH (total) CD19 on IgD- CD27- 0.007 (− 0.003, 0.017) 0.006 (− 0.004, 0.015) 0.001 (0, 0.003) 16.86 MS-TSH (normal) CD19 on IgD + CD38dim 0.003 (− 0.008, 0.015) 0.002 (− 0.011, 0.014) 0.001 (0, 0.003) 37.53 MS-TSH (normal) CD28 + CD45RA + CD8dim %CD8dim 0.003 (− 0.008, 0.015) 0.003 (− 0.008, 0.015) 0.001 (0, 0.002) 25.94 MS-TSH (normal) CD19 on sw mem 0.003 (− 0.008, 0.015) 0.002 (− 0.01, 0.014) 0.001 (0, 0.003) 38.07 MS-TSH (normal) Activated & resting Treg %CD4+ 0.003 (− 0.008, 0.015) − 0.002 (− 0.013, 0.01) − 0.001 (− 0.003, 0) 32.50 MS-TSH (normal) CD33 on CD33br HLA DR + CD14- 0.003 (− 0.008, 0.015) 0.004 (− 0.008, 0.015) − 0.001 (− 0.002, 0) 20.45 MS-TSH (normal) TD CD8br %CD8br 0.003 (− 0.008, 0.015) 0.004 (− 0.008, 0.015) − 0.001 (− 0.002, 0) 28.25 [101]Open in a new tab Fig. 7. [102]Fig. 7 [103]Open in a new tab The immune cell subgroups that mediated the causal association between thyroid indicators and MS. We conducted a comprehensive mediation analysis utilizing immune cells as mediators. As depicted in Fig. [104]7, several immune cell subsets emerged as significant contributors to the observed causal associations. Key immune cells, such as CD27, CD28, CD19, CD33, and CD4, played pivotal roles in the association between thyroid function and MS. Specifically, our mediation analysis showed that “HLA DR on CD33br HLA DR + CD14-” and “IgD- CD27- %B cell” were key mediators of the effects of FT4 and hypothyroidism on MS risk. For FT4, a positive mediating effect of 39.16% was observed through “HLA DR on CD33br HLA DR + CD14-”, suggesting that elevated FT4 levels may increase MS risk via this immune cell pathway. Conversely, FT4 exerted a reverse mediating effect of 78.53% through “IgD- CD27- %B cell”, indicating a potential protective role of this B cell subset against MS in the context of altered FT4 levels. Enrichment analysis of immune cell-related genes Supplementary file 1: Fig. [105]S1 depicted the expression profile of immune cell-related genes, providing a comprehensive view of their activities across 54 common tissues. It highlighted the specific expression patterns of these genes in tissues, with particular attention to those associated with the immune system and the CNS (Supplementary file 1: Fig. [106]S1). Supplementary file 1: Fig. [107]S2 presented the results of pathway enrichment analysis. The figure displayed a network of enriched pathways. The main roles of the pathway primarily included “positive regulation of the immune system”, “regulation of lymphocyte proliferation”, and “antigen processing and presentation” (Supplementary file 1: Fig. [108]S2). Supplementary file 1: Fig. [109]S3 exhibited the PPI network constructed for immune cell-related genes. Nodes represented proteins encoded by the identified genes, and edges denoted physical interactions between them. Prominent hub proteins in the network had high interaction counts with other proteins (Supplementary file 1: Fig. [110]S3). Discussion In the present large-scale MR study, we used a bidirectional MR method and leveraged large-scale GWAS data to explore the causal relationship between thyroid function and MS, as well as to conduct a detailed analysis of the mediating role of immune cells in this relationship. MS is a chronic disease of the CNS, believed to be immune-mediated. It has been reported that there is an association between thyroid function and the prevalence and incidence of MS^[111]34. The association between autoimmune thyroid diseases and other autoimmune diseases emphasizes potential shared pathogenic mechanisms among these conditions^[112]35. Although the association between the two has been confirmed by multiple epidemiological studies, the causality and directionality have remained unclear. Our study showed that FT4 may be associated with an increased risk of developing MS. Patients with thyroiditis exhibit a significant increase in the incidence of MS^[113]36. Thyroid hormones are crucial for normal myelin formation, and they play an important role in regulating neurogenesis in the adult mammalian brain^[114]37. Elevated FT4 levels may disrupt normal myelin maintenance, thereby contributing to the onset of MS. It has been reported that normalizing thyroid hormone levels can reverse CNS symptoms, suggesting a direct causal relationship between altered thyroid hormone levels and CNS symptoms. Autoimmune reactions against antigens present in the thyroid may spread to the central nervous system^[115]38. The prevalence of thyroid diseases has increased among patients with MS and their relatives. Henderson et al. suggested that clinicians should examine patients who have not undergone recent thyroid function testing but present with unspecified symptoms to ascertain if they have thyroid dysfunction^[116]39. Our research emphasized the importance of monitoring FT4 levels in assessing the risk of MS. Early detection of FT4 abnormalities and the implementation of intervention measures may contribute to reducing the risk of developing MS. Further studies are warranted to delve deeper into the specific mechanisms by which FT4 influences MS, particularly its regulatory role on immune function and its potential to promote the development of MS. Hypothyroidism caused by autoimmune thyroid disease is more severe and more common in MS patients^[117]40. Unfortunately, definitive results were not obtained in the Mendelian validation of the causal relationship between hypothyroidism and TSH factors with MS, and further research is needed to confirm this. We recognized that the effect of FT4 was no longer significant in our multivariable MR model after adjusting for TSH and hypothyroidism. Once FT4, hypothyroidism, and TSH were considered together in the multivariable model, the previously significant association for FT4 became attenuated, with its 95% CI crossing the reference line. This indicated that the apparent effect of FT4 might have been partly explained by overlapping genetic influences or mediation through TSH, underscoring the complex interplay among these thyroid-related traits in MS risk. According to our results, TSH and hypothyroidism can decrease the risk of MS, while MS can increase the level of TSH and the risk of hypothyroidism. These results likely reflected differences in the direction and magnitude of causal effects in the bidirectional MR framework, possibly due to shared genetic pathways or pleiotropy. The observed associations could have been explained by the complex interactions between the immune and endocrine systems. Hypothyroidism and elevated TSH levels might have exerted immunosuppressive effects, potentially dampening autoimmune responses, including those involved in MS pathogenesis. The pathophysiology of MS appears to involve aberrant immune activation, leading to neuroinflammation involving both peripheral immune cells and resident cells of the central nervous system such as microglia and astrocytes^[118]41. Large-scale studies have uncovered multiple independent genetic variations that elevate the risk of MS. These variations are likely to play a functional role in the pathogenesis of MS, involving both adaptive and innate immune cells. Moreover, some of these MS-associated variations also mediate the risk of developing other autoimmune diseases^[119]42. We conducted gene enrichment analysis on genes identified through instrumental variable mapping and found that human leukocyte antigen (HLA)-related genes played an important role in the mediating effect between thyroid function and MS. Pathway analysis revealed that the major pathways of mediator immune cell-related genes in 54 tissues primarily included “positive regulation of the immune system”, “regulation of lymphocyte proliferation” and “antigen processing and presentation”. The effects of thyroid hormones are mainly mediated by thyroid-stimulating hormone receptor (TSHR)^[120]43. HLA-DR3 has a high affinity for the immunodominant peptide of the TSHR, which may have affected the binding and presentation of TSHR peptides, thereby influencing the regulation of thyroid function^[121]44. This is consistent with our findings. Among all the genetic factors associated with MS susceptibility, the association between the HLA and MS is the strongest^[122]45. Although the direct role of HLA alleles in MS has been confirmed, it is still difficult to understand the role of HLA-DQ alleles in the disease pathogenesis due to strong linkage disequilibrium^[123]46. Concerning the immune cell-mediated effects, we identified key immune cells such as CD27, CD28, CD19, CD33, and CD4 as pivotal players in the thyroid function-MS association. Specifically, “HLA DR on CD33br HLA DR + CD14-” and “IgD- CD27- %B cell” are identified as the primary mediators influencing the risk of MS associated with FT4 and hypothyroidism. FT4 exerts a 39.16% positive mediating effect on MS through “HLA DR on CD33br HLA DR + CD14”, while it has a 78.53% negative mediating effect through “IgD- CD27- %B cell”. In previous literature descriptions, localized infiltration of T lymphocytes and macrophages and death of oligodendrocytes, resulting in multiple small foci of inflammation, are the primary cause of myelin destruction, leading to the formation of lesions of inflammatory cells and their products, demyelination, and broken axons in the CNS^[124]47. This laterally confirms that variations in FT4 levels may regulate the risk of MS by affecting the activity and function of specific immune cell subsets. CD27 is associated with T-cell activation and memory cells, and research suggests that soluble CD27 in the cerebrospinal fluid serves as a biomarker to aid in the detection of early MS^[125]48. In our mediation analysis, FT4 mediated the protective effect of IgD- CD27- %B cells on the occurrence of MS, which is consistent with the conclusion of this literature. Many other studies have also emphasized the important role of other immune cells in the occurrence of MS. Research on both human MS and rodent models suggests that CD28 blockade can serve as a therapeutic approach for treating autoimmune demyelination^[126]49. MS is considered to be an autoimmune disease triggered by CD4 T cells, associated with specific Th cells targeting myelin antigens^[127]50. Monoclonal antibodies targeting CD20 and CD19 hold potential advantages in MS therapy^[128]51. The neuroinflammatory protein CD33 is situated at the core of neuroinflammatory events associated with various neurodegenerative diseases and is linked to several neurodegenerative conditions, including MS^[129]52. These cells encompass diverse functions related to T-cell activation, B-cell function, and neuroinflammation, all intimately linked to the immunopathogenesis of MS. Our study not only provides genetic evidence for the causal relationship between thyroid function and MS through mediation analysis but also deeply reveals the key roles of specific immune cells in this process. These findings offer a new perspective for understanding the complex connection between thyroid diseases and autoimmune diseases and provide potential targets for future therapeutic interventions against these diseases. Future investigations should explore how these immune cells modulate MS onset and progression in the context of thyroid dysfunction, and how targeting these cells could lead to innovative MS interventions. This study exhibits several notable methodological strengths. It employs a bidirectional two-sample MR design based on GWAS data, which is a robust approach for investigating causal relationships. Furthermore, the study incorporates mediation MR analysis, enhancing its ability to unravel the underlying mechanisms. By utilizing various MR techniques, the study minimizes confounding factors and reduces bias in causal estimation, thereby ensuring the reliability of its findings. The application of MR methods in this study provides genetic evidence of a causal association between FT4 and MS. Notably, the study highlights the significant roles of specific immune cells, namely “HLA DR on CD33br HLA DR + CD14” and “IgD- CD27- %B cell”, in this causal relationship. Sensitivity analyses do not reveal heterogeneity, confirming the validity and robustness of the study’s findings. This underscores the importance of these immune cells in the pathogenesis of MS and suggests potential targets for future therapeutic interventions. However, there are also limitations to consider. Firstly, the majority of GWAS data originate from European populations, thus caution is warranted when extrapolating the results to other ethnic groups. Secondly, as mentioned earlier, thyroid function and MS are influenced by a combination of genetic variation and environmental factors, indicating that the study’s findings can only partially elucidate the causal impact of thyroid function on MS. Our bidirectional MR framework provides valuable initial insights, but the interpretation of binary exposures for complex traits such as hypothyroidism and MS must be approached with caution, as this approach may obscure underlying continuous or polygenic processes^[130]53. Future studies employing more refined phenotypic definitions or continuous indicators may better capture the nuances of how thyroid function influences MS risk. Conclusion We have presented novel evidence suggesting that FT4 may serve as a causal determinant for the risk of developing MS. Furthermore, our findings reveal that specific immune cells, namely “HLA DR on CD33br HLA DR + CD14” and “IgD- CD27- %B cell”, play pivotal roles in both thyroid function and MS pathogenesis. These research outcomes imply an intricate interplay between MS and thyroid function, underscoring the necessity for further investigation to elucidate potential shared mechanisms underlying these two conditions. Electronic supplementary material Below is the link to the electronic supplementary material. [131]Supplementary Material 1^ (4.2MB, zip) [132]Supplementary Material 2^ (1.2MB, xlsx) Author contributions Y.R. and W.W. conceptualized the study, curated the data, and reviewed and edited the manuscript. X.W. handled the software and wrote the original draft. Z.W. contributed to the conceptualization, methodology, and reviewed and edited the manuscript. All authors reviewed the manuscript. Funding None. Data availability The data utilized in this paper were obtained from publicly available databases that comply with ethical standards and legal requirements. The data of this study can be found in the article or supplementary materials. To obtain the raw data from this study, please contact the corresponding author directly. Declarations Competing interests The authors declare no competing interests. Ethical approval The data used in this paper were sourced from publicly accessible databases that adhere to ethical norms and legal regulations. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Yinghao Ren and Xin Wang have contributed equally to this work and share first authorship. Contributor Information Weiliang Wang, Email: 983044268@qq.com. Zeyu Wang, Email: 850350243@qq.com. References