shiny.gosling is Now on Bioconductor - An Open-Source Software for Bioinformatics

By:
Dario Radečić
June 5, 2024

Inclusion of our shiny.gosling package on Bioconductor is a three-fold milestone for us. First, it gives our developers the recognition they deserve. Second, it strengthens our position as a leading voice in bioinformatics software development. And finally, it amplifies our visibility and credibility within the scientific community.

For you, as a user, developer, or researcher, it means you’ll now have a much easier time incorporating genomics visualizations into your bioinformatics research projects and Shiny dashboards.

Today’s article will show you how to get started with shiny.gosling and Bioconductor in general.

Looking for practical genomics visualization examples? These 7 should get you started in with shiny.gosling R and R Shiny.

Table of contents:

What is shiny.gosling and Why Should You Care?

Genomics is a fascinating field, but one of the most challenging to bridge with computer science. There are too many niches within the field for any single R package to bridge the gap. No matter what you do, you simply can’t cover everyone’s point of interest and research.

Our shiny.gosling package is an R Shiny wrapper for gosling.js powered by shiny.react. In other words, it’s a grammar-based toolkit for scalable and interactive data visualization.

Image 1 - shiny.gosling new hex logo

Let’s go over the main functionalities and benefits of using shiny.gosling for genomics data visualization.

Main Functionalities

  • Interactivity- shiny.gosling provides interactive charts out of the box, which isn’t always a given in your typical R environment. Operations such as zooming, panning, brushing, and linking are supported.
  • Scalability - Semantic zooming allows you to scale from whole genomes to single nucleotides.
  • Expressiveness - The package is expressive, meaning you can generate almost any visualization of genome-mapped data you want. Our latest guide shows you a couple of examples to get started.

You now know what shiny.gosling is, but how exactly is it tied with Bioconductor? And what is Bioconductor in the first place? Let’s answer that next.

Why the Inclusion of shiny.gosling in Bioconductor is a Significant Milestone

We already mentioned that having an R package included in Bioconductor is a huge accomplishment, both for our developers and for Appsilon as a company. This section will provide more details into why, and will also show how you can benefit from it.

What is Bioconductor?

Bioconductor is a project that aims to develop and share open-source software for precise and repeatable analysis of biological data. It’s updated twice a year, and the latest version includes exactly 2300 packages!

Image 2 - Bioconductor hex logo

So, it’s clear that many companies and developers around the world are contributing to Bioconductor with the same goal in mind. We’re proud to be on that list.

Inclusion Benefits for Users and Developers

If you’re thinking about switching to Bioconductor for your bioinformatics research, here are a couple of reasons to go for it:

  • Package quality: Do you know what’s the single thing all 2300 Bioconductor packages have in common? It’s quality. Each submitted package goes through a review process, meaning you can rest assured that the package has been thoroughly tested and validated. In the end, this means you shouldn’t have to worry about mysterious bugs and performance issues.
  • Comprehensive documentation: Documentation for your typical R packages can be hit or miss. With Bioconductor, each package comes with extensive documentation and examples, making it easier to implement and use in your research.
  • Code reproducibility: Due to the nature of the Bioconductor release process, using a specific version of the Bioconductor release makes sure that you get the exact same version of the R package from the Bioconductor repository which will work the same.

On the other hand, if you’re a developer in the field of bioinformatics, submitting an R package to Bioconductor also has its fair share of advantages:

  • Visibility: Once your contributions to an open-source project get noticed, your visibility within the field and community will go up. Further, publishing on a trusted and reputable platform is a sure way to showcase potential employees that you mean business.
  • Credibility: If you have a reputable platform standing behind your work, it carries a lot more weight than publishing the same packages to more generic repositories. It’s also a guaranteed way to establish yourself as an expert in the field.

To conclude, having a package accepted by Bioconductor means you’re on the right track to becoming a subject matter expert in bioinformatics - both as a company and as an individual. Our recent inclusion did just that for Appsilon as a company and our team of expert developers.

Starting Small - How to Run Basic shiny.gosling examples

Before diving deeper into Shiny examples, let’s take a peek at a couple of examples that are available to you in a single function call.

The shiny.gosling::run_example() function can be used to run any of the 17 examples that come by default with the package installation. You can pass one of the following values into the function:

  • areaChart, barChart, circosVcfData, circosVectorData, circularLinearWithBrush, circularVisualEncoding, ideograms, lineChart, multiTrackApp, pointPlot, ruleMarks, sarsCov2, staticCircularBar, structuralVariant, textAnnotation, textMarks, and vcfSimpleBarChart

Let’s see one of these in action:

shiny.gosling::run_example("circularVisualEncoding")

This is the output you’ll see after running the example:

Image 3 - Shiny Gosling circular visual encoding example

That was simple, wasn’t it? 

Up next, we're about to complicate things slightly.

R Shiny is transforming processes in the Pharmaceutical industry? Read (and watch) our latest talk in R/Basel to find out how.

shiny.gosling in Action - How to Get Started in R and R Shiny

The BiocManager package in R allows you to install the mentioned 2300 approved packages straight from the R console. The alternative way is to get started through a Docker container. We’ll proceed with the first option.

Assuming you have R installed (R version 4.4.0 or above is required for Bioconductor 3.19), get the BiocManager package by running the following command from the R console:

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install(version = "3.19")

