# Producing interactive plots

Lindsay Rutter

#### 2020-03-18

#### Package

bigPint 1.2.2

## 0.1 Accessing interactive plots

Interactive plots in the `bigPint` package open as Shiny applications. These applications consist of a simple dashboard that includes an “About” tab that explains how to use the application. They also include an “Application” tab that offers several input fields that the user can tailor to their needs. Some of these input fields are generated dynamically based off the dataset that the user input. These tailorizations include aesthetics (such as point color) and metrics to determine the subset of data to be superimposed. In these applications, users can also easily save static images of the interactive graphics and lists of selected genes to their local computer.

## 0.2 Types of interactive plots

Currently, there are four interactive plots available in the `bigPint` package:

- Scatterplot matrix
- Litre plots
- Parallel coordinate plots
- Volcano plots

Below we provide examples on how to produce these types of plots.

## 0.3 Scatterplot matrix app

Interactive scatterplot matrices can be generated with the `bigPint` function plotSMApp(). The code below will generate an example interactive scatterplot matrix from the soybean cotyledon dataset (Brown and Hudson 2015).

    library(bigPint)
    data("soybean_cn_sub")
    soybean_cn_sub <- soybean_cn_sub[,1:7]
    app <- plotSMApp(data=soybean_cn_sub)
    if (interactive()) {
        shiny::runApp(app)
    }

Upon running the code above in your R session, an interactive window will open. By default, you will first see an “About” tab that explains the application. Simply click on the “Application” tab under the navigation icon at the top of the screen to enter the actual interactive graphic. Embedded below is the resulting application (which can also be accessed directly here).

## 0.4 Litre plot app

Interactive litre plots can be generated with the `bigPint` function plotLitreApp(). The code below will generate an example interactive litre plot using the soybean iron metabolism dataset after being logged (Lauter and Graham 2016).

    data("soybean_ir_sub")
    data("soybean_ir_sub_metrics")
    soybean_ir_sub_log <- soybean_ir_sub
    soybean_ir_sub_log[,-1] <- log(soybean_ir_sub[,-1]+1)
    app <- plotLitreApp(data=soybean_ir_sub_log,
        dataMetrics = soybean_ir_sub_metrics)
    if (interactive()) {
        shiny::runApp(app, port = 1234, launch.browser = TRUE)
    }

Upon running the code above in your R session, an interactive window will open. By default, you will first see an “About” tab that explains the application. Simply click on the “Application” tab under the navigation icon at the top of the screen to enter the actual interactive graphic. Embedded below is the resulting application (which can also be accessed directly here).

## 0.5 Parallel coordinates app

Users can produce interactive parallel coordinate plots with the `bigPint` function plotPCPApp(). The code below will generate an example interactive parallel coordinate plot using the soybean iron metabolism dataset after being standardized (Lauter and Graham 2016).

    soybean_ir_sub_st = as.data.frame(t(apply(as.matrix(soybean_ir_sub[,-1]), 1,
      scale)))
    soybean_ir_sub_st$ID = as.character(soybean_ir_sub$ID)
    soybean_ir_sub_st = soybean_ir_sub_st[,c(length(soybean_ir_sub_st),
      1:length(soybean_ir_sub_st)-1)]
    colnames(soybean_ir_sub_st) = colnames(soybean_ir_sub)
    nID = which(is.nan(soybean_ir_sub_st[,2]))
    soybean_ir_sub_st[nID,2:length(soybean_ir_sub_st)] = 0

    plotGenes = filter(soybean_ir_sub_metrics[["N_P"]], FDR < 0.01, logFC < -4) %>%
      select(ID)
    pcpDat = filter(soybean_ir_sub_st, ID %in% plotGenes[,1])
    app <- plotPCPApp(data = pcpDat)
    if (interactive()) {
        shiny::runApp(app, display.mode = "normal")
    }

Upon running the code above in your R session, an interactive window will open. By default, you will first see an “About” tab that explains the application. Simply click on the “Application” tab under the navigation icon at the top of the screen to enter the actual interactive graphic. Embedded below is the resulting application (which can also be accessed directly here).

## 0.6 Volcano plot app

Users can produce interactive parallel coordinate plots with the `bigPint` function plotVolcanoApp(). The code below will generate an example interactive volcano plot using the soybean iron metabolism dataset after being logged (Lauter and Graham 2016).

    app <- plotVolcanoApp(data = soybean_ir_sub_log,
        dataMetrics = soybean_ir_sub_metrics)
    if (interactive()) {
        shiny::runApp(app)
    }

Upon running the code above in your R session, an interactive window will open. By default, you will first see an “About” tab that explains the application. Simply click on the “Application” tab under the navigation icon at the top of the screen to enter the actual interactive graphic. Embedded below is the resulting application (which can also be accessed directly here).

## References

Brown, Anne V., and Karen A. Hudson. 2015. “Developmental Profiling of Gene Expression in Soybean Trifoliate Leaves and Cotyledons.” BMC Plant Biology 15 (1). BioMed Central:169.

Lauter, AN Moran, and MA Graham. 2016. “NCBI Sra Bioproject Accession: PRJNA318409.”