### Install volcano3Ddata Package
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Installs the volcano3Ddata package, which contains sample data required for the volcano3d vignette. This is a prerequisite for running the examples in the documentation.
```r
devtools::install_github("KatrionaGoldmann/volcano3Ddata")
```
--------------------------------
### Load Example Data
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette.html
Loads the example dataset included with the volcano3d package. This dataset contains gene expression data and associated metadata for demonstration purposes.
```R
data("example_data")
```
--------------------------------
### Install Shiny Package
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Installs the 'shiny' R package, which is a prerequisite for building and running Shiny applications. No specific inputs or outputs are detailed, but it requires an R environment with package installation capabilities.
```r
install.packages("shiny")
```
--------------------------------
### Install volcano3D Package from GitHub
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Installs the 'volcano3D' R package directly from its GitHub repository using the 'devtools' package. This is useful for installing the latest development version. It requires the 'devtools' package to be installed first. The library is then loaded.
```r
library(devtools)
install_github("KatrionaGoldmann/volcano3D")
library(volcano3D)
```
--------------------------------
### Load PEAC Shiny Example Data and Packages
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Loads necessary R packages (volcano3D, volcano3Ddata) and data (syn_data, syn_metadata) for the PEAC Shiny example. It also prepares the 'Pathotype' factor for correct ordering.
```r
library(volcano3D)
library(volcano3Ddata)
data(syn_data)
syn_metadata$Pathotype <- factor(syn_metadata$Pathotype,
levels = c("Lymphoid", "Myeloid", "Fibroid"))
```
--------------------------------
### Install volcano3D Package from CRAN
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Installs the 'volcano3D' R package from the Comprehensive R Archive Network (CRAN). This involves downloading and installing the package and its dependencies. After installation, the library is loaded for use.
```r
install.packages("volcano3D")
library(volcano3D)
```
--------------------------------
### Install volcano3D from GitHub (R)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/ReadMe.html
Installs the volcano3D R package directly from its GitHub repository using the devtools package. This is useful for installing development versions or specific branches.
```r
library(devtools)
install_github("KatrionaGoldmann/volcano3D")
library(volcano3D)
```
--------------------------------
### Install volcano3D Package from GitHub
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/ReadMe.md
Installs the volcano3D R package directly from its GitHub repository using the devtools package. This allows for installation of the latest development version.
```r
library(devtools)
install_github("KatrionaGoldmann/volcano3D")
```
--------------------------------
### Example Usage of add_animation
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/reference/add_animation.html
This example demonstrates how to use the `add_animation` function. It first creates a 3D volcano plot using the `volcano3D` function with sample data and then applies the `add_animation` function to enable plot rotation.
```r
data(example_data)
syn_polar <- polar_coords(outcome = syn_example_meta$Pathotype,
data = t(syn_example_rld))
p <- volcano3D(syn_polar,
label_rows = c("COBL", "TREX2"))
add_animation(p)
```
--------------------------------
### Install volcano3D Data Package (R)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/ReadMe.html
Installs the volcano3D data package from GitHub. This function requires the devtools package to be installed.
```r
install_github("KatrionaGoldmann/volcano3Ddata")
```
--------------------------------
### Install and Load volcano3d Data Package
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Extended_Vignette.rmd
Installs the volcano3ddata package from GitHub and loads it into the R session. It also loads the 'syn_data' object, which contains sample synovial gene expression data and associated metadata for analysis.
```r
devtools::install_github("KatrionaGoldmann/volcano3Ddata")
library(volcano3Ddata)
data("syn_data")
```
```r
library(volcano3Ddata)
data("syn_data")
```
--------------------------------
### Setup R Markdown Chunks
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Vignette.rmd
Configures global options for R Markdown chunks, controlling the display of code, warnings, messages, and figure dimensions. It also loads necessary libraries like knitr and kableExtra.
```r
knitr::opts_chunk$set(
echo = TRUE,
warning = FALSE,
message = FALSE,
fig.height = 7,
fig.width=7,
fig.align = "center"
)
library(knitr)
library(kableExtra)
```
--------------------------------
### Install volcano3D from CRAN (R)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/ReadMe.html
Installs the volcano3D R package from the Comprehensive R Archive Network (CRAN). This is the standard method for installing stable package versions.
```r
install.packages("volcano3D")
```
--------------------------------
### Generate Example Polar Coordinates and Plot
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/reference/volcano3D.html
This example demonstrates how to generate polar coordinates from sample data and then create a 3D volcano plot using the volcano3D function. It first loads example data, calculates polar coordinates based on a specified outcome and data, and then passes these coordinates to the volcano3D function to generate the plot.
```r
data(example_data)
syn_polar <- polar_coords(
outcome = syn_example_meta$Pathotype,
data = t(syn_example_rld)
)
volcano3D(syn_polar)
```
--------------------------------
### Setup R Markdown Vignette
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Extended_Vignette.rmd
Configures R Markdown chunk options for consistent output, including disabling messages and warnings, centering figures, and setting transparent backgrounds. It loads necessary libraries like knitr, kableExtra, and a custom R script for rendering the table of contents.
```R
knitr::opts_chunk$set(echo = TRUE,
warning = FALSE,
message = FALSE,
fig.align = 'center',
dev.args=list(bg="transparent")
)
library(knitr)
library(kableExtra)
source("https://gist.githubusercontent.com/KatrionaGoldmann/3d6dfd6aa4cc5c3940bb72dc49beae02/raw/26e78c78a7a9d096d695c708e8a45830a1d1121a/render_toc.R")
```
--------------------------------
### Create Polar Coordinates for PEAC Example
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Calculates polar coordinates from the provided RNA-Seq data (t(syn_rld)) and metadata (syn_metadata$Pathotype) to prepare data for the 3D volcano plot in the PEAC Shiny example.
```r
syn_polar <- polar_coords(outcome = syn_metadata$Pathotype,
data = t(syn_rld))
```
--------------------------------
### Load volcano3D Package in R
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/ReadMe.md
Loads the volcano3D package into the current R session, making its functions available for use. This command is typically run after installing the package.
```r
library(volcano3D)
```
--------------------------------
### Generating Radial Plots and Boxplots in R
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Extended_Vignette.rmd
Provides examples for generating both interactive radial plots and static ggplot radial plots using the `radial_plotly` and `radial_ggplot` functions, respectively. It also shows how to create boxplots for specific modules using `boxplot_trio` and combine them with `ggpubr::ggarrange` for comparative analysis.
```r
radial_plotly(polar = syn_mod_polar,
axes_from_origin = FALSE,
label_rows = c("M156.0", "M37.2"))
radial_ggplot(polar = syn_mod_polar,
label_rows = c("M156.0", "M37.2"),
marker_size = 2.7,
label_size = 5,
axis_lab_size = 3,
axis_title_size = 5,
legend_size = 10)
plot1 <- boxplot_trio(syn_mod_polar,
value = "M156.0",
test = "wilcox.test",
levels_order = c("Lymphoid", "Myeloid", "Fibroid"),
box_colours = c("blue", "red", "green3"))
plot2 <- boxplot_trio(syn_mod_polar,
value = "M37.2",
test = "wilcox.test",
levels_order = c("Lymphoid", "Myeloid", "Fibroid"),
box_colours = c("blue", "red", "green3"))
ggpubr::ggarrange(plot1, plot2)
```
--------------------------------
### Interactive Radial Plot with Labels
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette_2x3.html
This example shows how to create an interactive 2D radial plot using the 'radial_plotly' function. It utilizes a 'volc3d' object and allows for highlighting specific genes by providing a 'label_rows' argument. The `toWebGL()` function is used to optimize plotting performance in plotly.
```r
obj <- deseq_2x3_polar(data1)
labs <- c('MS4A1', 'TNXA', 'FLG2', 'MYBPC1')
radial_plotly(obj, type=2, label_rows = labs) %>% toWebGL()
```
--------------------------------
### DESeq2 Setup and 2x3-way Analysis
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette_2x3.html
This code sets up a DESeq2 object with experimental metadata and performs a 2x3-way differential gene expression analysis. It then generates a 'volc3d' class results object suitable for plotting. The 'deseq_2x3' function is used for the analysis, comparing a binary response across three experimental groups.
```r
library(volcano3D)
# Basic DESeq2 set up
library(DESeq2)
counts <- matrix(rnbinom(n=3000, mu=100, size=1/0.5), ncol=30)
rownames(counts) <- paste0("gene", 1:100)
cond <- rep(factor(rep(1:3, each=5), labels = c('A', 'B', 'C')), 2)
resp <- factor(rep(1:2, each=15), labels = c('non.responder', 'responder'))
metadata <- data.frame(drug = cond, response = resp)
# Full dataset object construction
dds <- DESeqDataSetFromMatrix(counts, metadata, ~response)
# Perform 3x DESeq2 analyses comparing binary response for each drug
res <- deseq_2x3(dds, ~response, "drug")
```
--------------------------------
### Example Usage of polar_coords (R)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/reference/polar_coords.html
This example demonstrates how to use the polar_coords function with sample data. It loads the 'example_data' dataset, defines the outcome and data matrices, and then calls polar_coords to generate the 'volc3d' object. This object can then be used with other volcano3D plotting functions.
```R
data(example_data)
syn_polar <- polar_coords(outcome = syn_example_meta$Pathotype,
data = t(syn_example_rld))
```
--------------------------------
### Get Citation for volcano3D R Package
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/index.html
Retrieves the recommended citation for the volcano3D R package. This is essential for academic and research use to properly attribute the software. It provides both a standard citation format and a BibTeX entry for LaTeX users.
```r
citation("volcano3D")
##
## To cite package 'volcano3D' in publications use:
##
## Goldmann K, Lewis M (2020). _volcano3D: 3D Volcano Plots and Polar
## Plots for Three-Class Data_.
## https://katrionagoldmann.github.io/volcano3D/index.html,
## https://github.com/KatrionaGoldmann/volcano3D.
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {volcano3D: 3D Volcano Plots and Polar Plots for Three-Class Data},
## author = {Katriona Goldmann and Myles Lewis},
## year = {2020},
## note = {https://katrionagoldmann.github.io/volcano3D/index.html, https://github.com/KatrionaGoldmann/volcano3D},
## }
```
--------------------------------
### Get Citation for volcano3D Package (R)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/ReadMe.html
Retrieves the citation information for the volcano3D R package. This is useful for academic publications and ensures proper attribution.
```r
citation("volcano3D")
```
--------------------------------
### Create and Run Basic Shiny App
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Combines the UI and server components to create a Shiny application object and runs it. This function call launches the interactive web application.
```r
library(shiny) shinyApp(ui = ui, server = server)
```
--------------------------------
### Launch Shiny Application in R
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
This code snippet demonstrates how to launch a Shiny application once the user interface (ui) and server logic have been defined. It's the final step in creating an interactive web application using the Shiny package in R.
```r
shinyApp(ui = ui, server = server)
```
--------------------------------
### Load Supporting Packages
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Extended_Vignette.rmd
Loads the 'ggpubr' and 'plotly' R packages, which are often used in conjunction with volcano3D for enhanced plotting and interactive visualizations.
```R
library(ggpubr)
library(plotly)
```
--------------------------------
### Load volcano3D Libraries and Data
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/shiny_builder.rmd
Loads necessary R libraries for the volcano3D package and its associated data. It then loads the 'syn_data' and prepares 'syn_metadata' by converting the 'Pathotype' column to a factor with specified levels.
```r
library(volcano3D)
library(volcano3Ddata)
data(syn_data)
syn_metadata$Pathotype <- factor(syn_metadata$Pathotype,
levels = c("Lymphoid", "Myeloid", "Fibroid"))
```
--------------------------------
### Google Analytics Configuration
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette.html
Initializes Google Analytics tracking for the webpage. This involves setting up the dataLayer and sending the initial configuration event.
```javascript
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-158679490-1');
```
--------------------------------
### Load Additional Packages for PEAC Shiny UI
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Loads additional R packages required for the enhanced PEAC Shiny application, including those for CSS loaders, interactive plots, data tables, and ggplot creation.
```r
library(shinycssloaders)
library(plotly)
library(DT)
library(ggpubr)
```
--------------------------------
### DESeq2 Analysis and volc3d Object Creation with R
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette.html
This snippet demonstrates how to set up a DESeqDataSet, run the DESeq analysis, perform a likelihood ratio test, and then use the results to create a 'volc3d' class object for plotting with the deseq_polar function. Ensure DESeq has been run on the input objects and the design formula prioritizes the variable of interest.
```r
library(DESeq2)
# setup initial dataset from Tximport
dds <- DESeqDataSetFromTximport(txi = syn_txi,
colData = syn_metadata,
design = ~ Pathotype + Batch + Gender)
# initial analysis run
dds_DE <- DESeq(dds)
# likelihood ratio test on 'Pathotype'
dds_LRT <- DESeq(dds, test = "LRT", reduced = ~ Batch + Gender, parallel = TRUE)
# create 'volc3d' class object for plotting
res <- deseq_polar(dds_DE, dds_LRT, "Pathotype")
# plot 3d volcano plot
volcano3D(res)
```
--------------------------------
### Basic Shiny App UI Structure
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Defines the user interface (UI) for a basic Shiny application. It includes a title panel, a sidebar layout with a slider input for controlling the number of bins in a histogram, and a main panel to display the plot.
```r
library(shiny)
ui <- fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput("bins", label = "No. of bins:", min = 1, max = 50,
value = 30)
),
mainPanel(plotOutput(outputId = "distPlot"))
)
)
```
--------------------------------
### Subset Significance Groups from 'volc3d' Object
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Extended_Vignette.rmd
This R code provides examples of using the significance_subset function to extract specific significance groups from a 'volc3d' object. It shows how to obtain subsets for p-values and polar coordinates, and then displays the head of the p-value subset using kable for formatted output.
```r
pvals_subset <- significance_subset(syn_polar,
significance = c("L+", "M+"),
output="pvals")
polar_subset <- significance_subset(syn_polar,
significance = c("L+", "M+"),
output="polar")
head(pvals_subset) %>%
kable() %>%
kable_styling(full_width = F)
```
--------------------------------
### Create Polar Coordinates for Visualization
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette.html
Generates polar coordinates from data for plotting 3D volcano or radial 3-way plots. It requires outcome (a three-level factor) and data (a dataframe or matrix). P-values can be optionally provided. This example uses transposed gene expression data and sample metadata.
```R
syn_polar <- polar_coords(outcome = syn_example_meta$Pathotype,
data = t(syn_example_rld))
```
--------------------------------
### PEAC Shiny Application UI Definition
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Defines the user interface for the PEAC Shiny application using `navbarPage`. It includes a window title, styling, a favicon, and sets up the main navigation structure with multiple tab panels for different sections of the application.
```r
ui <- navbarPage(
windowTitle="PEAC RNA-Seq",
selected="a",
fluid=TRUE,
tags$style(type="text/css", "body {padding-top: 0px;}"),
id="mainNavbarPage",
tags$head(tags$link(rel="shortcut icon", href="favicon.ico")),
# Tab 1: The navigation page with links to other tabs
tabPanel(
div(
img(
src="http://qm-web.chem.qmul.ac.uk/qm-resources/images/crown_tab.gif",
height=30, style="padding: 0px 0px;"), "PEAC RNA-Seq"),
value="a",
fluidPage(
fluidRow(
column(12, align="center",
actionLink(
```
--------------------------------
### Load Required Libraries for Plotting
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Vignette.rmd
Loads essential R libraries for data visualization and interactive plotting, including ggplot2 for static plots, ggpubr for enhanced plotting, and plotly for interactive visualizations.
```r
library(ggplot2)
library(ggpubr)
library(plotly)
library(usethis)
```
--------------------------------
### Basic Shiny App Server Logic
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/shiny_builder.rmd
Defines the server-side logic for a basic Shiny application. It renders a plot based on user input from the UI, specifically generating a histogram with a variable number of bins.
```r
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = "#75AADB", border = "white",
xlab = "Waiting time to next eruption (in mins)",
main = "Histogram of waiting times")
})
}
```
--------------------------------
### Load Shiny UI and Supporting Libraries
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/shiny_builder.rmd
Loads additional R libraries required for the Shiny application, including shinycssloaders for spinners, plotly for interactive plots, DT for data tables, and ggpubr for plot creation. It then defines the overall structure of the Shiny UI using 'navbarPage'.
```r
library(shinycssloaders)
library(plotly)
library(DT)
library(ggpubr)
ui <- navbarPage(
windowTitle="PEAC RNA-Seq",
selected="a",
fluid=TRUE,
tags$style(type="text/css", "body {padding-top: 0px;}"),
id="mainNavbarPage",
tags$head(tags$link(rel="shortcut icon", href="favicon.ico")),
# Tab 1: The navigation page with links to other tabs
tabPanel(
div(
img(
src="http://qm-web.chem.qmul.ac.uk/qm-resources/images/crown_tab.gif",
height=30, style="padding: 0px 0px;"), "PEAC RNA-Seq"),
value="a",
fluidPage(
fluidRow(
column(12, align="center",
actionLink(
"link_to_tabpanel_v",
div(img(
src="https://bit.ly/39LH4Nv",
height=150, width=150),
HTML("
3D Volcano Plot"),
style="display: inline-block; padding: 0px 10px 0px 10px;")),
actionLink(
"link_to_tabpanel_g",
div(img(src="https://bit.ly/2yGQSvk",
height=150, width=150),
HTML("
Gene Correlations"),
style="display: inline-block; padding: 0px 10px 0px 10px;")),
actionLink(
"link_to_tabpanel_c",
div(img(src="https://bit.ly/3dVXPJ7",
height=150, width=150),
HTML("
Table of Pvalues"),
style="display: inline-block; padding: 0px 10px 0px 10px;"))))
)),
# Tab 2: 3D volcano plot
tabPanel("Volcano", value="v",
fluidPage(
column(8, withSpinner(plotlyOutput("volcano", height=720))),
column(4,
fluidRow(
# option for data type
column(4, radioButtons("data_type",
label=h5("Polar radius"),
choices=
list("Z score"=1,
"Fold change"=2),
selected=1))),
fluidRow(plotOutput("boxplots", height=400))
))
),
# Tab 3: Gene search:
tabPanel("Genes", value="g",
fluidPage(
column(3,
selectizeInput(
"gene", label=h5("Select a Gene"),
choices=rownames(syn_polar@df[[1]]),
options=list(
onInitialize=I(
'function() { this.setValue(""); }')))),
column(9, plotOutput("gene_plots")))
),
# Tab 4: table setup:
tabPanel("Table", value="t",
fluidPage(
column(
2,
checkboxGroupInput(
'group',
'Select upregulated groups',
```
--------------------------------
### Example Usage of polar_grid with polar_coords (R)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/reference/polar_grid.html
This R code snippet demonstrates how to use the `polar_grid` function in conjunction with `polar_coords`. It first generates polar coordinates from sample data and then uses these coordinates to define the `r_vector` for the `polar_grid` function, while specifying custom `z_axis_ticks` and `n_spokes`. This showcases a practical application for creating visualization grids.
```r
grid <- polar_grid(r_vector=syn_polar@df[[1]]$r,
z_vector=NULL,
r_axis_ticks = NULL,
z_axis_ticks = c(0, 8, 16, 32),
n_spokes = 4)
```
--------------------------------
### Differential Expression Analysis with limma voom
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette.html
Performs differential expression analysis using the limma voom method from Bioconductor packages 'limma' and 'edgeR'. Requires raw count data, metadata, and a design formula. Outputs a 'volc3d' object suitable for 3D plotting. The design formula must start with '~ 0 + outcome', where 'outcome' is a factor with exactly 3 levels.
```r
library(limma)
library(edgeR)
syn_tpm <- syn_txi$counts # raw counts
resl <- voom_polar(~ 0 + Pathotype + Batch + Gender, syn_metadata, syn_tpm)
volcano3D(resl)
```
--------------------------------
### Google Analytics Configuration (JavaScript)
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/ReadMe.html
This snippet configures Google Analytics tracking for the webpage. It initializes the dataLayer and sends initial configuration data, including the tracking ID.
```javascript
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
gt('js', new Date());
gt('config', 'UA-158679490-1');
```
--------------------------------
### Shiny Server: Navigation and Plot Rendering
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
The server logic for the Volcano3D Shiny app. It includes functions to update navigation based on user clicks, render the 3D volcano plot, generate boxplots from plot clicks, and create gene-specific plots.
```r
server <- function(input, output, session) {
# Navitation tab: allow images to link to tabs
observeEvent(input$link_to_tabpanel_v, {
updateNavbarPage(session, "mainNavbarPage", "v")})
observeEvent(input$link_to_tabpanel_g, {
updateNavbarPage(session, "mainNavbarPage", "g")})
observeEvent(input$link_to_tabpanel_t, {
updateNavbarPage(session, "mainNavbarPage", "t")})
# Volcano tab: Create the 3D volcano plot
output$volcano <- renderPlotly({
data_type <- as.numeric(input$data_type)
if (length(data_type) == 0) data_type <- 1
p <- volcano3D(syn_polar,
type = data_type)
})
# Volcano tab: Create pathotype boxplots when genes clicked
output$boxplots <- renderPlot({
s <- event_data("plotly_click")
req(length(s) > 0)
gene = s$key
boxplot_trio(syn_polar,
value = gene,
test = "polar_pvalue",
step_increase = 0.1)
})
# Gene tab: create plots for selected genes
output$gene_plots <- renderPlot({
s <- input$gene
req(s != "")
# synovium pathotype boxplot
gene <- input$gene
path_plot <- boxplot_trio(syn_polar,
value = gene,
test = "polar_pvalue",
```
--------------------------------
### Visualizing DESeq2 Results with easyVolcano
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette_2x3.html
This snippet demonstrates how to visualize the results of a DESeq2 analysis for a specific drug using the 'easyVolcano' function from the 'easylabel' package. It takes a DESeq2 results data frame as input and generates an interactive volcano plot. This is useful for quickly exploring differential gene expression for each comparison.
```r
library(easylabel)
df <- as.data.frame(res[[1]]) # results for the first drug
easyVolcano(df)
```
--------------------------------
### Shiny UI Navigation and Image Links
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Defines the user interface structure for the Volcano3D Shiny app, including navigation tabs and image elements that link to specific panels. It uses functions like `div`, `img`, `HTML`, and `actionLink` to create interactive components.
```r
div(column(2,
div(style="display: inline-block; padding: 0px 10px 0px 10px;",
actionLink(
"link_to_tabpanel_v",
div(img(src="https://bit.ly/39LH4Nv",
height=150, width=150),
HTML("
3D Volcano Plot"),
style="display: inline-block; padding: 0px 10px 0px 10px;")))),
actionLink(
"link_to_tabpanel_g",
div(img(src="https://bit.ly/2yGQSvk",
height=150, width=150),
HTML("
Gene Correlations"),
style="display: inline-block; padding: 0px 10px 0px 10px;")),
actionLink(
"link_to_tabpanel_c",
div(img(src="https://bit.ly/3dVXPJ7",
height=150, width=150),
HTML("
Table of Pvalues"),
style="display: inline-block; padding: 0px 10px 0px 10px;"))))
)
)),
# Tab 2: 3D volcano plot
tabPanel("Volcano", value="v",
fluidPage(
column(8, withSpinner(plotlyOutput("volcano", height=720))),
column(4,
fluidRow(
# option for data type
column(4, radioButtons("data_type",
label=h5("Polar radius"),
choices=
list("Z score"=1,
"Fold change"=2),
selected=1))),
fluidRow(plotOutput("boxplots", height=400))
))
),
# Tab 3: Gene search:
tabPanel("Genes", value="g",
fluidPage(
column(3,
selectizeInput(
"gene", label=h5("Select a Gene"),
choices=rownames(syn_polar@df[[1]]),
options=list(
onInitialize=I(
'function() { this.setValue(""); }')))),
column(9, plotOutput("gene_plots"))
),
# Tab 4: table setup:
tabPanel("Table", value="t",
fluidPage(
column(
2,
checkboxGroupInput(
'group',
'Select upregulated groups',
syn_polar@labs[-1],
# by default select all significant
selected=syn_polar@labs[
syn_polar@labs !=
"ns"])),
column(10, DT::dataTableOutput("full_table"))
))
)
```
--------------------------------
### Basic Shiny App Server Logic
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/shiny_builder.html
Defines the server-side logic for a basic Shiny application. It generates a histogram based on the 'waiting' data from the 'faithful' dataset, with the number of bins controlled by user input from the UI.
```r
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = "#75AADB", border = "white",
xlab = "Waiting time to next eruption (in mins)",
main = "Histogram of waiting times")
})
}
```
--------------------------------
### CSS: Icon and Badge Styling
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/inst/pkgdown/footer.html
This CSS provides styling for a grey icon and two custom badges (.smadge and .bladge). The badges are pseudo-elements that display text ('EMR' or 'C4TB') with specific positioning and appearance.
```css
*.icon-grey {color: lightgrey}
j { text-align:center; vertical-align:middle; position: relative; padding-bottom: 12px; }
.smadge:after{ content:"EMR"; position: absolute; background: lightgrey; height:1.2rem; top:1rem; right:-1rem; width:2.3rem; text-align: center; line-height: 1rem;; font-size: 1rem; color: #cc0099; border-radius: 10%; }
.bladge:after{ content:"C4TB"; position: absolute; background: lightgrey; height:1.2rem; top:1rem; right:-1rem; width:2.7rem; text-align: center; line-height: 1rem;; font-size: 1rem; color: #cc0099; border-radius: 10%; }
```
--------------------------------
### Perform 2x3 Factor DESeq2 Analysis in R
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/reference/deseq_2x3.html
This R code demonstrates how to set up and perform a 2x3 factor DESeq2 analysis using the 'deseq_2x3' function from the volcano3D package. It requires the DESeq2 package and involves creating a matrix of counts, assigning row names, and then calling the 'deseq_2x3' function with appropriate design and group parameters. The function returns a list of DESeq2 results objects.
```R
library(DESeq2)
counts <- matrix(rnbinom(n=3000, mu=100, size=1/0.5), ncol=30)
rownames(counts) <- paste0("gene", 1:100)
# Assuming 'object', 'design', and 'group' are defined elsewhere
# results_list <- deseq_2x3(object, design, group)
```
--------------------------------
### Display Pathotype Counts
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Vignette.rmd
Uses the kable function from the knitr package to display a formatted table showing the counts of samples within each 'Pathotype' group from the 'syn_example_meta' data.
```r
kable(table(syn_example_meta$Pathotype), col.names = c("Pathotype", "Count"))
```
--------------------------------
### Saving Plotly Plots as Static Images
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/articles/Vignette.html
Provides methods to save interactive plotly plots as static images. Plotly itself offers a download button in the mode bar. Customization options allow specifying the output format (e.g., SVG, PNG, JPEG, WebP) via `plotly::config`.
```r
p %>% plotly::config(toImageButtonOptions = list(format = "svg"))
```
--------------------------------
### Prepare and Analyze RNA-Seq Data with DESeq2 for volcano3d
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/Extended_Vignette.rmd
This code demonstrates setting up a DESeq2 object from RNA-Seq count data (syn_txi) and metadata (syn_metadata). It performs differential expression analysis using DESeq2, including a likelihood ratio test, and then processes the results using the `deseq_polar` function to create a 'volc3d' object for plotting.
```r
library(DESeq2)
library(volcano3Ddata)
data("syn_txi")
syn_metadata$Pathotype <- factor(syn_metadata$Pathotype,
levels = c('Lymphoid', 'Myeloid', 'Fibroid'))
# setup initial dataset from Tximport
dds <- DESeqDataSetFromTximport(txi = syn_txi,
colData = syn_metadata,
design = ~ Pathotype + Batch + Gender)
# initial analysis run
dds_DE <- DESeq(dds)
# likelihood ratio test on 'Pathotype'
dds_LRT <- DESeq(dds, test = "LRT", reduced = ~ Batch + Gender, parallel = TRUE)
# create 'volc3d' class object for plotting
res <- deseq_polar(dds_DE, dds_LRT, "Pathotype")
```
--------------------------------
### Shiny Server Logic for Volcano3D App
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/vignettes/shiny_builder.rmd
The R code defines the server logic for the Volcano3D Shiny application. It handles user interactions, generates interactive plots (volcano plots, boxplots), and renders a data table with statistical information. Dependencies include the 'plotly', 'DT', 'ggplot2', and 'ggpubr' packages.
```r
server <- function(input, output, session) {
# Navitation tab: allow images to link to tabs
observeEvent(input$link_to_tabpanel_v, {
updateNavbarPage(session, "mainNavbarPage", "v")})
observeEvent(input$link_to_tabpanel_g, {
updateNavbarPage(session, "mainNavbarPage", "g")})
observeEvent(input$link_to_tabpanel_t, {
updateNavbarPage(session, "mainNavbarPage", "t")})
# Volcano tab: Create the 3D volcano plot
output$volcano <- renderPlotly({
data_type <- as.numeric(input$data_type)
if (length(data_type) == 0) data_type <- 1
p <- volcano3D(syn_polar,
type = data_type)
})
# Volcano tab: Create pathotype boxplots when genes clicked
output$boxplots <- renderPlot({
s <- event_data("plotly_click")
req(length(s) > 0)
gene = s$key
boxplot_trio(syn_polar,
value = gene,
test = "polar_pvalue",
step_increase = 0.1)
})
# Gene tab: create plots for selected genes
output$gene_plots <- renderPlot({
s <- input$gene
req(s != "")
# synovium pathotype boxplot
gene <- input$gene
path_plot <- boxplot_trio(syn_polar,
value = gene,
test = "polar_pvalue",
step_increase = 0.1)
df = cbind(syn_metadata, "expression"=syn_rld[gene, ])
# synovium gender boxplot
g_plot <- ggplot(df, aes(x=Gender, y=expression, fill=Gender)) +
geom_boxplot(outlier.shape=NA) +
geom_jitter(width=0.25, height=0) +
theme_classic() +
theme(legend.position="none")
# synovium batch boxplot
b_plot <- ggplot(df, aes(x=Batch, y=expression, fill=Batch)) +
geom_boxplot(outlier.shape=NA) +
geom_jitter(width=0.25, height=0) +
theme_classic() +
theme(legend.position="none")
ggarrange(path_plot, g_plot, b_plot, ncol=3, align="hv")
})
# Table Tab: create a data table of stats for upregulated genes.
output$full_table <- DT::renderDataTable({
pvals <- syn_polar@pvals
padj <- syn_polar@padj
colnames(pvals) <- c("P_LRT", "P_LvM", "P_LvF", "P_MvF")
colnames(padj) <- c("P_adj_LRT", "P_adj_LvM", "P_adj_LvF", "P_adj_MvF")
tab <- cbind(pvals, padj)
tab <- tab[order(tab[, 'P_LRT']), ]
groups <- input$group
tab <- tab[syn_polar@df[[1]]$lab %in% groups, ]
datatable(tab, options = list(
rowCallback = JS(
"function(row, data) {",
"for (i = 1; i < data.length; i++) {",
"if (data[i]>0 | data[i]<0){",
"$(\'td:eq(\'+i+\')\', row).html(data[i].toExponential(1));",
"}",
"}",
"}")
))
}, options = list(bInfo=TRUE))
}
```
--------------------------------
### CSS Styling for Layout and Badges
Source: https://github.com/katrionagoldmann/volcano3d/blob/master/docs/404.html
This CSS code defines styles for page layout elements such as left and right floats, and creates custom badge styles using pseudo-elements. The '.smadge:after' and '.bladge:after' rules are particularly noteworthy for dynamically adding text content to elements, likely for indicating specific types or states.
```css
#left {
float: left;
}
#right {
width: 100%;
position: relative;
text-align: right;
align: right;
float: right;
}
*.icon-grey {
color: lightgrey
}
j {
text-align: center;
vertical-align: middle;
position: relative;
padding-bottom: 12px;
}
.smadge:after {
content: "EMR";
position: absolute;
background: lightgrey;
height: 1.2rem;
top: 1rem;
right: -1rem;
width: 2.3rem;
text-align: center;
line-height: 1rem;
font-size: 1rem;
color: #cc0099;
border-radius: 10%;
}
.bladge:after {
content: "C4TB";
position: absolute;
background: lightgrey;
height: 1.2rem;
top: 1rem;
right: -1rem;
width: 2.7rem;
text-align: center;
line-height: 1rem;
font-size: 1rem;
color: #cc0099;
border-radius: 10%;
}
```