Once installed, proceed with shiny.gosling installation:

BiocManager::install("shiny.gosling")

You can see how the package was installed through BiocManager instead of your typical install.packages() command.

When it comes to R Shiny, the shiny.gosling package provides a couple of functions you must know about:

  • use_gosling() - A function you must call at the beginning of ui. Without it, Gosling won’t be able to work in R Shiny plots.
  • goslingOutput() - Allows you to specify outputId for a Gosling component that will be rendered in R Shiny.
  • gosling() - Builds a Gosling plot object, and is typically embedded in the renderGosling() function.
  • renderGosling() - Renders a Gosling chart in R Shiny by constructing a Gosling plot object (call gosling() inside the expression).

Now with this knowledge, we’ll build a multi-scale sequence track application that displays DNA base counts and annotations, allowing the user to explore genomic data related to the SARS-CoV-2 virus. The code snippet below will fetch the base counts data organized into rows and columns with attributes such as base, position, count, and categories (A, T, G, C).

For a more detailed description of the data processing pipeline, visit the official example documentation.

Anyhow, here’s the entire code snippet:

library(shiny)
library(shiny.gosling)

track1_data <- track_data(
  url = "https://server.gosling-lang.org/api/v1/tileset_info/?d=NC_045512_2-multivec",
  type = "multivec",
  row = "base",
  column = "position",
  value = "count",
  categories = c("A", "T", "G", "C"),
  start = "start",
  end = "end"
)

track1 <- add_single_track(
  mark = "bar",
  y = visual_channel_y(
    field = "count", type = "quantitative", axis = "none"
  )
)

track2 <- add_single_track(
  dataTransform = track_data_transform(
    type = "filter",
    field = "count",
    oneOf = list(0),
    not = TRUE
  ),
  mark = "text",
  x = visual_channel_x(
    field = "start", type = "genomic"
  ),
  xe = visual_channel_x(
    field = "end", type = "genomic"
  ),
  size = 24,
  color = "white",
  visibility = list(
    list(
      operation = "less-than",
      measure = "width",
      threshold = "|xe-x|",
      transitionPadding = 30,
      target = "mark"
    ),
    list(
      operation = "LT",
      measure = "zoomLevel",
      threshold = 40,
      target = "track"
    )
  )
)

track1_x <- visual_channel_x(
  field = "position", type = "genomic"
)

track1_color <- visual_channel_color(
  field = "base",
  type = "nominal",
  domain = c("A", "T", "G", "C"),
  legend = TRUE
)

track1_text <- visual_channel_text(
  field = "base", type = "nominal"
)

track1_style <- default_track_styles(
  inlineLegend = TRUE
)

track3 <- add_single_track(
  title = "NC_045512.2 Sequence",
  alignment = "overlay",
  data = track1_data,
  tracks = add_multi_tracks(
    track1, track2
  ),
  x = track1_x,
  color = track1_color,
  text = track1_text,
  style = track1_style,
  width = 800, height = 40
)

view1 <- compose_view(
  multi = TRUE,
  centerRadius = 0,
  xDomain = list(interval = c(1, 29903)),
  linkingId = "detail",
  alignment = "stack",
  tracks = add_multi_tracks(
    track3
  )
)

combined_view <- arrange_views(
  title = "SARS-CoV-2",
  subtitle = "Data Source: WashU Virus Genome Browser, NCBI, GISAID",
  assembly = list(list("NC_045512.2", 29903)),
  layout = "linear",
  spacing = 50,
  views = list(view1),
  listify = FALSE
)

ui <- fluidPage(
  use_gosling(),
  fluidRow(
    column(6, goslingOutput("gosling_plot"))
  )
)

server <- function(input, output, session) {
  output$gosling_plot <- renderGosling({
    gosling(
      component_id = "sars_cov2",
      combined_view
    )
  })
}

shinyApp(ui, server)

You can see that ~ 85% of the code has to do with data gathering and processing. The convenient shiny.gosling functions do most of the heavy lifting when it comes to visualization - you just have to call the functions.

This is the R Shiny dashboard you’ll end up with:

Image 4 - The resulting shiny.gosling application

There are many more well-documented examples on the official Bioconductor shiny.gosling documentation page, so make sure to pay a visit.

Summing up shiny.gosling

Having a package included in a trusted and reputable platform such as Bioconductor is a huge accomplishment for Appsilon as a company and our team of expert developers. It validates months of hard work and makes future development that much more rewarding.

We’re excited to see how will developers and researchers use our package to help them tackle the biggest challenges in bioinformatics. If you fit into this group, we’d love to hear from you! Make sure to try shiny.gosling and provide feedback.

Did you find this blog post helpful? Sign up to Shiny Weekly to stay up to date on shiny.gosling and other open-source packages.

Have questions or insights?

Engage with experts, share ideas and take your data journey to the next level!

Is Your Software GxP Compliant?

Download a checklist designed for clinical managers in data departments to make sure that software meets requirements for FDA and EMA submissions.

Sign up for ShinyWeekly

Join 4,2k explorers and get the Shiny Weekly Newsletter into your mailbox
for the latest in R/Shiny and Data Science.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Explore Possibilities

Share Your Data Goals with Us

From advanced analytics to platform development and pharma consulting, we craft solutions tailored to your needs.

Talk to our Experts
shiny.gosling
life sciences
open source
r