Multimodal AI model for early detection of hepatocellular carcinoma

Multimodal AI model for early detection of hepatocellular carcinoma

Patients and H&E images

The internal cohort of this study was from Zhongshan Hospital Fudan University (ZS; Shanghai, China) and contained H&E slides of patients diagnosed with eHCC or DN between 2017 and 2023. These slides were reviewed by at least two senior pathologists specializing in liver diseases and supplemented with clinical information and immunohistochemistry (IHC) examination of proteins such as Ki67, HSP70, GS, and GPC3. eHCC is clearly defined as HCC in the early stage of malignancy (generally ≤2 cm), which is usually sparsely vascularized, irregularly bordered, and contains portal elements on diagnostic imaging, but has no significant impact on the original architecture of the liver3. HGDN is characterized by hepatocellular hyperplasia with atypical cytological and/or architectural features that are insufficient for diagnosis of HCC. HGDN shows higher cellularity and often exhibits small cell changes31.

These slides were reviewed by at least two senior pathologists specializing in liver diseases, and IHC examination of multiple proteins was performed when necessary. All H&E slides confirmed as eHCC or HGDN were retained and scanned using Aperiod AT2 (500 nm/px) or Nano Zoomer S360 (220 nm/px) digital slide scanners. Because most HCC patients were in advanced stages at the time of diagnosis, only 112 high-quality slides from 75 patients in the ZS were included in the study, resulting in the generation of 73,891 tiles (Supplementary Table S1). In addition, 7 eHCC or HGDN slides from 6 patients from Huashan Hospital Fudan University (HS; Shanghai, China) were included as independent external datasets, resulting in the generation of 3430 tiles (Supplementary table S1).

All patients provided informed consent. The use of clinical samples and all procedures were approved by the Zhongshan Hospital Fudan University Research Ethics Committee (B2024-340) and Huashan Hospital Fudan University Research Ethics Committee (2017M-003). The study conformed to the principles of the Helsinki Declaration.

Each H&E image was loaded and tiled into non-overlapping tiles of 512 × 512 μm (corresponding to 1024 px for Aperiod AT2 and 2327 px for Nano Zoomer S360) using openslide (v1.1.2). The background or blank images were deleted according to the intensity of the RGB channels, and only the tiles containing more than 80% tissue pixels were retained for analysis. Pathologists annotated the images using Qupath32. We extracted the coordinates from the annotation files using XML in Python (v3.9.16), shapely (v2.0.1) and geojson (v3.0.1).

Design of TMC-net

TMC-net is a novel two-stage, multi-scale convolutional network designed to emulate the diagnostic workflow of pathologists. In clinical practice, pathologists first assess overall morphological patterns at low magnification before conducting a detailed examination of localized regions at higher magnification. TMC-net replicates this process by incorporating two different magnification levels as input data for each tile33.

Specifically, the tile at 20× magnification is denoted as \({X}_{0}\), and used to input into the Low-resolution convolutional neural network (CNN) to extract global features. While the corresponding tile at 40× magnification is subdivided into four sub-regions: upper-left, upper-right, lower-left, and lower-right, denoted as \({X}_{1},{X}_{2},{X}_{3}\) and \({X}_{4}\), and input into the high-resolution CNN to extract detailed features.

Specifically, a tile at 20× magnification, denoted as \({X}_{0}\), serves as input to the Low-resolution CNN to extract global features. In parallel, the corresponding tile at 40× magnification is subdivided into four sub-regions: upper-left, upper-right, lower-left, and lower-right, denoted as \({X}_{1},{X}_{2},{X}_{3}\), and \({X}_{4}\). These subregions are processed by the high-resolution CNN to extract fine-grained features.

