sp_volcano_plot: Generating volcano plot

View source: R/sp_volcano.R

sp_volcano_plotR Documentation

Generating volcano plot

Description

Generating volcano plot

Usage

sp_volcano_plot(
  data,
  geneL = NULL,
  log2fc_var = "log2FoldChange",
  fdr_var = "padj",
  coordinate_flip = FALSE,
  status_col_var = NULL,
  significance_threshold = c(0.05, 1),
  status_col_var_order = NULL,
  point_color_vector = c("#E6AAAA", "#9AD7EA", "#E6E5E5"),
  log10_transform_fdr = TRUE,
  max_allowed_log10p = Inf,
  max_allowed_log2fc = Inf,
  title = NULL,
  point_label_var = NULL,
  log2fc_symmetry = TRUE,
  alpha = NA,
  point_size = NULL,
  extra_ggplot2_cmd = NULL,
  filename = NULL,
  xtics_angle = 0,
  x_label = "Log2 fold change",
  y_label = "Negative log10 transformed qvalue",
  legend.position = "top",
  xintercept = "fc",
  yintercept = "fdr",
  ...
)

Arguments

data

Data frame or data file (with header line, the first column will not be treated as the rowname, tab separated)

geneL

Data frame or data file (with header line, the first column will not be treated as the rowname, tab separated)

log2fc_var

Name of fold change column.

fdr_var

Name of FDR or p-value column.

coordinate_flip

Default FALSE meaning log2fc_var in X-axis. Specify TRUE to make fdr_var in X-axis.

status_col_var

Name of the column containing labels of gene expression status like ⁠"No differnece", "UP-regulated", "Down-regulated"⁠. If exists, this column would be used to color each group of points. This parameter has higher priority than significance_threshold.

significance_threshold

Set the threshold for defining DE genes in format like c(pvalue,abs_log_fodchange). If this parameter is given, the program will generate status_col_var based on given thresholds.

status_col_var_order

Changing the order of status column values. Normally, the unique values of status column would be sorted alphabetically. For example, the order of ⁠"No difference", "UP-regulated", "Down-regulated"⁠ would be ⁠"Down-regulated", "No differnece", "UP-regulated"⁠. Here we can specify their order manually like ⁠"UP-regulated", "Down-regulated", "No differnece"⁠ to match the color specified below.

point_color_vector

Color vector. Default 'red, green, grey' for 'up, dw, nodiff' when status_col_var is not given. The order of color vector must match the order of levels of status_col_var.

log10_transform_fdr

Get -log10(pvalue) or -log10(fdr) for column given to fdr_var. Default FALSE, accept TRUE.

max_allowed_log10p

Maximum allowed -log10(pvalue). Default Inf meaning no limitation. Normally this should be set to 3 or 4 to make the output picture beautiful.

max_allowed_log2fc

Maximum allowed log2(foldchange). Default Inf meaning no limitation. Normally this should be set to 3 or 4 to make the output picture beautiful.

title

Title of picture.

point_label_var

Name of columns containing labels for points (representing genes, proteins or OTUs) to be labeled. Points with NA,- or “ value in this column will not be labeled.

log2fc_symmetry

Make coordinate axis symmetry to generate better visualization. Default TRUE.

alpha

Transparency of points (0-1). 0: opaque; 1: transparent.

point_size

Point size. Default 0.8. Accept a number of name of one column.

extra_ggplot2_cmd

Extra ggplot2 commands (currently unsupported)

filename

Output picture to given file.

xtics_angle

Rotation angle for a-axis. Default 0.

x_label

Xlab label.Default "Log2 fold change".

y_label

Ylab label.Default "Negative log10 transformed qvalue".

legend.position

Position of legend, accept top, bottom, left, right, none or c(0.8,0.8).

xintercept

Default 'fc' to show fold change lines. This needs significance_threshold. Specify NULL to hide lines.

yintercept

Default 'fdr' to show fdr lines. This needs significance_threshold. Specify NULL to hide lines.

...

Parameters given to sp_ggplot_layout

Value

A ggplot2 object

Examples


### Generate test data
res_output <- data.frame(log2FoldChange=rnorm(3000), row.names=paste0("ImageGP",1:3000))
res_output$padj <- 20 ^ (-1*(res_output$log2FoldChange^2))
padj = 0.05
log2FC = 1
res_output$level <- ifelse(res_output$padj<=padj,
                           ifelse(res_output$log2FoldChange>=log2FC,
                                  paste("groupA","UP"),
                                  ifelse(res_output$log2FoldChange<=(-1)*(log2FC),
                                         paste("groupB","UP"), "NoDiff")) , "NoDiff")
head(res_output)

volcanoPlot(res_output, )

## Not run:
input <- "KO-OE_all.txt"
volcano_plot(input,log2fc_var='Log2FoldChange',fdr_var='Padj',status_col_var='',
             title="sd",label="Label",log10_transform_fdr=TRUE,point_size=5)
## End(Not run)

Tong-Chen/ImageGP documentation built on April 14, 2025, 12:54 p.m.