An Introduction to Shapley Values in Biology
CGSI Tutorial 2026
Readings: 1, 2, 3; Source; Colab: 1, 2
CGSI Motivation
On Friday, Prof. Na Cai described an approach to making EHR-based GWAS more reliable (Di and Cai 2026). A part of the method used a multilayer perceptron model, EDGAR, to predict deep phenotypes from EHR codes. This is Supplementary Figure 7.
At CGSI 2024, Prof. Christina Leslie presented SCARlink (Mitra et al. 2024), a model to predict gene expression from chromatin accessibility data, which can be used to identify cell-type specific enhancers. This is from their introduction:
Moreover, we can use Shapley values, a well-known feature attribution method, to identify cell-type-specific enhancers, that is, genomic tiles that are important for predicting expression across cells from a given cluster or annotation. Therefore, although SCARlink is formulated as a gene expression prediction problem, we can use the learned model parameters to infer enhancer–gene links in a cell-type-specific manner.
So, what exactly are Shapley values???
Setup
Goal. Given a model \(f\) and a sample \(x \in \reals^{D}\), return a local feature attribution \(\varphi_d\left(x\right)\) that quantifies the contribution of feature \(d\) to the prediction \(f\left(x\right)\).
Requirements.
Local feature attributions. Unlike global variable importances, \(\varphi_d\left(x\right)\) are specific to sample \(x\). This matters a stakeholder cares specifically about particular prediction \(f(x)\) and wants an explanation for it.
Model agnostic. Attributions should be computable by querying \(f\) alone, without any assumptions about what kind of model it is – it could be a black box.
Principled. The attribution measure should be derivable from a clear set of mathematical axioms.
Approach. SHAP values satisfy all three requirements. This handout focuses on their theory (Section 1), computation (Section 2), and software (Section 3).
Conceptual Foundation
Local Feature Attributions
High-stakes decisions. When an individual is given a medical diagnosis, knowing the globally most important features isn’t enough. They deserve an explanation specific to their case.
- A related use case is algorithmic recourse. What could a stakeholder change to reverse a decision? (e.g., are there any lifestyle changes that might help delay disease symptoms?)
Model debugging. A model might classify a radiograph \(x\) as COVID-19 positive because it has the watermark of a hospital with disproportionately many COVID-19 patients (DeGrave et al. 2021). This means the model has learned a “shortcut” and won’t generalize well – a patient with the disease but scanned with a different machine would get misclassified.
Game Theory Definitions
SHAP is motivated by the credit assignment problem from game theory. Imagine agents \(\mathcal{D} = \{1, \dots, D\}\) where any subset \(S\) earns profit \(v(S)\). How much of the total profit \(v(\mathcal{D})\) should agent \(d\) receive? This share is the Shapley value \(\varphi_{d}(v)\).
Intuitively, agent \(d\)’s contribution depends on how much they add to each team \(S\). Define the marginal contributions of agent \(d\) to team \(S\) as, \[C\left(d \vert S\right) = v(S \cup \{d\}) - v(S)\]
The Shapley value is a weighted average of these marginal contributions across all subsets \(S \subseteq{\mathcal{D} - \{d\}}\) excluding agent \(d\),
\[ \varphi_d(v) = \sum_{S \subseteq \mathcal{D} - \{d\}} \frac{1}{D {D - 1 \choose \left|S\right|}} C(d \vert S) \tag{1}\] The summation is over all subsets that don’t include agent \(\{d\}\) (if it had included agent \(d\), then the definition of the contribution \(C(d \vert S)\) of \(d\) to \(S\) wouldn’t make sense).
Exercise: Express the following in terms of \(v\). Which of these could appear in the definition of the Shapley value?
- \(C(1 \vert 2)\)
- \(C(1 \vert \emptyset)\)
- \(C(1 \vert 1)\)
- \(C(3 \vert \{1, 2\})\)
- \(C(\{1, 2\} \vert 3)\)
The weights \(1/(D {D - 1 \choose \left|S\right|})\) ensure that the weights sum to 1, making \(\varphi_{d}(v)\) a proper weighted average of marginal contributions. For any coalition of size \(s\), there are \({D - 1 \choose s}\) subsets with that size, so the total weight is,
\[ \sum_{s=0}^{D-1} \binom{D-1}{s} \frac{1}{D\binom{D-1}{s}} = \sum_{s=0}^{D-1} \frac{1}{D} = 1. \]