The multi-scale architecture of TMC-net is built upon ResNet18, where both low-resolution features (\({W}_{0}\)) and high-resolution features (\({W}_{1},{W}_{2},{W}_{3},{W}_{4}\)) are learned through multi-layer CNNs. These high-resolution representations are subsequently concatenated with the global representation \({W}_{0}\), and the final prediction \(\hat{y}\) is generated using a multilayer perceptron (MLP) applied to the concatenated feature vector. The entire network is trained in an end-to-end manner, ensuring the joint optimization of all layers. The mathematical formulation of the model is as follows:

$${W}_{0}={{CNN}}_{{low}-{resolution}}({X}_{0}),$$

(1)

$${W}_{l}={{CNN}}_{{high}-{resolution}}\left({X}_{l}\right),\,l=1,2,3,4$$

(2)

$$\hat{y}={MLP}([{W}_{0};{W}_{1};{W}_{2};{W}_{3};{W}_{4}])$$

(3)

In order to explore the most suitable input data feature type for early liver cancer diagnosis, this study evaluated the impact of multi-scale features under different field of view sizes on model performance, including 256 μm, 512 μm and 1024 μm. The original tile was first scaled to 448 × 448 px and cut into four parts to obtain a 224 × 224 px high-power field of view image. All field of view images are eventually scaled to 224 × 224 px input model.

To assess the contributions of the multi-scale CNN and the two-stage framework, we conducted ablation studies under various network configurations. The baseline model TMC-net, which integrates both the multi-scale CNN and two-stage modeling, is denoted as “TwoStage_MultiScale”. Variations of the model were constructed as follows:

1.

“TwoStage_SingleScale”—This variant retains the two-stage framework but replaces the multi-scale CNN with a single-scale CNN that processes only 20× magnification images.

2.

“OneStage_MultiScale”—This variant preserves the multi-scale CNN but adopts a one-stage modeling framework, directly classifying regions as non-critical areas, HGDN, or eHCC, without a candidate region extraction step.

3.

“OneStage_SingleScale”—This model, representing the most conventional approach, employs a single-scale CNN within a one-stage framework.

Other histopathological feature extraction methods

The proposed TMC-net was compared with 1) lightweight CNN, 2) the pathology foundation model and 3) the machine learning model based on traditional cell-level features.

1) We replace the basic ResNet18 neural network in TMC-net with a lightweight CNN SqueezeNet to evaluate the performance of the model with a smaller number of parameters. Because SqueezeNet performs poorly, ‘TMC-net’ reported in the Results are all ResNet18 neural networks (Supplementary Table S4).

2) The PLIP model is a multimodal pathology-based basic model based on contrastive learning, which has been trained on OpenPath. The PLIP image encoder has been shown to be the preferred pre-trained backbone for various pathology image classification tasks. Therefore, this study used the PLIP image encoder to extract the feature representation of small tiles in 512 dimensions, and we trained two commonly used machine learning classifiers (logistic regression and random forest) for the classification of other non-critical regions, HGDN and eHCC.

3) Cell density ratio and cellular atypia index are two common quantifiable cellular features. In each annotated region on each WSI image, we randomly selected 100 tiles, and if there were less than 100 tiles, we selected all of them. The previously published cell segmentation classification network34 was used to segment epithelial cells on these tiles. For nuclear density, it was defined as the number of cells divided by the area. For the morphology atypia35, the score of epithelial cells in tile i was defined as \({s}_{i}\). Then the cell morphology heterogeneity score at the WSI level is defined as \(\max \left({s}_{i}\right)\).

$${s}_{i}={SD}\left(\frac{{p}_{{cj}}}{2\sqrt{\pi {a}_{{cj}}}}\right),\,j\in \left\{1,\ldots ,\,n\right\},$$

(4)

where SD is the standard deviation function, \({p}_{{cj}}\) is the perimeter of the nucleus of the jth epithelial cell, \({a}_{{cj}}\) is the nuclear area of the jth epithelial cell, and n is the total number of epithelial cells on tile i. These features were input into logistic regression to obtain tile-level prediction results.

Aggregation of classifications from the tile level to the slide level

