The aim of the ‘bscui’ R package is to render any SVG image as an interactive figure and convert identified elements into an actionable interface. This figure can be seamlessly integrated into ‘rmarkdown’ and ‘Quarto’ documents, as well as ‘shiny’ applications, allowing manipulation of elements and reporting actions performed on them.
Here are the main features of ‘bscui’ figures:
The main motivation behind the development of this package was to be able to leverage SVG images kindly shared in public knowledge resources (e.g., EBI anatomograms, SwissBioPics, or wikipathways ) to display and browse information in the relevant contexts.
The package comes with several pre-processed examples used to demonstrate the main available features described in this document.
The ‘bscui’ R package is available on CRAN.
install.packages('bscui')
The development version is available in github.
## Dependencies
install.packages("htmlwidgets")
## Install from github
devtools::install_github("patzaw/bscui")
The following packages are not dependencies of ‘bscui’ strictly speaking but are required to run code examples discussed in this document.
library(bscui)
library(xml2)
library(dplyr)
library(readr)
library(stringr)
library(glue)
library(scales)
library(reactable)
library(reactable.extras)
Built on 2024-03-31
sessionInfo()
## R version 4.3.3 (2024-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.4 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=C
## [5] LC_MONETARY=fr_BE.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=fr_BE.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=fr_BE.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Europe/Brussels
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] scales_1.3.0 glue_1.7.0 stringr_1.5.1 readr_2.1.5 dplyr_1.1.4
## [6] xml2_1.3.6 bscui_0.1.5 knitr_1.45
##
## loaded via a namespace (and not attached):
## [1] jsonlite_1.8.8 compiler_4.3.3 tidyselect_1.2.1 jquerylib_0.1.4
## [5] yaml_2.3.8 fastmap_1.1.1 R6_2.5.1 generics_0.1.3
## [9] htmlwidgets_1.6.4 tibble_3.2.1 munsell_0.5.0 bslib_0.7.0
## [13] pillar_1.9.0 tzdb_0.4.0 rlang_1.1.3 utf8_1.2.4
## [17] cachem_1.0.8 stringi_1.8.3 xfun_0.43 sass_0.4.9
## [21] cli_3.6.2 magrittr_2.0.3 digest_0.6.35 rstudioapi_0.16.0
## [25] hms_1.1.3 lifecycle_1.0.4 vctrs_0.6.5 evaluate_0.23
## [29] fansi_1.0.6 colorspace_2.1-0 rmarkdown_2.26 tools_4.3.3
## [33] pkgconfig_2.0.3 htmltools_0.5.8
The main function of the package is bscui()
. It takes as
main argument a character string with SVG code. The use of xml2 to read SVG
files is not mandatory but it can be useful to validate the SVG and
manipulate it before displaying it.
This example relies on a figure of animal cells taken from SwissBioPics.
svg <- xml2::read_xml(system.file(
"examples", "Animal_cells.svg.gz",
package="bscui"
))
The simplest way to display the figure is shown below.
figure <- bscui(svg)
figure