Skip to contents

This page takes an existing MAF object to a first interactive MutGlyph plot. MutGlyph is exclusively a visualization package: use maftools or another analysis workflow to prepare and analyze variants, then use MutGlyph to render the results with an embedded GenomeSpy interactive genomic visualization.

Start with a familiar oncoplot

The TCGA acute myeloid leukemia data bundled with maftools makes a convenient small example. This starting point deliberately corresponds to the basic top-ten oncoplot in the maftools introduction, but uses MutGlyph for rendering.

laml <- maftools::read.maf(
  maf = system.file("extdata", "tcga_laml.maf.gz", package = "maftools"),
  clinicalData = system.file(
    "extdata",
    "tcga_laml_annot.tsv",
    package = "maftools"
  ),
  verbose = FALSE
)
MutGlyph::oncoplot(maf = laml, top = 10, height = 500)

The columns share one sample scale. Scroll or pinch over the plot to zoom and pan, and hover over marks for details. Sample labels can be enabled even for a dense cohort: ranged text keeps them hidden until the columns are wide enough. Hover over the widget to reveal controls for fullscreen viewing, PNG or SVG image export, and downloading the generated GenomeSpy specification.

Continue with the plot guides

Use the generated specification

MutGlyph returns an htmlwidget containing the exact GenomeSpy specification used in the browser. as_json() creates a portable copy for inspection, versioning, or experimentation in the GenomeSpy Playground.

plot <- MutGlyph::oncoplot(laml, top = 10, height = 500)
spec_json <- MutGlyph::as_json(plot, pretty = TRUE)
cat(substr(spec_json, 1, 160), "...\n")
#> {
#>   "$schema": "https://cdn.jsdelivr.net/npm/@genome-spy/core/dist/schema.json",
#>   "name": "mutglyph-oncoplot",
#>   "background": "white",
#>   "width": "container", ...

Widget width is responsive by default. Set height when embedding the plot in a constrained layout; matrix height is controlled independently with rowHeight.

Data acknowledgement

The results shown in these articles are in whole or part based upon data generated by the TCGA Research Network: https://www.cancer.gov/tcga.

sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.4 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.26.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> time zone: UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] cli_3.6.6          knitr_1.51         rlang_1.3.0        xfun_0.60         
#>  [5] otel_0.2.0         textshaping_1.0.5  jsonlite_2.0.0     data.table_1.18.4 
#>  [9] htmltools_0.5.9    ragg_1.5.2         sass_0.4.10        rmarkdown_2.31    
#> [13] grid_4.6.1         evaluate_1.0.5     jquerylib_0.1.4    fastmap_1.2.0     
#> [17] yaml_2.3.12        lifecycle_1.0.5    maftools_2.28.0    DNAcopy_1.86.0    
#> [21] compiler_4.6.1     fs_2.1.0           RColorBrewer_1.1-3 htmlwidgets_1.6.4 
#> [25] MutGlyph_0.1.0     R.oo_1.27.1        R.utils_2.13.0     lattice_0.22-9    
#> [29] systemfonts_1.3.2  digest_0.6.39      R6_2.6.1           splines_4.6.1     
#> [33] R.methodsS3_1.8.2  Matrix_1.7-5       bslib_0.12.0       tools_4.6.1       
#> [37] survival_3.8-6     pkgdown_2.2.1      cachem_1.1.0       desc_1.4.3