plot_disco: Create a disco plot

View source: R/plot.R

plot_discoR Documentation

Create a disco plot

Description

Make a concordance / discordance plots for two contrasts

Usage

plot_disco(
  contrast1,
  contrast2,
  lower = -100,
  upper = 100,
  show_top_labels = 0,
  top_labels_both = TRUE,
  annot1 = NULL,
  annot2 = NULL,
  alpha = 0.5,
  disco = NULL,
  by = 0,
  primary_id = "PrimaryID",
  label_col = "SYMBOL",
  label_sel = NULL
)

Arguments

contrast1, contrast2

data frames with rownames corresponding to IDs (they don't need to be in the same order) and columns log2FoldChange and pvalue.

lower, upper

lower and upper boundaries for coloring of the score

show_top_labels

sort the genes by descending absolute disco score and show top N labels

top_labels_both

should top labels from both negative and positive disco scores be shown, or only for the absolute top, whether only negative or only positive or both?

annot1, annot2

annotation data frames for the two contrasts

alpha

transparency

disco

result of disco_score; if provided, it will be used to avoid unnecessary computations

by

column by which the contrast data frames should be merged (passed to merge). Default: merge by row names

primary_id

the name which should be assigned to the identifier column which results from the merge

label_col

name of the column in annot which should be used for labels

label_sel

identifiers of labels to be shown on the plot

Details

A concordance / discordance plot is simply a log~2~ FC vs log~2~ FC comparison between two contrasts. Disco score is a heuristic score reflecting the strength of similarity or dissimilarity between two log~2~ FC values weighted by the corresponding p-values and given by the formula log2FC.x * log2FC.y * (-log10(pval.x) - log10(pval.y)).

To manually select which labels to show, use a truncated annot object – remove all rows you don't want to show, and set the show_top_labels parameter to Inf.

Value

a ggplot object (plot)

Examples

## Generate example data
c1 <- data.frame(log2FoldChange=rnorm(5000, sd=2))
c1$pvalue <- pnorm(abs(c1$log2FoldChange), sd=2, lower.tail=FALSE)
c1$PrimaryID <- paste0("ID", 1:nrow(c1))

c2 <- data.frame(log2FoldChange=c1$log2FoldChange + rnorm(5000, sd=3))
c2$pvalue <- pnorm(abs(c2$log2FoldChange), sd=2, lower.tail=FALSE)
c2$PrimaryID <- paste0("ID", 1:nrow(c2))

## Example disco plot
plot_disco(c1, c2)

bihealth/bioshmods documentation built on July 1, 2023, 4:32 a.m.