From f005dd67d599c6373a07c4f9dc4f63c792ff868a Mon Sep 17 00:00:00 2001
From: Patrice Godard 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 R Markdown and Quarto documents applications.as well as
-Shiny applications, allowing
+interface. This figure can be seamlessly integrated into R Markdown 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:
Built on 2023-12-22
+Built on 2024-01-07
## R version 4.3.2 (2023-10-31)
@@ -253,8 +252,8 @@ Simple example: Animal cells
figure <- bscui(svg)
figure
The figure can be grabbed with mouse and enlarged or shrunk using the +
+The figure can be grabbed with mouse and enlarged or shrunk using the mouse wheel. Clicking on the button at the top-left corner of the figure displays a menu with various functions, including resetting the view and exporting the figure in SVG or PNG format. Several configuration choices @@ -318,8 +317,8 @@
In the example above the set_bscui_options()
function is
+
In the example above the set_bscui_options()
function is
used to hide the menu and to disable view changes (zoom and pan). Other
options can be changed with this function.
Built on 2023-12-22
+Built on 2024-01-07
## R version 4.3.2 (2023-10-31)
@@ -265,8 +265,8 @@ Move organs in front
bscui(svg)
bscui(svg)
bscui(svg)
This example relies on a figure of animal cells taken from SwissBioPics.
-##################################@
-### Preparing data ----
-
-library(bscui)
-library(xml2)
-library(readr)
-library(dplyr)
-
-svg <- xml2::read_xml(system.file(
- "examples", "Animal_cells.svg.gz",
- package="bscui"
-))
-info <- readr::read_tsv(system.file(
- "examples", "uniprot_cellular_locations.txt.gz",
- package="bscui"
-), col_types=strrep("c", 6)) |>
- mutate(id = sub("-", "", `Subcellular location ID`))
-
-##################################@
-### Building the figure ----
-
-figure <- bscui(svg) |>
- set_bscui_ui_elements(
- info |>
- mutate(
- ui_type = "selectable",
- title = Name
- ) |>
- select(id, ui_type, title)
- ) |>
- set_bscui_styles(
- info |>
- filter(Name == "Cytosol") |>
- mutate(fill = "#FF7F7F") |>
- select(id, fill)
- ) |>
- set_bscui_attributes(
- info |>
- filter(Name == "Cytoskeleton") |>
- mutate(display = "none") |>
- select(id, display)
- ) |>
- set_bscui_selection("SL0188") |>
- set_bscui_options(zoom_min=1, clip=TRUE)
-figure
-
-##################################@
-### Saving the figure ----
-
-\dontrun{
- ## Interactive html file
- figure |> htmlwidgets::saveWidget(file="figure.html")
-
- ## PNG image
- figure |>
- set_bscui_options(show_menu = FALSE) |>
- export_bscui_to_image(file="figure.png", zoom=2)
-}
+##################################@
+### Preparing data ----
+
+library(bscui)
+library(xml2)
+library(readr)
+library(dplyr)
+
+svg <- xml2::read_xml(system.file(
+ "examples", "Animal_cells.svg.gz",
+ package="bscui"
+))
+info <- readr::read_tsv(system.file(
+ "examples", "uniprot_cellular_locations.txt.gz",
+ package="bscui"
+), col_types=strrep("c", 6)) |>
+ mutate(id = sub("-", "", `Subcellular location ID`))
+
+##################################@
+### Building the figure ----
+
+figure <- bscui(svg) |>
+ set_bscui_ui_elements(
+ info |>
+ mutate(
+ ui_type = "selectable",
+ title = Name
+ ) |>
+ select(id, ui_type, title)
+ ) |>
+ set_bscui_styles(
+ info |>
+ filter(Name == "Cytosol") |>
+ mutate(fill = "#FF7F7F") |>
+ select(id, fill)
+ ) |>
+ set_bscui_attributes(
+ info |>
+ filter(Name == "Cytoskeleton") |>
+ mutate(display = "none") |>
+ select(id, display)
+ ) |>
+ set_bscui_selection("SL0188") |>
+ set_bscui_options(zoom_min=1, clip=TRUE)
+figure
+
+##################################@
+### Saving the figure ----
+
+## Not run:
+ ## Interactive html file
+ figure |> htmlwidgets::saveWidget(file="figure.html")
+
+ ## PNG image
+ figure |>
+ set_bscui_options(show_menu = FALSE) |>
+ export_bscui_to_image(file="figure.png", zoom=2)
+## End (Not run)