Problem selectively labelling points in the Enhanced Volcano package
1
0
Entering edit mode
Peter ▴ 10
@Peter-24438
Last seen 3.9 years ago

I'm using the Enhanced Volcano package to represent my DE proteins on a volcano plot. Drawing the plot isn't an issue but selectively labeling points of interest is. The two points I want to label are present in the data and exceed the cutoff I have set for PCutoff and FCcutoff. According the the package vignette the necessary code is

EnhancedVolcano(res,
    lab = rownames(res),
    x = 'log2FoldChange',
    y = 'pvalue',
    selectLab = c('TMEM176B','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)

My code is

EnhancedVolcano(volcano_rd,
    lab = 'volcano_rd$DE_Proteins',
    x = 'log2FC',
    y = 'pvalue',
    xlim = c(-5, 5),
    ylim = c(0, 8),
    selectLab = c('RRP1B', 'PLIN2'),
    xlab = bquote(~Log[2]~ 'FC'),
    pointSize = 3.0,
    labSize = 6.0,
    pCutoff = 0.0001,
    FCcutoff = 1.2,
    cutoffLineType = 'twodash',
    cutoffLineWidth = 0.8,
    col=c('orange', 'green','pink', 'blue'),
    colAlpha = 1,
    legendPosition = 'right',
    legendLabSize = 16,
    legendIconSize = 5.0)

  dev.off()

I think the issue is with the line

`xlab = bquote(~Log[2]~ 'FC')`,

but I don't understand what this line does and don't know what to change. FC is the column in my data which I then perform the log2 transformation on.

The structure of my data

str(volcano_rd)
'data.frame':   1191 obs. of  4 variables:
 $ pvalue    : num  0.007987 0.000869 0.00104 0.001904 0.003591 ...
 $ log2FC    : num  0.481 0.383 0.766 0.595 0.773 ...
 $ FC        : num  1.4 1.3 1.7 1.51 1.71 ...
 $ DE_Protein: chr  "AAAS" "AARS" "ABCB6" "ABCB7" ...

sessionInfo output

sessionInfo()

R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale: [1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252 LC_MONETARY=English_Ireland.1252 [4] LC_NUMERIC=C LC_TIME=English_Ireland.1252

attached base packages: [1] grid parallel stats4 stats graphics grDevices utils datasets methods base

other attached packages: [1] ggpubr_0.4.0.999 EnhancedVolcano_1.6.0 ggrepel_0.8.2 pheatmap_1.0.12 data.table_1.13.4
[6] RColorBrewer_1.1-2 NMF_0.23.0 cluster_2.1.0 rngtools_1.5 pkgmaker_0.32.2
[11] registry_0.5-1 limma_3.44.3 preprocessCore_1.50.0 VennDiagram_1.6.20 futile.logger_1.4.3
[16] splitstackshape_1.4.8 magrittr_2.0.1 AnnotationHub_2.20.2 BiocFileCache_1.12.1 dbplyr_2.0.0
[21] clusterProfiler_3.16.1 GO.db_3.11.4 AnnotationDbi_1.50.3 IRanges_2.22.2 S4Vectors_0.26.1
[26] Biobase_2.48.0 BiocGenerics_0.34.0 reshape_0.8.8 forcats_0.5.0 stringr_1.4.0
[31] dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 tibble_3.0.4
[36] ggplot2_3.3.2 tidyverse_1.3.0 plyr_1.8.6 biomaRt_2.44.4

loaded via a namespace (and not attached): [1] readxl_1.3.1 backports_1.2.0 fastmatch_1.1-0 igraph_1.2.6
[5] splines_4.0.2 BiocParallel_1.22.0 gridBase_0.4-7 urltools_1.7.3
[9] digest_0.6.25 foreach_1.5.1 htmltools_0.5.0 GOSemSim_2.14.2
[13] viridis_0.5.1 fansi_0.4.1 memoise_1.1.0 doParallel_1.0.16
[17] openxlsx_4.2.3 graphlayouts_0.7.1 modelr_0.1.8 askpass_1.1
[21] enrichplot_1.8.1 prettyunits_1.1.1 colorspace_2.0-0 blob_1.2.1
[25] rvest_0.3.6 rappdirs_0.3.1 haven_2.3.1 xfun_0.17
[29] crayon_1.3.4 jsonlite_1.7.2 scatterpie_0.1.5 iterators_1.0.13
[33] glue_1.4.2 polyclip_1.10-0 gtable_0.3.0 car_3.0-10
[37] abind_1.4-5 scales_1.1.1 DOSE_3.14.0 futile.options_1.0.1
[41] DBI_1.1.0 rstatix_0.6.0 Rcpp_1.0.5 viridisLite_0.3.0
[45] xtable_1.8-4 progress_1.2.2 gridGraphics_0.5-1 foreign_0.8-80
[49] bit_4.0.4 europepmc_0.4 httr_1.4.2 fgsea_1.14.0
[53] ellipsis_0.3.1 pkgconfig_2.0.3 XML_3.99-0.5 farver_2.0.3
[57] labeling_0.4.2 ggplotify_0.0.5 tidyselect_1.1.0 rlang_0.4.7
[61] reshape2_1.4.4 later_1.1.0.1 munsell_0.5.0 BiocVersion_3.11.1
[65] cellranger_1.1.0 tools_4.0.2 downloader_0.4 cli_2.2.0
[69] generics_0.1.0 RSQLite_2.2.1 broom_0.7.3 ggridges_0.5.2
[73] evaluate_0.14 fastmap_1.0.1 yaml_2.2.1 knitr_1.30
[77] bit64_4.0.5 fs_1.5.0 tidygraph_1.2.0 zip_2.1.1
[81] ggraph_2.0.4 mime_0.9 formatR_1.7 DO.db_2.9
[85] xml2_1.3.2 compiler_4.0.2 rstudioapi_0.13 curl_4.3
[89] interactiveDisplayBase_1.26.3 ggsignif_0.6.0 reprex_0.3.0 tweenr_1.0.1
[93] stringi_1.5.3 lattice_0.20-41 Matrix_1.2-18 vctrs_0.3.5
[97] pillar_1.4.7 lifecycle_0.2.0 BiocManager_1.30.10 triebeard_0.3.0
[101] cowplot_1.1.0 httpuv_1.5.4 qvalue_2.20.0 R6_2.5.0
[105] promises_1.1.1 rio_0.5.16 gridExtra_2.3 codetools_0.2-16
[109] lambda.r_1.2.4 MASS_7.3-51.6 assertthat_0.2.1 openssl_1.4.3
[113] withr_2.3.0 hms_0.5.3 rmarkdown_2.6 rvcheck_0.1.8
[117] carData_3.0-4 ggforce_0.3.2 shiny_1.5.0 lubridate_1.7.9.2

Any suggestions would be appreciated.

Peter

EnhancedVolcano • 3.9k views
ADD COMMENT
0
Entering edit mode
Kevin Blighe ★ 4.0k
@kevin
Last seen 14 days ago
Republic of Ireland

'RRP1B', 'PLIN2' have to be members of volcano_rd$DE_Proteins - can you confirm that they are [members]?

Kevin

ADD COMMENT
0
Entering edit mode

Yes they are. Values used to plot each are below

  pvalue        log2FC   FC  DE_Protein

  1. 5.572771e-08 1.3419857 2.535 RRP1B
  2. 9.608585e-06 2.5983652 6.056 PLIN2
ADD REPLY
0
Entering edit mode

Can you add drawConnectors = TRUE?

ADD REPLY
0
Entering edit mode

So my code is now this

    EnhancedVolcano(volcano_rd,
    lab = 'volcano_rd$DE_Proteins',
    x = 'log2FC',
    y = 'pvalue',
    xlim = c(-8, 8),
    ylim = c(0, 8),
    selectLab = c('RRP1B', 'PLIN2'),
    xlab = bquote(~Log[2]~ 'FC'),
    drawConnectors = TRUE,
    pointSize = 3.0,
    labSize = 6.0,
    pCutoff = 0.0001,
    FCcutoff = 1.2,
    cutoffLineType = 'twodash',
    cutoffLineWidth = 0.8,
    col=c('orange', 'green','pink', 'blue'),
    colAlpha = 1,
    legendPosition = 'right',
    legendLabSize = 16,
    legendIconSize = 5.0)

  dev.off()

Still no labels.

Kevin, is there an easy way to send you my entire dataset and that way you can reproduce the full volcano plot I see? Obviously the dataset contains more than 2 points.

What I really want to achieve is to label only the points which exceed the LogFC and pvalue thresholds that I set. The 2 named in my code below are the 2 most extreme examples.

ADD REPLY
0
Entering edit mode

Wait the issue is that you are passing a character string to lab. You just need to change it to:

lab = volcano_rd$DE_Proteins,

[without the aostrophes]

ADD REPLY
0
Entering edit mode

Tried that but now it doesn't draw the plot at all. It resulted in the following error.

Error in `$<-.data.frame`(`*tmp*`, "lab", value = logical(0)) : replacement has 0 rows, data has 1191

the output from traceback()

4: stop(sprintf(ngettext(N, "replacement has %d row, data has %d", 
       "replacement has %d rows, data has %d"), N, nrows), domain = NA)
3: `$<-.data.frame`(`*tmp*`, "lab", value = logical(0))
2: `$<-`(`*tmp*`, "lab", value = logical(0))
1: EnhancedVolcano(volcano_rd, lab = volcano_rd$DE_Proteins, x = "log2FC", 
       y = "pvalue", xlim = c(-8, 8), ylim = c(0, 8), selectLab = c("RRP1B", 
           "PLIN2"), xlab = bquote(~Log[2] ~ "FC"), drawConnectors = TRUE, 
       pointSize = 3, labSize = 6, pCutoff = 1e-04, FCcutoff = 1.2, 
       cutoffLineType = "twodash", cutoffLineWidth = 0.8, col = c("orange", 
           "green", "pink", "blue"), colAlpha = 1, legendPosition = "right", 
       legendLabSize = 16, legendIconSize = 5)

The code I used is

 EnhancedVolcano(volcano_rd,
    lab = volcano_rd$DE_Proteins,
    x = 'log2FC',
    y = 'pvalue',
    xlim = c(-8, 8),
    ylim = c(0, 8),
    selectLab = c('RRP1B', 'PLIN2'),
    xlab = bquote(~Log[2]~ 'FC'),
    drawConnectors = TRUE,
    pointSize = 3.0,
    labSize = 6.0,
    pCutoff = 0.0001,
    FCcutoff = 1.2,
    cutoffLineType = 'twodash',
    cutoffLineWidth = 0.8,
    col=c('orange', 'green','pink', 'blue'),
    colAlpha = 1,
    legendPosition = 'right',
    legendLabSize = 16,
    legendIconSize = 5.0)

  dev.off()
2: `$<-`(`*tmp*`, "lab", value = logical(0))
1: EnhancedVolcano(volcano_rd, lab = volcano_rd$DE_Proteins, x = "log2FC", 
       y = "pvalue", xlim = c(-8, 8), ylim = c(0, 8), selectLab = c("RRP1B", 
           "PLIN2"), xlab = bquote(~Log[2] ~ "FC"), drawConnectors = TRUE, 
       pointSize = 3, labSize = 6, pCutoff = 1e-04, FCcutoff = 1.2, 
       cutoffLineType = "twodash", cutoffLineWidth = 0.8, col = c("orange", 
           "green", "pink", "blue"), colAlpha = 1, legendPosition = "right", 
       legendLabSize = 16, legendIconSize = 5)
ADD REPLY
0
Entering edit mode

It should be 'DE_Protein' it seems

ADD REPLY
1
Entering edit mode

and we have a winner. Thanks for all your help.

ADD REPLY

Login before adding your answer.

Traffic: 736 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6