### Install EnhancedVolcano Development Version Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Installs the development version of the EnhancedVolcano package directly from GitHub using the devtools package. This is useful for accessing the latest features or bug fixes. ```r devtools::install_github('kevinblighe/EnhancedVolcano') ``` -------------------------------- ### Install EnhancedVolcano from Bioconductor Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Installs the EnhancedVolcano package from Bioconductor using the BiocManager. This is the recommended way to install the stable version of the package. ```r if (!requireNamespace('BiocManager', quietly = TRUE)) install.packages('BiocManager') BiocManager::install('EnhancedVolcano') ``` -------------------------------- ### Highlight Key Variables via Custom Point Sizes Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Illustrates how to set custom point sizes for variables based on specific conditions, such as log2 fold change greater than 2. This example also includes data loading and preprocessing using DESeq2. ```R library("pasilla") pasCts <- system.file("extdata", "pasilla_gene_counts.tsv", package="pasilla", mustWork=TRUE) pasAnno <- system.file("extdata", "pasilla_sample_annotation.csv", package="pasilla", mustWork=TRUE) cts <- as.matrix(read.csv(pasCts,sep="\t",row.names="gene_id")) coldata <- read.csv(pasAnno, row.names=1) coldata <- coldata[,c("condition","type")] rownames(coldata) <- sub("fb", "", rownames(coldata)) cts <- cts[, rownames(coldata)] library("DESeq2") dds <- DESeqDataSetFromMatrix(countData = cts, colData = coldata, design = ~ condition) featureData <- data.frame(gene=rownames(cts)) mcols(dds) <- DataFrame(mcols(dds), featureData) dds <- DESeq(dds) res <- results(dds) p1 <- EnhancedVolcano(res, lab = rownames(res), x = "log2FoldChange", y = "pvalue", pCutoff = 10e-4, FCcutoff = 2, ylim = c(0, -log10(10e-12)), pointSize = c(ifelse(res$log2FoldChange>2, 8, 1)), labSize = 6.0, shape = c(6, 6, 19, 16), title = "DESeq2 results", subtitle = "Differential expression", caption = bquote(~Log[2]~ "fold change cutoff, 2; p-value cutoff, 10e-4"), legendPosition = "right", legendLabSize = 14, col = c("grey30", "forestgreen", "royalblue", "red2"), colAlpha = 0.9, drawConnectors = TRUE, hline = c(10e-8), widthConnectors = 0.5) p1 ``` -------------------------------- ### Adjust Legend Position, Size, and Text Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Customizes the legend's position, label size, and icon size. This example places the legend to the 'right' and increases the size of the text and icons. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', pCutoff = 10e-12, FCcutoff = 1.5, cutoffLineType = 'twodash', cutoffLineWidth = 0.8, pointSize = 4.0, labSize = 6.0, colAlpha = 1, legendLabels=c('Not sig.','Log (base 2) FC','p-value', 'p-value & Log (base 2) FC'), legendPosition = 'right', legendLabSize = 16, legendIconSize = 5.0) ``` -------------------------------- ### Adjust Shape of Plotted Points (Multiple Shapes) Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Customizes the shape of plotted points using multiple shape encodings. This example applies four different shapes based on the default conditional mapping. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', title = 'N061011 versus N61311', pCutoff = 10e-16, FCcutoff = 1.5, pointSize = 3.0, labSize = 6.0, shape = c(1, 4, 23, 25), colAlpha = 1) ``` -------------------------------- ### Adjust Shape of Plotted Points (Single Shape) Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Customizes the shape of plotted points. This example sets all points to a single shape (shape 8). The 'shape' parameter accepts a single value for uniform shaping or four values for conditional shaping. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', title = 'N061011 versus N61311', pCutoff = 10e-16, FCcutoff = 1.5, pointSize = 4.0, labSize = 6.0, shape = 8, colAlpha = 1) ``` -------------------------------- ### Adjust Cut-off Lines and Add Extra Threshold Lines Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Modifies the appearance of cut-off lines and adds custom horizontal and vertical threshold lines. This example disables default cut-off lines and adds multiple horizontal lines with different styles and colors. Gridlines are also disabled. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', xlim = c(-6, 6), title = 'N061011 versus N61311', pCutoff = 10e-12, FCcutoff = 1.5, pointSize = 3.0, labSize = 6.0, colAlpha = 1, cutoffLineType = 'blank', cutoffLineCol = 'black', cutoffLineWidth = 0.8, hline = c(10e-20, 10e-20 * 10e-30, 10e-20 * 10e-60, 10e-20 * 10e-90), hlineCol = c('pink', 'hotpink', 'purple', 'black'), hlineType = c('solid', 'longdash', 'dotdash', 'dotted'), hlineWidth = c(1.0, 1.5, 2.0, 2.5), gridlines.major = FALSE, gridlines.minor = FALSE) ``` -------------------------------- ### Load EnhancedVolcano Package Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Loads the EnhancedVolcano package into the current R session, making its functions available for use. ```r library(EnhancedVolcano) ``` -------------------------------- ### R Session Information Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Displays detailed information about the R session, including version, platform, locale settings, and a list of attached and loaded packages with their versions. This is crucial for reproducibility. ```R sessionInfo() ``` -------------------------------- ### EnhancedVolcano: Label Only Key Variables Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Shows how to label only specific key variables of interest in an EnhancedVolcano plot by using the 'selectLab' parameter. The selected variables must be present in the 'lab' vector. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', selectLab = c('TMEM178B','ADH1A'), xlab = bquote(~Log[2]~ 'fold change'), pCutoff = 10e-14, FCcutoff = 2.0, pointSize = 4.0, labSize = 6.0, shape = c(4, 35, 17, 18), colAlpha = 1, legendPosition = 'right', legendLabSize = 14, legendIconSize = 5.0) ``` -------------------------------- ### EnhancedVolcano: Add Connectors to Labels Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Demonstrates how to add connectors from labels to points in an EnhancedVolcano plot to maximize space and improve label visibility. Allows customization of connector width and color. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', xlab = bquote(~Log[2]~ 'fold change'), pCutoff = 10e-32, FCcutoff = 2.0, pointSize = 4.0, labSize = 6.0, colAlpha = 1, legendPosition = 'right', legendLabSize = 12, legendIconSize = 4.0, drawConnectors = TRUE, widthConnectors = 0.75) ``` -------------------------------- ### Displaying Multiple EnhancedVolcano Plots Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code uses the `gridExtra` and `grid` packages to arrange and display multiple EnhancedVolcano plots side-by-side. It combines the plots `p1` and `p2` into a single figure with a main title, facilitating comparison of different customization strategies. ```R library(gridExtra) library(grid) grid.arrange(p1, p2, ncol=2, top = textGrob('EnhancedVolcano', just = c('center'), gp = gpar(fontsize = 32))) ``` -------------------------------- ### EnhancedVolcano: Italicise Labels and Flip Plot Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Demonstrates how to italicize labels using 'parseLabels = TRUE' and flip the volcano plot orientation using 'coord_flip()'. This enhances label readability and offers an alternative visualization perspective. ```R lab_italics <- paste0("italic('", rownames(res), "')") selectLab_italics = paste0( "italic('", c('VCAM1','KCTD12','ADAM12', 'CXCL12','CACNB2','SPARCL1','DUSP1','SAMHD1','MAOA'), "')") EnhancedVolcano(res, lab = lab_italics, x = 'log2FoldChange', y = 'pvalue', selectLab = selectLab_italics, xlab = bquote(~Log[2]~ 'fold change'), pCutoff = 10e-14, FCcutoff = 1.0, pointSize = 3.0, labSize = 6.0, labCol = 'black', labFace = 'bold', boxedLabels = TRUE, parseLabels = TRUE, col = c('black', 'pink', 'purple', 'red3'), colAlpha = 4/5, legendPosition = 'bottom', legendLabSize = 14, legendIconSize = 4.0, drawConnectors = TRUE, widthConnectors = 1.0, colConnectors = 'black') + coord_flip() ``` -------------------------------- ### Generate Basic Volcano Plot Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Creates a basic volcano plot using the 'EnhancedVolcano' function. It requires a results object (e.g., from DESeq2) and specifies the columns for labels, log2 fold change, and p-value. Default cutoffs for log2FC (>|2|) and p-value (10e-6) are used. ```r EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue') ``` -------------------------------- ### Encircle Key Variables in Volcano Plot Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Demonstrates how to use the 'encircle' parameter to highlight specific variables in a volcano plot. This is useful for emphasizing 1-2 key variables, with 'shapeCustom' recommended for more complex identification. ```R celltype1 <- c('VCAM1','CXCL12') celltype2 <- c('SORT1', 'KLF15') EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', selectLab = c(celltype1, celltype2), xlab = bquote(~Log[2]~ 'fold change'), title = 'Shading cell-type 1|2', pCutoff = 10e-14, FCcutoff = 1.0, pointSize = 8.0, labSize = 6.0, labCol = 'black', labFace = 'bold', boxedLabels = TRUE, shape = 42, colCustom = keyvals, colAlpha = 1, legendPosition = 'right', legendLabSize = 20, legendIconSize = 20.0, # encircle encircle = celltype1, encircleCol = 'black', encircleSize = 2.5, encircleFill = 'pink', encircleAlpha = 1/2, # shade shade = celltype2, shadeAlpha = 1/2, shadeFill = 'skyblue', shadeSize = 1, shadeBins = 5, drawConnectors = TRUE, widthConnectors = 2.0, gridlines.major = TRUE, gridlines.minor = FALSE, border = 'full', borderWidth = 5, borderColour = 'black') ``` -------------------------------- ### EnhancedVolcano: Draw Labels in Boxes Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Illustrates how to draw boxes around labels in an EnhancedVolcano plot using the 'boxedLabels' parameter for improved clarity. This feature works best when 'drawConnectors' is also enabled. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', selectLab = c('VCAM1','KCTD12','ADAM12', 'CXCL12','CACNB2','SPARCL1','DUSP1','SAMHD1','MAOA'), xlab = bquote(~Log[2]~ 'fold change'), pCutoff = 10e-14, FCcutoff = 2.0, pointSize = 4.0, labSize = 6.0, labCol = 'black', labFace = 'bold', boxedLabels = TRUE, colAlpha = 4/5, legendPosition = 'right', legendLabSize = 14, legendIconSize = 4.0, drawConnectors = TRUE, widthConnectors = 1.0, colConnectors = 'black') ``` -------------------------------- ### Prepare Airway Data for Volcano Plot Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Loads and prepares the 'airway' dataset for differential expression analysis. This involves releveling the 'dex' factor and annotating Ensembl gene IDs to gene symbols. ```r library(airway) library(magrittr) data('airway') airway$dex %<>% relevel('untrt') ens <- rownames(airway) library(org.Hs.eg.db) symbols <- mapIds(org.Hs.eg.db, keys = ens, column = c('SYMBOL'), keytype = 'ENSEMBL') symbols <- symbols[!is.na(symbols)] symbols <- symbols[match(rownames(airway), names(symbols))] rownames(airway) <- symbols keep <- !is.na(rownames(airway)) airway <- airway[keep,] ``` -------------------------------- ### Perform Differential Expression Analysis with DESeq2 Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Conducts differential expression analysis on the prepared 'airway' data using DESeq2. It fits the model, performs the test, and shrinks the log2 fold changes for improved accuracy. ```r library('DESeq2') dds <- DESeqDataSet(airway, design = ~ cell + dex) dds <- DESeq(dds, betaPrior=FALSE) res <- results(dds, contrast = c('dex','trt','untrt')) res <- lfcShrink(dds, contrast = c('dex','trt','untrt'), res=res, type = 'normal') ``` -------------------------------- ### Customize Volcano Plot with Cutoffs and Aesthetics Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Generates a customized volcano plot with modified cutoffs for p-value (10e-32) and log2FC (0.5). It also adjusts the point size (3.0) and label size (6.0) for better readability and specifies a custom title for the plot. ```r EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', title = 'N061011 versus N61311', pCutoff = 10e-32, FCcutoff = 0.5, pointSize = 3.0, labSize = 6.0) ``` -------------------------------- ### Continuous Colour Scheme in Volcano Plot Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Explains how to override the default discrete color scheme with a continuous gradient based on p-value using the 'colGradient' parameter. This allows shading between two specified colors. ```R p1 <- EnhancedVolcano(res, lab = rownames(res), x = "log2FoldChange", y = "pvalue", pCutoff = 10e-4, FCcutoff = 2, ylim = c(0, -log10(10e-12)), pointSize = c(ifelse(res$log2FoldChange>2, 8, 1)), labSize = 6.0, shape = c(6, 6, 19, 16), title = "DESeq2 results", subtitle = "Differential expression", caption = bquote(~Log[2]~ "fold change cutoff, 2; p-value cutoff, 10e-4"), legendPosition = "right", legendLabSize = 14, colAlpha = 0.9, colGradient = c('red3', 'royalblue'), drawConnectors = TRUE, hline = c(10e-8), widthConnectors = 0.5) p1 ``` -------------------------------- ### Custom Color Mapping by Fold-Change Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code snippet demonstrates how to create custom color mappings for an EnhancedVolcano plot based on log2 fold-change values. It assigns 'gold' to high expression (log2FC > 2.5), 'royalblue' to low expression (log2FC < -2.5), and 'black' to intermediate expression. The resulting named vector is then used with the `colCustom` argument in EnhancedVolcano. ```R keyvals <- ifelse( res$log2FoldChange < -2.5, 'royalblue', ifelse(res$log2FoldChange > 2.5, 'gold', 'black')) keyvals[is.na(keyvals)] <- 'black' names(keyvals)[keyvals == 'gold'] <- 'high' names(keyvals)[keyvals == 'black'] <- 'mid' names(keyvals)[keyvals == 'royalblue'] <- 'low' ``` -------------------------------- ### Hide Legend Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Demonstrates how to make the legend completely invisible by setting the 'legendPosition' parameter to 'none'. ```R legendPosition = 'none' ``` -------------------------------- ### Adjust Color and Alpha for Point Shading Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Modifies the color scheme and transparency of points in the volcano plot. Points passing specified log2FC and P-value thresholds are colored red, while others are black. Alpha controls point transparency. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', title = 'N061011 versus N61311', pCutoff = 10e-16, FCcutoff = 1.5, pointSize = 3.0, labSize = 6.0, col=c('black', 'black', 'black', 'red3'), colAlpha = 1) ``` -------------------------------- ### EnhancedVolcano Plot with Custom Color Override Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code generates an EnhancedVolcano plot, overriding the default color scheme using the `colCustom` argument. It highlights genes with log2 fold-change values above 2.5 as 'high' and below -2.5 as 'low', using a pre-defined `keyvals` vector. The plot includes custom labels, axis titles, and styling for points, labels, and connectors. ```R EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', selectLab = rownames(res)[which(names(keyvals) %in% c('high', 'low'))], xlab = bquote(~Log[2]~ 'fold change'), title = 'Custom colour over-ride', pCutoff = 10e-14, FCcutoff = 1.0, pointSize = 3.5, labSize = 4.5, shape = c(6, 4, 2, 11), colCustom = keyvals, colAlpha = 1, legendPosition = 'left', legendLabSize = 15, legendIconSize = 5.0, drawConnectors = TRUE, widthConnectors = 1.0, colConnectors = 'black', arrowheads = FALSE, gridlines.major = TRUE, gridlines.minor = FALSE, border = 'partial', borderWidth = 1.5, borderColour = 'black') ``` -------------------------------- ### Custom Shape Mapping by Cell Type Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code defines custom shape mappings for an EnhancedVolcano plot based on cell types. It assigns specific shape codes (17, 64, 3) to different cell type groups ('Cell-type 1', 'Cell-type 2', 'PBMC') and creates a named vector `keyvals.shape` for use with the `shapeCustom` argument. ```R celltype1 <- c('VCAM1','KCTD12','ADAM12','CXCL12') celltype2 <- c('CACNB2','SPARCL1','DUSP1','SAMHD1','MAOA') keyvals.shape <- ifelse( rownames(res) %in% celltype1, 17, ifelse(rownames(res) %in% celltype2, 64, 3)) keyvals.shape[is.na(keyvals.shape)] <- 3 names(keyvals.shape)[keyvals.shape == 3] <- 'PBMC' names(keyvals.shape)[keyvals.shape == 17] <- 'Cell-type 1' names(keyvals.shape)[keyvals.shape == 64] <- 'Cell-type 2' ``` -------------------------------- ### Custom Color Mapping for Fold-Change (Revisited) Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code snippet redefines custom color mappings based on log2 fold-change values, assigning 'gold' for high expression, 'royalblue' for low expression, and 'black' for intermediate. This is used in conjunction with custom shapes for a combined aesthetic override. ```R keyvals.colour <- ifelse( res$log2FoldChange < -2.5, 'royalblue', ifelse(res$log2FoldChange > 2.5, 'gold', 'black')) keyvals.colour[is.na(keyvals.colour)] <- 'black' names(keyvals.colour)[keyvals.colour == 'gold'] <- 'high' names(keyvals.colour)[keyvals.colour == 'black'] <- 'mid' names(keyvals.colour)[keyvals.colour == 'royalblue'] <- 'low' ``` -------------------------------- ### EnhancedVolcano Plot with Custom Shape and Color Override Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code generates an EnhancedVolcano plot that simultaneously overrides both the shape and color schemes. It uses `keyvals.shape` for custom shapes based on cell types and `keyvals.colour` for colors based on fold-change. The plot features custom labels, axis titles, and distinct legend positioning. ```R p2 <- EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', selectLab = rownames(res)[which(names(keyvals) %in% c('High', 'Low'))], xlab = bquote(~Log[2]~ 'fold change'), title = 'Custom shape & colour over-ride', pCutoff = 10e-14, FCcutoff = 1.0, pointSize = 5.5, labSize = 0.0, shapeCustom = keyvals.shape, colCustom = keyvals.colour, colAlpha = 1, legendPosition = 'right', legendLabSize = 15, legendIconSize = 5.0, drawConnectors = TRUE, widthConnectors = 0.5, colConnectors = 'grey50', gridlines.major = TRUE, gridlines.minor = FALSE, border = 'full', borderWidth = 1.0, borderColour = 'black') ``` -------------------------------- ### EnhancedVolcano Plot with Custom Shape Override Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md This R code generates an EnhancedVolcano plot with a custom shape scheme applied using `shapeCustom`. It highlights specific cell types with distinct shapes, while `colCustom` is set to NULL to use default coloring. The plot includes custom labels, axis titles, and styling for points and connectors. ```R p1 <- EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', selectLab = rownames(res)[which(names(keyvals) %in% c('high', 'low'))], xlab = bquote(~Log[2]~ 'fold change'), title = 'Custom shape over-ride', pCutoff = 10e-14, FCcutoff = 1.0, pointSize = 4.5, labSize = 4.5, shapeCustom = keyvals.shape, colCustom = NULL, colAlpha = 1, legendLabSize = 15, legendPosition = 'left', legendIconSize = 5.0, drawConnectors = TRUE, widthConnectors = 0.5, colConnectors = 'grey50', gridlines.major = TRUE, gridlines.minor = FALSE, border = 'partial', borderWidth = 1.5, borderColour = 'black') ``` -------------------------------- ### Custom Axis Tick Marks with ggplot2 Source: https://github.com/kevinblighe/enhancedvolcano/blob/master/README.md Demonstrates how to customize axis tick marks in an EnhancedVolcano plot by integrating ggplot2's coordinate and scale functions, such as 'coord_cartesian' and 'scale_x_continuous'. ```R p1 + ggplot2::coord_cartesian(xlim=c(-6, 6)) + ggplot2::scale_x_continuous( breaks=seq(-6,6, 1)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.