Hematoxylin and eosin (H&E) staining is the most widely used method to view the microscopic details of cells and tissues, allowing pathologists to identify abnormal patterns on a patient’s cells and diagnose disease. While this tried-and-true technique is fast and inexpensive, trained pathologists are needed to interpret the slides, and this approach only reveals physical properties. To fully explore and decode the cellular ecosystem inside a tumor, pathologists require costly molecular testing, creating a bottleneck that can rarely scale to the millions of slides analyzed in research studies.
Stanford Cancer Institute member Zinaida Good, PhD, assistant professor of medicine, and Jure Leskovec, PhD, the Alfred and Rebecca Lin Professor of computer science, have developed a tool that helps to unlock the slides’ hidden molecular secrets. In a study published this summer, Good and Leskovec introduced SpatialWhisperer, an artificial intelligence (AI) framework that uses H&E-stained images to predict cell types, such as T cells, tumor cells, or fat cells, making routine pathology more informative and accessible to all cancer researchers.
“Pathologists are trained to read these slides, and they are very good at it,” Good explained. “But most cancer researchers are not pathologists. We wanted to make the biology in H&E slides accessible to scientists who are not trained to read them. Down the road, a tool like this could help pathologists as well, whether in teaching or in everyday decision support.”
The study was led by Moritz Schaefer, PhD, a postdoctoral fellow co-mentored by Good and Leskovec, and published at the International Conference on Machine Learning.
The purple and pink problem
H&E slides combine two dyes that stain cellular components based on their chemical properties. This approach is inexpensive because specialized technology is not required.
At the opposite end of the technological spectrum is RNA sequencing. This method acts like a molecular barcode scanner to read a cell’s active genes and assign precise cell types. While public databases hold millions of these RNA sequencing profiles, relying on pathologists to select tissue samples and guide the overall workflow, the technique requires grinding tissue into a fluid, destroying the sample’s physical layout and, in turn, erasing all records of where those cells actually lived. A newer method called spatial transcriptomics solves this problem by measuring gene expression in intact tissue samples and mapping molecular data directly onto microscope images. However, it remains prohibitively expensive and labor-intensive.
The gap between accessibility and affordability set up the question that Good and her team wanted to answer. “Can we use the molecular measurements we do have to teach an AI to recognize more of that biology in the slides we already have?” Good asked.
Connecting the dots
The team’s answer is a strategy they call “transitive representation learning.” It is a machine learning technique that connects two types of data without corresponding direct measurements by using a shared data source. Essentially, the shared data source translates one type of data into the other. Normally, an AI model couldn’t accurately predict cell types straight from H&E slides because there is no source of truth labeling the slides with cell types for the model to use. However, there is a dataset connecting H&E slides to gene expression and a separate dataset linking gene expression to cell types.
SpatialWhisperer gets around the lack of data linking H&E slides to cell types by using gene expression as the middleman to predict cell types. The model used two different datasets: spatial transcriptomics data from 921,000 H&E-stained tissue samples, each paired with its gene activity profile, and RNA-sequencing data from 1.8 million gene activity profiles, each matched with its cell type.
The two collections never shared a single specimen, but because both speak the language of gene expression, SpatialWhisperer learned to connect the data types, allowing researchers to look at a basic H&E slide and predict which cell types are present without running expensive RNA sequencing tests every time.
SpatialWhisperer grew out of a collaboration spanning cancer immunology, computer science, and genomics. Schaefer, who led the project, works between Good’s cancer immunology lab and Leskovec’s computer science group. He previously conceived and developed CellWhisperer, an AI tool that lets researchers explore gene expression data. That tool’s name inspired this one, and the million-plus pairs of gene expression profiles and text descriptions assembled for it became one of SpatialWhisperer’s two training sets.
Prompting the pathology
Traditionally, creating training data for AI models requires pathologists to manually mark up individual tissue slides by drawing boundaries and labeling where distinct cell types are located, which is a massive, time-consuming endeavor.
By entering the cell type into the model, SpatialWhisperer can pinpoint the location of all cells of that type on a standard H&E slide. For example, even though no pathologist has ever manually labeled T cells on tissue images for the model to train on, SpatialWhisperer can still find all T cells on a slide.
“You can just type in what you are looking for,” Good explained. “By using gene expression as an intermediate data type, the approach lets you ask the model to show you T cells or tumor cells, and it highlights those areas directly on the slide.”
Across three independent benchmark collections spanning 19 tissue types, SpatialWhisperer recognized cell types more accurately than existing AI models trained to analyze visual data or pathology information, improving on the best of them by 13.9 to 15.9 percent.
“Traditionally, if we want an AI system to recognize something new, we need thousands of examples labeled specifically for that task,” Good said. “In pathology, creating those labels requires scarce expert time or extensive laboratory studies. Our approach shows that we can instead connect knowledge that already exists in different scientific datasets. A molecular atlas created for one purpose can help teach an AI to interpret pathology images collected for another.”
Access for all
Good, who also directs the Stanford Center for Cancer Cell Therapy Data Hub, is currently putting SpatialWhisperer to work in her research on cancer immunotherapies. Her team is analyzing tissue samples from a large group of patients who received CAR-T cell therapies for large B-cell lymphoma. CAR-T cell therapy genetically engineers a patient’s own immune cells to seek out and kill cancer cells. It can be remarkably effective, but outcomes vary, and some patients relapse.
By mapping where immune cells sit relative to tumor and stromal cells on standard H&E biopsy slides, the team hopes to identify tissue patterns that help explain why the treatment works for some patients but not others.
“For our research program focused on T cell therapies, we are now applying SpatialWhisperer to a large cohort of samples from patients who received CAR-T cell therapies,” she explained. “We can now understand those tumor microenvironments in much greater depth and detail. It allows us to bring insights from large molecular datasets we have generated to samples where we could never run those experiments.”
The team has publicly released the trained SpatialWhisperer model and its code, allowing researchers to explore the cellular makeup of other diseases and build on the work.
“Our goal was to democratize access to pathology data interpretation across science.”
“Our goal was to democratize access to pathology data interpretation across science,” she explained.
Good emphasizes that SpatialWhisperer is a research tool, not a diagnostic one. It has not been validated for clinical decision-making and is not intended for use in diagnosis or treatment. It also works better for some cell types than others. Fat cells, for instance, are hard to find because they contain little of the genetic material that gene expression measurements detect. Broader testing across tissues and patient populations is still needed. Still, by lowering the technical and financial barriers to detailed tissue analysis, SpatialWhisperer could help close the gap between intensive molecular biology and everyday cancer research.
“The larger vision is to connect two worlds that have largely developed separately: the vast archives of tissue that pathologists have collected for decades, and the increasingly detailed molecular maps produced by modern biology,” Good said. “If we can connect them reliably, every ordinary pathology slide becomes a potentially much richer source of biological information.”
The research was supported by the National Institutes of Health, the Stanford Center for Digital Health, the Laude Institute, the Parker Institute for Cancer Immunotherapy, the Weill Cancer Hub West, the National Science Foundation, the Stanford Data Science Applications Initiative, the Wu Tsai Neurosciences Institute, the Stanford Institute for Human-Centered AI, Amazon, Genentech, SAP, SCBX, and the Cancer Research Institute. Co-authors from Stanford, Genentech, the CISPA Helmholtz Center for Information Security in Germany, and Vienna contributed to the study.