使用R包volcano3D绘制3D火山图-2020-07-06Mon

火山图通常在生信分析中会经常绘制的一种图形,通常用来展示比较组的差异基因、蛋白或代谢物的,也通常是绘制为2D形式。但是,如果我们给2D火山图增加一个维度,变成3D火山图呢?本文将介绍一个绘制3D火山图的R包:volcano3D。

volcano3D允许绘制三组之间的差异基因、蛋白或代谢物,设计之初的目的也是为了探究差异基因表达情况,可以绘制成三维的,而且可以转换为交互式动态格式的网页文件。

本文例子中也惯用volcano3D包中的测试数据,该数据是类风湿关节炎实验数据the PEAC rheumatoid arthritis trial (Pathobiology of Early Arthritis Cohort),相关参考文献见下面:

Lewis, Myles J., et al. Molecular portraits of early rheumatoid arthritis identify clinical and treatment response phenotypes. Cell reports 28.9 (2019): 2455-2470. (DOI: 10.1016/j.celrep.2019.07.091

相关在线工具网址为:https://peac.hpc.qmul.ac.uk

## 1.设置当前工作目录

setwd("./volcano3D/")

## 2.安装和导入R包:volcano3D

# install.packages("volcano3D")

library(volcano3D)

library(ggplot2)

library(ggpubr)

library(plotly)

## 3.R包简介

### 3.1 帮助信息

help(package="volcano3D")

# Package: volcano3D

# Type: Package

# Title: Interactive Plotting of Three-Way Differential Expression

# Analysis

# Version: 1.0.1

# [email protected]: c(person("Katriona", "Goldmann", role = c("aut", "cre"),

# email = "[email protected]"),

# person("Myles", "Lewis", role = c("aut", "ctb")))

# Maintainer: Katriona Goldmann <[email protected]>

# URL: Interactive Plotting of Three-Way Differential Expression Analysis,

# KatrionaGoldmann/volcano3D

# BugReports: KatrionaGoldmann/volcano3D

# Description: Differential expression (DE) analysis can be used to discover quantitative changes in expression levels between experimental groups. Such results are typically visualised using volcano plots, however in cases where more than two experimental groups are involved, visualising results can become convoluted and it quickly becomes difficult to see the wood for the trees. This package provides easy-to-use functions to extract and visualise outputs from DE between three groups (primarily aimed at 'limma' and 'DESeq2' outputs). We present novel methods to map DE results into polar coordinates to enable users to combine and simultaneously view three sets of results. These graphics also possess optional 'plotly' outputs for interactive and three-dimensional functionality, as seen in Lewis et. al. (2019) <doi:10.1016/j.celrep.2019.07.091>.

# Language: en-gb

# License: GPL-2

# Encoding: UTF-8

# LazyData: true

# Depends: R (>= 3.5)

# VignetteBuilder: knitr

# RoxygenNote: 7.1.0

# NeedsCompilation: no

# Packaged: 2020-06-26 15:43:50 UTC; kgoldmann

# Imports: plotly, ggplot2, ggpubr, ggrepel, methods

# Suggests: knitr, rmarkdown, kableExtra, usethis

# Author: Katriona Goldmann [aut, cre],

# Myles Lewis [aut, ctb]

# Repository: CRAN

# Date/Publication: 2020-06-26 17:20:03 UTC

# Built: R 3.6.3; ; 2020-06-28 23:39:01 UTC; windows

 

### 3.2 主要函数

ls(package:volcano3D)

# [1] "boxplot_trio" "polar_coords"

# [3] "polar_grid" "radial_ggplot"

# [5] "radial_plotly" "show_grid"

# [7] "syn_example_meta" "syn_example_p"

# [9] "syn_example_rld" "volcano_plot"

# [11] "volcano_trio" "volcano3D"

 

## 4.功能测试

data("example_data")

syn_polar <- polar_coords(sampledata = syn_example_meta,

contrast = "Pathotype",

pvalues = syn_example_p,

expression = syn_example_rld,

p_col_suffix = "pvalue",

padj_col_suffix = "padj",

fc_col_suffix = "log2FoldChange",

multi_group_prefix = "LRT",

non_sig_name = "Not Significant",

significance_cutoff = 0.01,

label_column = NULL,

fc_cutoff = 0.1)

class(syn_polar)

# [1] "polar"

# attr(,"package")

# [1] "volcano3D"

head([email protected])

# Fibroid_Lymphoid_pvalue Fibroid_Lymphoid_logFC

# FMOD 3.080821e-24 2.377676

# KCNIP3 1.618961e-23 2.575418

# TRIM29 1.642192e-23 4.301344

# CILP 3.004557e-23 4.159372

# CAB39L 2.440277e-23 2.176451

# PAMR1 8.429953e-22 2.666598

# Fibroid_Lymphoid_padj Lymphoid_Myeloid_pvalue

# FMOD 5.001712e-20 3.339001e-07

# KCNIP3 2.628222e-19 7.874796e-11

# TRIM29 2.665770e-19 5.329984e-19

# CILP 4.876696e-19 5.166450e-10

# CAB39L 3.961057e-19 3.537774e-07

# PAMR1 1.368181e-17 7.287287e-06

# Lymphoid_Myeloid_logFC Lymphoid_Myeloid_padj

# FMOD -1.096532 5.278293e-03

# KCNIP3 -1.538422 1.271543e-06

# TRIM29 -3.515507 8.651631e-15

# CILP -2.388539 8.326767e-06

# CAB39L -1.022201 5.589683e-03

# PAMR1 -1.144612 1.126032e-01

# Myeloid_Fibroid_pvalue Myeloid_Fibroid_logFC

# FMOD 2.050327e-06 -1.2811444

# KCNIP3 4.664822e-04 -1.0369961

# TRIM29 1.083911e-01 -0.7858377

# CILP 2.430993e-04 -1.7708331

# CAB39L 4.565418e-06 -1.1542502

# PAMR1 1.979054e-06 -1.5219853

# Myeloid_Fibroid_padj LRT_pvalue LRT_padj label

# FMOD 0.03325835 1.933555e-27 3.640110e-23 FMOD

# KCNIP3 1.00000000 4.340591e-27 4.085798e-23 KCNIP3

# TRIM29 1.00000000 1.253930e-26 7.868832e-23 TRIM29

# CILP 1.00000000 5.322664e-26 2.505112e-22 CILP

# CAB39L 0.07403282 7.133283e-26 2.685824e-22 CAB39L

# PAMR1 0.03210421 9.621579e-25 3.018931e-21 PAMR1

 

setNames(data.frame(table([email protected]$sig)), c("Significance", "Frequency"))

# Significance Frequency

# 1 Fibroid+ 9

# 2 Fibroid+Lymphoid+ 1

# 3 Fibroid+Myeloid+ 310

# 4 Lymphoid+ 124

# 5 Lymphoid+Myeloid+ 56

 

syn_plots <- volcano_trio(polar = syn_polar,

sig_names = c("not significant","significant",

"not significant","significant"),

colours = rep(c("grey60", "slateblue1"), 2),

text_size = 9,

marker_size=1,

shared_legend_size = 0.9,

label_rows = c("SLAMF6", "BOC", "FMOD"),

fc_line = FALSE,

share_axes = FALSE)

 

syn_plots$All

radial_plotly(polar = syn_polar, label_rows = c("SLAMF6", "GREM2", "FMOD"))

radial_ggplot(polar = syn_polar,

label_rows = c("SLAMF6", "FMOD", "GREM2"),

marker_size = 2.3,

legend_size = 10) +

theme(legend.position = "right")

plot1 <- boxplot_trio(syn_polar,

value = "SLAMF6",

text_size = 7,

test = "polar_padj",

my_comparisons=list(c("Lymphoid", "Myeloid"),

c("Lymphoid", "Fibroid")))

 

plot2 <- boxplot_trio(syn_polar,

value = "SLAMF6",

box_colours = c("violet", "gold2"),

levels_order = c("Lymphoid", "Fibroid"),

text_size = 7,

test = "polar_padj")

 

plot3 <- boxplot_trio(syn_polar,

value = "FMOD",

text_size = 7,

stat_size=2.5,

test = "polar_multi_padj",

levels_order = c("Lymphoid", "Myeloid", "Fibroid"),

box_colours = c("blue", "red", "green3"))

 

ggarrange(plot1, plot2, plot3, ncol=3)

p <- volcano3D(syn_polar,

label_rows = c("SLAMF6", "GREM2", "FMOD"),

label_size = 10,

xy_aspectratio = 1,

z_aspectratio = 0.9,

plot_height = 700)

p

 

p %>% plotly::config(toImageButtonOptions = list(format = "svg"))

 

plotly::orca(p, "./volcano_3d_synovium.svg", format = "svg")

citation("volcano3D")

#' 在出版物中使用程序包时引用‘volcano3D’:

#'

#' Katriona Goldmann and Myles Lewis (2020). volcano3D:

#' Interactive Plotting of Three-Way Differential

#' Expression Analysis. R package version 1.0.0.

#' CRAN - Package volcano3D

#'

#' A BibTeX entry for LaTeX users is

#'

#' @Manual{,

#' title = {volcano3D: Interactive Plotting of Three-Way Differential Expression

#' Analysis},

#' author = {Katriona Goldmann and Myles Lewis},

#' year = {2020},

#' note = {R package version 1.0.0},

#' url = {CRAN - Package volcano3D},

#' }

 

## 5.结束

sessionInfo()

# R version 3.6.3 (2020-02-29)

# Platform: x86_64-w64-mingw32/x64 (64-bit)

# Running under: Windows 10 x64 (build 18363)

#

# Matrix products: default

#

# locale:

# [1] LC_COLLATE=Chinese (Simplified)_China.936

# [2] LC_CTYPE=Chinese (Simplified)_China.936

# [3] LC_MONETARY=Chinese (Simplified)_China.936

# [4] LC_NUMERIC=C

# [5] LC_TIME=Chinese (Simplified)_China.936

#

# attached base packages:

# [1] stats graphics grDevices utils datasets

# [6] methods base

#

# other attached packages:

# [1] orca_1.1-1 htmlwidgets_1.5.1

#

# loaded via a namespace (and not attached):

# [1] Rcpp_1.0.4.6 plotly_4.9.2.1 rstudioapi_0.11

# [4] magrittr_1.5 tidyselect_1.1.0 munsell_0.5.0

# [7] viridisLite_0.3.0 colorspace_1.4-1 R6_2.4.1

# [10] rlang_0.4.6 httr_1.4.1 dplyr_1.0.0

# [13] tools_3.6.3 grid_3.6.3 packrat_0.5.0

# [16] data.table_1.12.8 gtable_0.3.0 htmltools_0.5.0

# [19] ellipsis_0.3.1 lazyeval_0.2.2 digest_0.6.25

# [22] tibble_3.0.1 lifecycle_0.2.0 crayon_1.3.4

# [25] tidyr_1.1.0 purrr_0.3.4 ggplot2_3.3.2

# [28] vctrs_0.3.1 glue_1.4.1 compiler_3.6.3

# [31] pillar_1.4.4 generics_0.0.2 scales_1.1.1

# [34] jsonlite_1.7.0 pkgconfig_2.0.3