To obtain the slide-level prediction, the output from the models (such as TMC-net and the above-mentioned multiple logistic regression classifiers) was further integrated. Specifically, the predicted labels (HGDN, eHCC or others) of all tiles and the corresponding probabilities were used to calculate the statistical features of each WSI. Each WSI is represented by a 34-dimensional feature vector \(Z\). These features include: the frequency of each label category (e.g., the number of tiles with HGDN), the proportion of each label category (e.g., the proportion of tiles with HGDN), the predicted probability distribution of each label category (e.g., mean, standard deviation, and quantile). The full list of features is shown in Supplementary Table S2.

To diagnose at the WSI level, we built a support vector machine (SVM) classifier based on the statistical features of tiles to predict whether the WSI is HGDN or eHCC. Specifically, SVM outputs the prediction of the WSI based on the 34-dimensional feature vector Z.

$$Y={SVM}\left(Z\right)$$

(5)

Model training and evaluation

In TMC-net, we implemented two neural networks: one for candidate lesion region extraction and another for eHCC detection, both based on multi-scale CNN architectures. The Resnet18 network was initialized with the best set of parameters obtained from training on the ImageNet dataset. To enable the networks to learn pathology-specific features, all layers were unfrozen during training. Each network was trained for 50 epochs on an Nvidia 4090 Ti GPU, with a batch size of 128. The cross-entropy loss function was used, and the Adam optimizer was employed with a learning rate of 5 × 10⁻⁶, a first-order moment estimate decay rate of 0.9, and a second-order moment estimate decay rate of 0.999. To enhance the diversity of the training data, random vertical, horizontal flips and random rotations were applied. The deep learning models were trained using PyTorch (v1.13.1), while scikit-learn (v1.3.2) was utilized for training machine learning models and evaluating.

All tile images were processed through the candidate lesion region extraction network, with a threshold of 0.5. Tiles with a probability greater than 0.5 were classified as candidate regions, while others were deemed irrelevant. The candidate region tiles were subsequently input into the eHCC detection network, which also employed a 0.5 threshold. Tiles with a probability greater than 0.5 were classified as eHCC, and the others were HGDN.

The models were evaluated using the following methods: Tile-level performance was evaluated on the internal validation dataset using LOOCV. Slide-level performance was evaluated not only on the internal validation set, but also on the internal test set and an independent external test set. Evaluation metrics used included AUROC, accuracy, and F1 score. The LOOCV process was repeated 10 times, and we report the average performance of each method along with 95% confidence intervals.

Model interpretability by saliency maps

The Grad-CAM++ class activation maps (CAMs) are generated by visualizing the weighted gradients flowing into the final convolutional layer of the network (referred to as the feature layer \(A\)). Since the feature maps of the final convolutional layer contain high-level semantic information, and spatial information is lost in the subsequent fully connected layers, this layer is chosen as the optimal feature layer for visualization. Compared to the traditional CAM, Grad-CAM25 does not require modifications to the network or retraining, making it more convenient to use. Grad-CAM++ improves upon Grad-CAM by not only considering positive gradients but also incorporating additional weight factors to more precisely reflect the contribution of each pixel to the class prediction.

Based on the fundamental assumption that the prediction score \({Y}^{c}\) for class \(c\) is a linear combination of the globally averaged feature maps \({A}^{k}\) of the feature layer:

$${Y}^{c}=\mathop{\sum }\limits_{k}\,{w}_{k}^{c}.\mathop{\sum }\limits_{i}\,\mathop{\sum }\limits_{j}\,{A}_{{ij}}^{k}.$$

(6)

In Grad-CAM++, the weight \({w}_{k}^{c}\) is a weighted average designed to capture the importance of the feature map \({A}^{k}\):

$${w}_{k}^{c}=\mathop{\sum}\limits_{i}\,\mathop{\sum}\limits_{j}{\alpha }_{{ij}}^{{kc}}\cdot {relu}(\frac{\partial {Y}^{c}}{\partial {A}_{{ij}}^{k}})$$

