kevinblighe / EnhancedVolcano

Publication-ready volcano plots with enhanced colouring and labeling
412 stars 81 forks source link

Feature request: custom point size #18

Closed proteostasis closed 5 years ago

proteostasis commented 5 years ago

Color and shape of points can be customized based on key-value pairs which is great, but unless I missed it it appears I can't customize point size. This would be useful for encoding another attribute such as intensity.

kevinblighe commented 5 years ago

Hey proteostasis, indeed, this is not currently implemented; however, my plan is to implement it in the next version.

Currently, you can use different sizes indirectly by specifying different shapes. For example, using shapes 46, 20, and 19 will already give you three different circle sizes. All shapes are here: http://sape.inf.usi.ch/quick-reference/ggplot2/shape

Otherwise, I will have to get back to this when I get the time. This issue will therefore be left open for now.

Kind regards, Kevin

proteostasis commented 5 years ago

Hi Kevin, Thanks for your reply and your effort developing this package. I will bin the data and use your suggestion for now; looking forward to having access to a continuous size parameter! Best, Peter

kevinblighe commented 5 years ago

Hey Peter,

I have been addressing some GitHub issues since yesterday, and now it's the turn for this issue! :)

I realised that it's actually already possible to provide a vector of custom sizes. The way that I have programmed EnhancedVolcano permits this. For example, take a look at this reproducible example, where I have everything at log2FC>2 as point size 8, while everything else is just 1:

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)

require(EnhancedVolcano)
EnhancedVolcano(res,
  lab = rownames(res),
  x = "log2FoldChange",
  y = "pvalue",
  pCutoff = 10e-4,
  FCcutoff = 1.333,
  xlim = c(-5.5, 5.5),
  ylim = c(0, -log10(10e-12)),
  #pointSize = c(ifelse(res$log2FoldChange>2, 8, 1)),
  labSize = 2.5,
  shape = c(6, 6, 19, 16),
  title = "DESeq2 results",
  subtitle = "Differential expression",
  caption = "FC cutoff, 1.333; 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)

aaaa

I will close this issue for now. If this does not resolve your question, then please feel free to re-open this.

Kind regards, Kevin