Transformer-Based Representation Learning for Robust Gene Expression Modeling and Cancer Prognosis

Shuai Jiang, Saeed HassanpourarXiv 2025 · OpenReview

Abstract

Transformer-based models have achieved remarkable success in natural language and vision tasks, but their application to gene expression analysis remains limited due to data sparsity, high dimensionality, and missing values. We present GexBERT, a transformer-based autoencoder framework for robust representation learning of gene expression data. GexBERT learns context-aware gene embeddings by pretraining on large-scale transcriptomic profiles with a masking and restoration objective that captures co-expression relationships among thousands of genes. We evaluate GexBERT across three critical tasks in cancer research: pan-cancer classification, cancer-specific survival prediction, and missing value imputation. GexBERT achieves state-of-the-art classification accuracy from limited gene subsets, improves survival prediction by restoring expression of prognostic anchor genes, and outperforms conventional imputation methods under high missingness. Furthermore, its attention-based interpretability reveals biologically meaningful gene patterns across cancer types. These findings demonstrate the utility of GexBERT as a scalable and effective tool for gene expression modeling, with translational potential in settings where gene coverage is limited or incomplete.

Introduction

Analyzing gene expression data (RNA-seq) is a cornerstone of modern oncology, yet it presents a significant "curse of dimensionality." A single patient sample typically contains expression levels for over 20,000 genes, while clinical datasets often suffer from small sample sizes and high sparsity due to technical or cost constraints. Traditional machine learning approaches, such as PCA or manual feature selection, often fail to capture the intricate, non-linear relationships between genes.

GexBERT addresses these challenges by applying the "BERT" philosophy to transcriptomics. By learning the complex "language" of gene co-expression through large-scale pretraining on cancer data, GexBERT achieves state-of-the-art results in cancer classification and survival prediction while demonstrating remarkable robustness to missing data.

Methodology

GexBERT is designed as a transformer-based autoencoder that treats genes as "words" within a genomic context. To adapt the transformer architecture to continuous transcriptomic data, several key innovations were implemented:

  1. Discretization and Embedding: Continuous expression values are binned into 64 categorical levels. Each gene is assigned a unique embedding, which is combined with an embedding representing its specific expression level.
  2. Random Sampling: To handle the high dimensionality of the genome (20,000+ genes), the model randomly samples subsets (e.g., 512 genes) during training iterations. This allows the model to learn global representations without exceeding hardware memory limits.
  3. Self-Supervised Pretraining: Following the BERT paradigm, GexBERT is trained to "fill in the blanks." It encodes a subset of genes into a summary "class" ($cls$) token and utilizes a decoder to restore the expression values of masked or missing genes.
  4. Downstream Tasks: The pretrained $cls$ token serves as a robust feature for classification, while the decoder can be used to impute missing values, thereby enhancing survival models.
The GexBERT framework: (a) Pretraining via masking, (b) Cancer classification, (c) Survival prediction using restored anchor genes, and (d) Missing value imputation.

Experimental Results

The model was evaluated using data from The Cancer Genome Atlas (TCGA), encompassing 33 cancer types and over 11,000 patients.

Pan-Cancer Classification

GexBERT consistently outperformed PCA-based benchmarks. Even when restricted to a small subset of 64 genes, the model achieved a classification accuracy of 0.940, surpassing standard neural networks (0.928).

Survival Prediction and Imputation

A unique capability of GexBERT is the restoration of "prognostic anchor genes." By inferring the values of unmeasured markers from the context of other genes, the model improved the Concordance Index (C-index) for survival prediction by up to 1.7%. Furthermore, in scenarios where up to 50% of data was missing, GexBERT maintained superior predictive performance compared to traditional imputation methods like KNN or MICE.

Discussion and Biological Interpretability

The success of GexBERT suggests that genes, much like words in a sentence, possess "context." The model's internal attention mechanism identifies genes with high variability or extreme expression levels—markers that are biologically significant for cancer subtyping.

Despite its performance, challenges remain regarding data uniformity across different sequencing platforms and the nature of missing data in clinical settings. Future work aims to integrate multi-omics data, such as DNA methylation and proteomics, to provide a more holistic biological representation.

Summary updated

BibTeX
@misc{jiang2025transformer,
  author = {Shuai Jiang and Saeed Hassanpour},
  title = {{Transformer-Based Representation Learning for Robust Gene Expression Modeling and Cancer Prognosis}},
  year = {2025},
  eprint = {2504.09704},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.09704},
}
Figure