(7)

where \(\frac{\partial {Y}^{c}}{\partial {A}^{k}}\) represents the gradient of class \(c\) with respect to the \(k\)-th channel of the feature layer \(A\). The weight \({\alpha }^{{kc}}\) is the importance of each pixel in the \(k\)-th channel of feature layer \(A\), derived from the second-order partial derivatives:

$${\alpha }_{{ij}}^{{kc}}=\frac{\frac{{\partial }^{2}{Y}^{c}}{{(\partial {A}_{{ij}}^{k})}^{2}}}{2\frac{{\partial }^{2}{Y}^{c}}{{(\partial {A}_{{ij}}^{k})}^{2}}+\mathop{\sum }\nolimits_{a}\,\mathop{\sum}\nolimits_{b}\,{A}_{{ab}}^{k}\{\frac{{\partial }^{3}{Y}^{c}}{{(\partial {A}_{{ij}}^{k})}^{3}}\}}$$

(8)

Thus, the saliency map for an image \(L\) can be computed as a linear combination of the feature maps:

$${L}_{{ij}}^{c}={relu}\left(\mathop{\sum}\limits_{k}\,{w}_{k}^{c}\cdot {A}_{{ij}}^{k}\right)$$

(9)

Differential expression and functional analysis of the transcriptome

The RNA-seq data were obtained from a collaborative study (Z.Z., H.L., L.C., Y.J. and L.H., unpublished data). The count data included 60 samples from the ZS cohort and 26 samples from the HS cohort, comprising a total of 36 eHCC tissues, 34 HGDN tissues, and 16 surrounding liver tissues. To address potential batch effects associated with differences in sequencing time, we applied the combat_seq() function from the sva package (v3.38) for batch correction, with the sample groups (HGDN, eHCC, and control tissue of the surrounding liver) set as the holdout parameter. We confirmed the effectiveness of batch removal using PCA and proceeded with the corrected expression profiles for downstream modeling.

Differential expression analysis was conducted using DESeq2 (v1.30) on the count data. The DEGs between all groups were compared as one-to-other. For the DEGs and functional pathways of HGDN and eHCC, only the two were compared. Genes were considered significantly differentially expressed if they had an adjusted p-value < 0.05 (Wald test, false discovery rate method). The gene sets were sourced from the public MSigDB database, including Hallmark gene sets and KEGG pathways, and analyzed using the ClusterProfiler (v4.0.5) package.

Screening of potential gene markers

Given the effectiveness of XGBoost in handling high-dimensional expression data, its ability to capture non-linear relationships between gene expression values, and its robustness to noise and outliers, we employed an XGBoost machine learning model to analyze the internal dataset. Within the ensemble learning framework, each base estimator (i.e., the XGBoost model) independently computed feature importance using the “estimator.feature_importances_” attribute. During the modeling process, the internal cohort was split into 80% training and 20% testing sets. The model was trained on the training data, and feature importance scores were calculated. This data partitioning and model training were performed 10 times randomly. The importance scores obtained each time were summed to obtain a combined feature importance ranking. The top 10 genes with the highest cumulative importance scores were selected as potential transcriptome biomarkers.

In the model building and evaluation stages, the same data split method was used. Evaluation metrics used included AUROC, accuracy, and F1 score.

Combining images with different numbers of genes

The model construction pipeline is illustrated in Fig. 6A and includes four parts: feature combination, hyperparameter tuning, model refitting, and model evaluation.

