ggpubr
ggpubr copied to clipboard
faceting MAplots?
Hello, I want to make a panel with multiple MA plots for my RNAseq data, but for some reason facet()
function does not recognize the column names?
I have a data frame, which was composed from multiple ones containing log2foldchange information for RNA seq of several species and different conditions measured:
> str(MA_data)
'data.frame': 518949 obs. of 8 variables:
$ baseMean : num 4082.9 454 483.6 11.6 23457.9 ...
$ log2FoldChange: num 5.00e-07 -3.20e-07 6.14e-08 3.41e-07 1.02e-06 ...
$ lfcSE : num 0.00144 0.00144 0.00144 0.00144 0.00144 ...
$ pvalue : num 0.986 0.682 0.981 0.528 0.141 ...
$ padj : num 0.998 0.978 0.997 0.955 0.8 ...
$ gene : chr "DN0c0g1" "DN0c0g2" "DN0c0g4" "DN0c12g1" ...
$ Condition : chr "Desiccated vs Hydrated" "Desiccated vs Hydrated" "Desiccated vs Hydrated" "Desiccated vs Hydrated" ...
$ species : chr "ZA17" "ZA17" "ZA17" "ZA17" ...
Then I go ahead to make a "frankenstein" plot (this works) to be split later:
ma <- ggmaplot(MA_data, fdr = 0.1, fc = 2, size = 0.4,
palette = c("#B31B21", "#1465AC", "darkgray"),
legend = "top", top = 20,
font.label = c("bold", 11),
font.legend = "bold",
font.main = "bold")
But when I use facet()
, there is an error:
facet(ma, facet.by = "species")
Error in `combine_vars()`:
! At least one layer must contain all faceting variables: `species`.
* Plot is missing `species`
* Layer 1 is missing `species`
* Layer 2 is missing `species`
* Layer 3 is missing `species`
I thought to facet the plot, the columns need to be present in the data rather than the plot? what am I doing wrong?
Best, Lisa
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.0.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] gridExtra_2.3 tidyr_1.2.1 ggpubr_0.4.0
[4] DESeq2_1.34.0 SummarizedExperiment_1.24.0 MatrixGenerics_1.6.0
[7] matrixStats_0.62.0 GenomicRanges_1.46.1 GenomeInfoDb_1.30.1
[10] IRanges_2.28.0 S4Vectors_0.32.4 dplyr_1.0.10
[13] ggplot2_3.3.6 genefilter_1.76.0 qvalue_2.26.0
[16] Biobase_2.54.0 BiocGenerics_0.40.0 cluster_2.1.4
loaded via a namespace (and not attached):
[1] httr_1.4.4 bit64_4.0.5 splines_4.1.2 carData_3.0-5
[5] assertthat_0.2.1 blob_1.2.3 GenomeInfoDbData_1.2.7 ggrepel_0.9.1
[9] pillar_1.8.1 RSQLite_2.2.17 backports_1.4.1 lattice_0.20-45
[13] glue_1.6.2 digest_0.6.29 RColorBrewer_1.1-3 XVector_0.34.0
[17] ggsignif_0.6.3 colorspace_2.0-3 Matrix_1.5-1 plyr_1.8.7
[21] XML_3.99-0.10 pkgconfig_2.0.3 broom_1.0.1 zlibbioc_1.40.0
[25] purrr_0.3.4 xtable_1.8-4 scales_1.2.1 BiocParallel_1.28.3
[29] tibble_3.1.8 annotate_1.72.0 KEGGREST_1.34.0 farver_2.1.1
[33] generics_0.1.3 car_3.1-0 ellipsis_0.3.2 cachem_1.0.6
[37] withr_2.5.0 cli_3.4.1 survival_3.4-0 magrittr_2.0.3
[41] crayon_1.5.2 memoise_2.0.1 fansi_1.0.3 rstatix_0.7.0
[45] tools_4.1.2 lifecycle_1.0.1 stringr_1.4.1 munsell_0.5.0
[49] locfit_1.5-9.6 ggsci_2.9 DelayedArray_0.20.0 AnnotationDbi_1.56.2
[53] Biostrings_2.62.0 compiler_4.1.2 rlang_1.0.6 grid_4.1.2
[57] RCurl_1.98-1.8 rstudioapi_0.14 labeling_0.4.2 bitops_1.0-7
[61] gtable_0.3.1 abind_1.4-5 DBI_1.1.3 reshape2_1.4.4
[65] R6_2.5.1 fastmap_1.1.0 bit_4.0.4 utf8_1.2.2
[69] stringi_1.7.8 parallel_4.1.2 Rcpp_1.0.9 vctrs_0.4.1
[73] geneplotter_1.72.0 png_0.1-7 tidyselect_1.1.2