# GraphEPN: A Deep Learning Framework for B-Cell Epitope Prediction Leveraging Graph Neural Networks
## 2 Materials and Methods
### Model Architecture
#### 2.3.3 Graph Attention-Based Epitope Prediction Module  
In the downstream task of epitope prediction, the pre-trained VQ-VAE model is utilized, with its encoder and codebook parameters remaining fixed. On the new dataset, the pre-trained VQ-VAE model encodes and quantizes the protein graph to generate each node's feature representation \(z\) and quantized representation \(e\). These nodes are concatenated to form the final node feature \(\mathrm{h}_{i}=[z_{i};\mathrm{e}_{i}]\), which is further processed via a graph transformer model to capture the complex relationships between residues (Figure 1c). For each layer, the model updates each node's representation by combining the node features \(\mathrm{h}_{i}\) and edge features \(\mathrm{e}_{ij}\) through a multi-head graph attention network (GAT) mechanism [20]:  
\[\mathrm{h}_{i}^{\prime}=\mathrm{h}_{i}+\sum_{j\in\mathcal{N}(i)}\alpha_{ij} \mathrm{Wh}_{j} \tag{13}\]where \(\text{h}_{i}^{\prime}\) is the updated feature of node \(i\), W is a trainable weight matrix, and \(\alpha_{ij}\) is the attention coefficient, which is calculated as follows:  
\[\alpha_{ij}=\frac{\exp\bigl{(}\text{LeakyReLU}\bigl{(}a^{\top}\bigl{[}\text{ Wh}_{i}\|\text{Wh}_{j}\|\text{e}_{ij}\bigr{]}\bigr{)}\bigr{)}}{\sum\limits_{k\in \mathcal{N}(i)}\exp\bigl{(}\text{LeakyReLU}\bigl{(}a^{\top}\bigl{[}\text{Wh}_{ i}\|\text{Wh}_{k}\|\text{e}_{ik}\bigr{]}\bigr{)}\bigr{)}} \tag{14}\]  
GAT dynamically assigns attention coefficients to each neighboring residue, allowing the model to focus on the most informative ones. By incorporating edge features, which encode spatial relationships between residues, the model effectively captures structural dependencies, enhancing epitope prediction accuracy.  
Using multihead attention mechanisms, the model independently calculates the relationships between nodes in different subspaces. The graph transformer is composed of multiple stacked transformer layers, each consisting of a multi-head GAT mechanism, residual connections, and normalization layers. The output of each layer is combined with its input through residual connections and enhanced by layer normalization to improve training stability. Finally, the model's output layer uses a linear transformation followed by a sigmoid activation function to produce the prediction probability \(\hat{y}_{i}\) for each node being an epitope:  
\[\hat{y}_{i}=\sigma(\text{W}_{out}\text{h}_{i}) \tag{15}\]  
where \(\text{W}_{out}\) is a trainable weight matrix, and where \(\hat{y}_{i}\) is the predicted probability of node \(i\) being an epitope.  
To improve the model's adaptability to imbalanced data, we introduce binary cross-entropy loss and Dice loss as the loss function. The use of Dice loss enhances the model's performance by emphasizing the prediction of the minority class, which in this case are the epitope residues. The final loss function is as follows:  
\[\mathcal{L}_{total}=\mathcal{L}_{BCE}+\mathcal{L}_{Dice} \tag{16}\]  
By jointly optimizing these two loss functions, the graph transformer model effectively captures both local and global information in protein structures, achieving superior performance in epitope prediction tasks.