The cohort was split into train cohort (80%) and test cohort (20%) for the classification task. The normalized features were concatenated together. We extracted a 34-dimensional feature vector for each WSI from the TMC-net. In the process of integrating RNA expression profiles, we added one gene at a time according to the order of importance score from high to low. This process generated 11 logistic regression models based on different feature combinations: 34-dimensional pathology features, pathology and top 1 gene, pathology and top 2 genes, …, pathology and all top 10 genes. All models followed the same machine learning training and evaluation framework. To balance the calculation burden and the model accuracy, we used the randomized search cross-validation strategy to search the optimal hyperparameter, setting the roc_auc as the scoring function and fivefold cross- validation. In the model refitting and model evaluation phases, to evaluate the model performance, we randomly re-split cohort and refit the model for 10 times, and evaluate the AUROC, balanced accuracy, F1, precision, and recall on the test cohort. The machine learning pipeline was built in Python (v3.9.15) using the following libraries: scikit-learn (v1.2.0), numpy (v1.24.1), scipy (v1.9.3), and pandas (v1.5.2).

Baseline model based on IHC markers

The genes corresponding to GS, AFP, GPC3, and HSP70 proteins are GLUL, AFP, GPC3, HSPA2/HSPA1A/HSPE1. Among them, GLUL, AFP, GPC3, and HSPA2 showed significant differential expression between the eHCC and HGDN groups, so they were combined with the image features extracted by TMC-net to establish a multimodal baseline model.

In addition, considering the impact of post-transcriptional regulation, we also collected the positive or negative information of these proteins in the samples of bimodal cohort. Under the guidance of pathology experts, we considered the possibility of HCC to be high when two or more of these protein markers were positive. Based on this criterion, a simple logistic classifier was established as another baseline model.

Association between histopathological features and gene expression

To identify histopathological features associated with gene expression, we computed histopathological features for samples from the TCGA-LIHC cohort. First, H&E tissue images were tiled into 512 μm. These tiles were then fed into the previously published TSFD-Net model34 to perform cell segmentation and classification. The centroids of cells labeled as malignant epithelial cells were extracted. For each tile, if the proportion of malignant epithelial cells exceeded 80%, the tile was considered to represent a tumor region. histopathological feature computation was then performed only within these tumor regions. Using the centroids of malignant epithelial cells, we performed affinity propagation clustering (using the sklearn.cluster module, v0.24.1) and constructed Delaunay plots (using the scipy.spatial module, v1.9.3). In addition, we computed the morphological heterogeneity of nuclei based on the segmented nuclear contours (using numpy, v1.24.1).

For patients with multiple H&E slides, the computed H&E features were averaged to obtain a representative set of features for each patient. In total, features of 358 patient slides were successfully calculated. These normalized H&E features were then subjected to Pearson correlation analysis with gene expression data using the scipy.stats module (v1.6.1) to determine the association between histopathological patterns and expression of key genes.

Survival analysis

Considering that integrating H&E features with AARS2, ARHGEF11, RABEPK, and ATP6V0A2 can detect eHCC well, we further explored the association between these four genes and prognosis, including 1) individual gene, 2) the combination of the four key genes, and 3) the multimodal feature values. These analyses were performed by the TCGA-LIHC dataset. The H&E images, RNA expression clinical data were downloaded from cBioPortal. Samples with missing values are deleted.

1) The effect of individual genes on survival was analyzed using the Cox Proportional Hazards Model.

2) For the gene combination, considering that integrating H&E signature with AARS2, ARHGEF11, RABEPK and ATP6V0A2 can detect eHCC well, we defined a risk score for these four genes36:

$${Risk}\,{Score}=\mathop{\sum }\limits_{i=1}^{3}{\beta }_{i}* {{Exp}}_{i}{,}$$

(10)

where Exp is the expression level of each gene, and β is its regression coefficient obtained from the single-variate Cox model. The TCGA-LIHC patients were divided into high-risk and low-risk groups based on the median risk score. The overall survival rates in the two groups were compared using Kaplan‒Meier curves and log-rank tests in the R package survminer and survival.

3) For the multimodal feature, we extracted “predicted HCC area ratio” from TMC-net based on H&E images. If a patient has multiple slides, choose the one with the larger value. Similarly, we defined a risk score for “predicted HCC area ratio” (β = 1), AARS2, ARHGEF11, RABEPK, and ATP6V0A2 expression using the same approach and performed survival analysis.