This vignette demonstrates how to explore and visualize experimental
deep mutational scanning (DMS) fitness scores and variant effect
prediction model scores from the ProteinGym database (Notin et al. 2023). Specifically, it walks
through the functionality to generate heatmaps of DMS scores for all
possible amino acid substitutions and projects these scores onto 3D
protein structures. ProteinGymR uses functionality from the
Bioconductor package ComplexHeatmap
and r3dmol
from CRAN under the hood to generate the heatmaps and 3D protein
structures, respectively. Finally, this vignette demonstrates how to
contrast variant effects predictions with experimental measurements.
Here, we explore the “ACE2_HUMAN” DMS assay from Chan et al. (2020) and create a heatmap of the
DMS scores with plot_dms_heatmap(). If the argument
dms_data is not specified, the default will load the most
recent DMS substitution data from ProteinGym with
dms_substitutions(). This function only requires a specific
assay name. To obtain all assay names, run:
names(dms_substitutions()). By default, the function also
plots the full range of positions where DMS data is available for this
assay. To plot a specific region of interest, use the arguments
start_pos and end_pos which takes in an
integer for the first and last residue position to plot in the
protein.
ace2_dms <- plot_dms_heatmap(
assay_name = "ACE2_HUMAN_Chan_2020",
start_pos = 1,
end_pos = 100)
ace2_dmsThe heatmap shows the DMS score at each position along the given protein sequence (x-axis) where a residue was mutated (y-axis: substituted amino acid, top; x-axis: reference amino acid). For demonstration, we subset to the first 1-100 positions and grouped the amino acids by their physiochemical properties (DE,KRH,NQ,ST,PGAVIL,MC,FYW). See here for more information. Note that not all positions along the protein sequence may be subjected to mutation for every DMS assay. This results from the specific research objectives, prioritization choices of the investigators, or technical constraints inherent to the experimental design.
A low DMS score indicates low fitness, while a higher DMS score indicates high fitness. We can think of higher DMS scores as being more benign, while lower DMS score indicates more pathogenic regions.
Based on the “ACE2_HUMAN_Chan_2020” assay, virtually all possible amino acid changes at positions 90 and 92 lead to higher fitness; possibly suggestive of a benign region of the protein. However, several mutations at position 48 resulted in low fitness. This could represent an important region for protein function where any perturbation would likely be deleterious.
Let’s plot another assay, specifying a region and invoking the
ComplexHeatmap row clustering under the hood. For more
details about this clustering method or to view more function
parameters, refer to the documentation of the
plot_dms_heatmap function.
shoc2_dms <- plot_dms_heatmap(assay_name = "SHOC2_HUMAN_Kwon_2022",
start_pos = 10,
end_pos = 60,
cluster_rows = TRUE)
shoc2_dmsFor example, in this region of the SHOC2_HUMAN protein, mutating to a Lysine (K, y-axis) resulted more frequently in higher fitness.
ProteinGymR provides functionality to generate heatmaps of zero-shot
mode scores for 79 variant effect prediction models and 11
semi-supervised models with the function
plot_zeroshot_heatmap(). The required arguments for this
function are the assay name to plot (same as for the DMS heatmap), and a
model to plot. For a complete list of models, run
available_models() for zero-shot models, and
supervised_available_models() for the 11 semi-supervised
models. If model_data is not provided, the default model
scores from ProteinGym will be loaded in from default model scores from
zeroshot_substitutions().
ace2_model <- plot_zeroshot_heatmap(
assay_name = "ACE2_HUMAN_Chan_2020",
model = "GEMME",
start_pos = 1,
end_pos = 100)As for DMS scores, we are plotting the GEMME zero-shot scores for positions 1 to 100 in the assay “ACE2_HUMAN_Chan_2020”. At first glance, both the DMS data and GEMME model reveal position 48 to be quite pathogenic across amino acid substitutions. Note that the model scores here are mostly negative; however because these are model prediction scores, negative values do not necessarily indicate lower fitness after mutation as with DMS scores. Thus, model scores are always represented with another color palette to distinguish from experimental scores. Note further that model scores are not rescaled or normalized across the 79 models, and comparison of the predicted scores between models is thus not straightforward. See (Notin et al. 2023) for more information on model scores and how to interpret them.
It can be useful to visualize the DMS and model scores side by side
for a given assay to compare the experimental DMS scores and predicted
zero-shot scores outputted from the model. This is easily done with
%v% which stacks the heatmaps in one column, while
+ will display them in two columns, side by side. This
functionality is available for all Heatmap objects generated with the
ComplexHeatmap package.
This section demonstrates how to explore and visualize DMS or model scores on a 3D protein structure using the package r3dmol under the hood. The function requires DMS or model assay to aggregate scores that will be projected onto the 3D structure.
By default, if no data_scores argument is provided, the
DMS substitutions from dms_substitutions() are loaded in,
or if viewing model scores, set this argument to any model available in
ProteinGym v1.2. Get a list of zero-shot and semi-supervised models with
available_models() and
supervised_available_model().
If a model is chosen, a helper function is invoked which normalizes the model prediction scores using a rank-based normal quantile transformation. The result is a set of normalized scores that preserve the rank order of the models scores, while standardizing the distribution. Transformed values typically fall between -3 and 3. This normalization ensures the scores are approximately standard normally distributed (mean = 0, SD = 1), allowing comparisons across models.
The user may also specify what aggregation method to use for
calculating the summary statistic at each residue position. By default,
the mean DMS score/model prediction score is calculated for each
position. See the function documentation for details:
?plot_structure()
First, let’s use all the default settings. The only required
arguments are the assay_name.
Importantly, because the plot shows one protein structure, all DMS
fitness scores across amino acids are aggregated within a position. By
default this aggregation function is just the average of all the DMS
scores at that position. However, it is possible to set any user-defined
aggregation function with the aggregation_func
argument.
For DMS assays, a score of zero will always be represented as white, corresponding to the biological interpretation of neutral fitness effect.
In this example, we are plotting the 3D structure of the ACE2_HUMAN protein and overlaying the mean DMS score across all mutants in a given position. Chan et al. (2020) who generated the DMS assay data only experimentally assessed a subset of the entire ACE2_HUMAN protein. By default, the function only colors the regions where there is information available in the assay. Red colors represent more pathogenic (lower DMS scores) and blue colors show more benign positions (higher DMS scores). Regions that appear white indicate closer to no change before and after the DMS perturbation. Grey regions represent the range of the protein assessed in the assay; however, only the colored regions include DMS data. Finally, by default, regions of the protein itself outside the range of the experimental assay have the “ball and stick” representation.
We can also overlap model scores from the any of our zero-shot or
semi-supervised models. Do this by setting data_scores
argument to any model string matching available_models() or
supervised_available_models(). Here, let’s demonstrate
plotting the “Kermut” model and also allowing the full visualization of
the complete protein structure, rather than just the “ball and stick”
representation. This can be done by setting the argument
full_structure to TRUE.
Now we can more clearly see the entire protein structure for ACE2_HUMAN in the ribbon representation, and we have overlaid the model prediction scores from the Kermut model.
Some assays extensively assessed nearly every position of the
complete protein, for example: the C6KNH7_9INFA protein from (Lee et al. 2018). Let’s visualize this protein
and set the aggregation method to view the minimum DMS score across all
mutants at each position by setting aggregation_fun = min.
To view a specific region in detail: use start_pos and
end_pos.
As we might expect, the minimum DMS value (more pathogenic) is almost always a negative number across all positions of this protein. Therefore, there seems to be at least one amino acid mutation that could severely disrupt the fitness at any position of this protein.
Finally, it is possible to use the same color scheme as the popEVE mutation portal. We can do
this for any of the heatmaps or protein structure plots. This can be
done by setting the argument color_scheme to “EVE”.
The dms_corr_plot() function allows the user to evaluate
the correlation between experimental and model prediction scores. By
default, it takes in a protein UniProt ID and runs a Spearman
correlation between the ProteinGym DMS assay scores and AlphaMissense
predicted pathogenicity scores. However, as with
plot_structure(), other models benchmarked in ProteinGym
can also be specified via the model argument.
## [1] "r = -0.68; Pval = 0"
By default, the dms_corr_plot() function gathers any of
the 217 DMS assays of the chosen UniProt ID and correlates the average
DMS score across relevant assays and the AlphaMissense model
predictions.
Although the default uses the AlphaMissense scores, it is simple to correlate DMS experimental scores with predictions from any of the 79 zero-shot or 11 supervised models. Below is an example of the workflow to accomplish this for the UniProt ID “Q9NV35” as before.
Similar to the above, we can also explore the correlation between two
different models for a given protein instead of looking at the DMS
experimental data. We can do this for the protein “P04637” and the
model_corr_plot() function. By default, the function only
requires a UniProt ID, and uses “AlphaMissense” and “EVE_single” models
as defaults. Let’s change that to “Kermut” and “ProteinNPT” for our
demonstration.
## [1] "r = 0.63; Pval = 0"
There seems to be good correlation between the model predictions for all variants in assays assessing the “P04637” protein.
## R version 4.6.1 (2026-06-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] grid stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] ggExtra_0.11.0 ComplexHeatmap_2.28.0 ggplot2_4.0.3
## [4] stringr_1.6.0 dplyr_1.2.1 tidyr_1.3.2
## [7] ProteinGymR_1.6.0 BiocStyle_2.40.0
##
## loaded via a namespace (and not attached):
## [1] DBI_1.3.0 httr2_1.3.0 rlang_1.3.0
## [4] magrittr_2.0.5 clue_0.3-68 GetoptLong_1.1.1
## [7] otel_0.2.0 matrixStats_1.5.0 compiler_4.6.1
## [10] RSQLite_3.53.3 maps_3.4.3 png_0.1-9
## [13] vctrs_0.7.3 pkgconfig_2.0.3 shape_1.4.6.1
## [16] crayon_1.5.3 fastmap_1.2.0 dbplyr_2.6.0
## [19] XVector_0.52.0 labeling_0.4.3 promises_1.5.0
## [22] rmarkdown_2.32 purrr_1.2.2 bit_4.6.0
## [25] xfun_0.61 pals_1.10 cachem_1.1.0
## [28] queryup_1.0.5 jsonlite_2.0.0 blob_1.3.0
## [31] later_1.4.8 parallel_4.6.1 spdl_0.0.5
## [34] cluster_2.1.8.3 R6_2.6.1 bslib_0.12.0
## [37] stringi_1.8.9 RColorBrewer_1.1-3 jquerylib_0.1.4
## [40] Rcpp_1.1.2 Seqinfo_1.2.0 iterators_1.0.14
## [43] knitr_1.52 IRanges_2.46.0 httpuv_1.6.17
## [46] tidyselect_1.2.1 dichromat_2.0-1 yaml_2.3.12
## [49] doParallel_1.0.17 codetools_0.2-20 miniUI_0.1.2
## [52] curl_8.0.0 tibble_3.3.1 bio3d_2.4-5
## [55] Biobase_2.72.0 shiny_1.14.0 withr_3.0.3
## [58] KEGGREST_1.52.2 S7_0.2.2 r3dmol_0.1.2
## [61] evaluate_1.0.5 BiocFileCache_3.2.0 ggdist_3.3.3
## [64] circlize_0.4.18 ExperimentHub_3.2.2 Biostrings_2.80.2
## [67] pillar_1.11.1 BiocManager_1.30.27 filelock_1.0.3
## [70] foreach_1.5.2 stats4_4.6.1 distributional_0.9.0
## [73] generics_0.1.4 BiocVersion_3.23.1 S4Vectors_0.50.3
## [76] scales_1.4.0 xtable_1.8-8 glue_1.8.1
## [79] mapproj_1.2.12 maketools_1.3.2 tools_4.6.1
## [82] AnnotationHub_4.2.2 sys_3.4.3 forcats_1.0.1
## [85] buildtools_1.0.0 AnnotationDbi_1.74.0 colorspace_2.1-4
## [88] RcppSpdlog_0.0.29 cli_3.6.6 rappdirs_0.3.4
## [91] viridisLite_0.4.3 gtable_0.3.6 sass_0.4.10
## [94] digest_0.6.39 BiocGenerics_0.58.1 htmlwidgets_1.6.4
## [97] rjson_0.2.23 farver_2.1.2 memoise_2.0.1
## [100] htmltools_0.5.9 lifecycle_1.0.5 httr_1.4.9
## [103] mime_0.13 GlobalOptions_0.1.4 bit64_4.8.6