Mercurial > repos > iuc > volcanoplot
diff test-data/out.rscript @ 6:83c573f2e73c draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/volcanoplot commit e880a5736a65605ae8a38ca9bc6f17c92c798ccd"
author | iuc |
---|---|
date | Thu, 10 Jun 2021 08:38:12 +0000 |
parents | 44608d0193ed |
children |
line wrap: on
line diff
--- a/test-data/out.rscript Sun Jun 06 09:12:22 2021 +0000 +++ b/test-data/out.rscript Thu Jun 10 08:38:12 2021 +0000 @@ -7,6 +7,7 @@ # we need that to not crash galaxy with an UTF8 error on German LC settings. loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") +# Galaxy settings end ----------------------------------------------------- # Load packages ----------------------------------------------------------- @@ -19,19 +20,7 @@ # Import data ------------------------------------------------------------ -# Check if header is present by checking if P value column is numeric or not - -first_line <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmpfpemuuun/files/8/3/7/dataset_8374ef6b-02c7-46f1-afc9-408a2a6cbde4.dat', header = FALSE, nrow = 1) - -first_pvalue <- first_line[, 3] - -if (is.numeric(first_pvalue)) { - print("No header row detected") - results <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmpfpemuuun/files/8/3/7/dataset_8374ef6b-02c7-46f1-afc9-408a2a6cbde4.dat', header = FALSE) -} else { - print("Header row detected") - results <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmpfpemuuun/files/8/3/7/dataset_8374ef6b-02c7-46f1-afc9-408a2a6cbde4.dat', header = TRUE) -} +results <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmprh4qip75/files/d/2/2/dataset_d2255b46-f0f6-4900-8b9e-bd352e34f303.dat', header = TRUE) # Format data ------------------------------------------------------------ @@ -52,52 +41,57 @@ # Create significant (sig) column results <- mutate(results, sig = case_when( - fdr < 0.05 & logfc > 0.0 ~ up, - fdr < 0.05 & logfc < -0.0 ~ down, + fdr < 0.05 & logfc > 0.0 ~ up, + fdr < 0.05 & logfc < -0.0 ~ down, TRUE ~ notsig)) # Specify genes to label -------------------------------------------------- -labelfile <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmpfpemuuun/files/4/2/f/dataset_42fc8a63-f9cc-435b-9bb3-dd106b708cd9.dat') + +# Import file with genes of interest +labelfile <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmprh4qip75/files/5/e/5/dataset_5e5b8fb0-bf65-438e-9b5b-03a540d9aa5d.dat', header = TRUE) + +# Label the genes of interest in results table results <- mutate(results, labels = ifelse(labels %in% labelfile[, 1], labels, "")) + # Create plot ------------------------------------------------------------- -pdf("out.pdf") -p <- ggplot(results, aes(x = logfc, y = -log10(pvalue))) + +# Open file to save plot as PDF +pdf("volcano_plot.pdf") + +# Set up base plot +p <- ggplot(data = results, aes(x = logfc, y = -log10(pvalue))) + geom_point(aes(colour = sig)) + scale_color_manual(values = colours) + - scale_fill_manual(values = colours) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"), legend.key = element_blank()) +# Add gene labels +p <- p + geom_text_repel(data = filter(results, labels != ""), aes(label = labels), + min.segment.length = 0, + max.overlaps = Inf, + show.legend = FALSE) + # Set legend title -p <- p + labs(colour = "") +p <- p + theme(legend.title = element_blank()) -# Add gene labels in boxes -p <- p + geom_label_repel(aes(label = labels, fill = sig), - segment.colour = "black", - colour = "white", - min.segment.length = 0, - show.legend = FALSE) +# Print plot +print(p) -print(p) +# Close PDF graphics device dev.off() -# Save RData ------------------------------------------------------------- -save.image(file="volcanoplot.RData") - - # R and Package versions ------------------------------------------------- sessionInfo()