# HG changeset patch # User iuc # Date 1623314292 0 # Node ID 83c573f2e73c21d744155dde64846a3ffc601e98 # Parent 44608d0193ed334ce1ae1d1f93a0186daafa6253 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/volcanoplot commit e880a5736a65605ae8a38ca9bc6f17c92c798ccd" diff -r 44608d0193ed -r 83c573f2e73c static/images/volcano_plot.png Binary file static/images/volcano_plot.png has changed diff -r 44608d0193ed -r 83c573f2e73c test-data/out.rscript --- 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() diff -r 44608d0193ed -r 83c573f2e73c volcanoplot.xml --- a/volcanoplot.xml Sun Jun 06 09:12:22 2021 +0000 +++ b/volcanoplot.xml Thu Jun 10 08:38:12 2021 +0000 @@ -1,4 +1,4 @@ - + create a volcano plot topic_0092 @@ -30,6 +30,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 ----------------------------------------------------------- @@ -42,12 +43,16 @@ # Import data ------------------------------------------------------------ -# Check if header is present by checking if P value column is numeric or not +#if $header == "yes" +results <- read.delim('$input', header = TRUE) +#elif $header == "no" +results <- read.delim('$input', header = FALSE) + +#else +# Auto-detect header by checking if P value column is numeric or not first_line <- read.delim('$input', header = FALSE, nrow = 1) - first_pvalue <- first_line[, $pval_col] - if (is.numeric(first_pvalue)) { print("No header row detected") results <- read.delim('$input', header = FALSE) @@ -55,7 +60,7 @@ print("Header row detected") results <- read.delim('$input', header = TRUE) } - +#end if # Format data ------------------------------------------------------------ @@ -75,28 +80,36 @@ # Create significant (sig) column results <- mutate(results, sig = case_when( - fdr < $signif_thresh & logfc > $lfc_thresh ~ up, - fdr < $signif_thresh & logfc < -$lfc_thresh ~ down, + fdr < $signif_thresh & logfc > $lfc_thresh ~ up, + fdr < $signif_thresh & logfc < -$lfc_thresh ~ down, TRUE ~ notsig)) ## R code below is left aligned for R script output #if $labels.label_select != "none" # Specify genes to label -------------------------------------------------- - #if $labels.label_select == "file" -labelfile <- read.delim('$labels.label_file') + + #if $labels.label_select == "file" +# Import file with genes of interest +labelfile <- read.delim('$labels.label_file', header = TRUE) + +# Label the genes of interest in results table results <- mutate(results, labels = ifelse(labels %in% labelfile[, 1], labels, "")) + #elif $labels.label_select == "signif" - #if $labels.top_num <= 0 -results <- mutate(results, labels = "") + #if not $labels.top_num +# Label all significant genes in results table +results <- mutate(results, labels=ifelse(sig != notsig, labels, "")) + #elif $labels.top_num > 0 -top <- results %>% - filter(sig != notsig) %>% - slice_min(order_by = pvalue, n = $labels.top_num) +# Get top genes by P value +top <- slice_min(results, order_by = pvalue, n = $labels.top_num) + +# Extract into vector toplabels <- pull(top, labels) + +# Label just the top genes in results table results <- mutate(results, labels = ifelse(labels %in% toplabels, labels, "")) - #else -results <- mutate(results, labels = ifelse(sig != notsig, labels, "")) #end if #end if #end if @@ -104,17 +117,34 @@ # 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()) +#if $labels.label_select != "none" +# Add gene labels + #if $plot_options.boxes +p <- p + geom_label_repel(data = filter(results, labels != ""), aes(label = labels), + min.segment.length = 0, + max.overlaps = Inf, + show.legend = FALSE) + #else +p <- p + geom_text_repel(data = filter(results, labels != ""), aes(label = labels), + min.segment.length = 0, + max.overlaps = Inf, + show.legend = FALSE) + #end if +#end if + #if not '$plot_options.title' p <- p + ggtitle('$plot_options.title') #end if @@ -137,39 +167,18 @@ # Set legend title #if not '$plot_options.legend' -p <- p + labs(colour = '$plot_options.legend') +p <- p + theme(legend.title = '$plot_options.legend') #else -p <- p + labs(colour = "") +p <- p + theme(legend.title = element_blank()) #end if -#if $labels.label_select != "none" -# Add gene labels in boxes - #if $plot_options.boxes -p <- p + geom_label_repel(aes(label = labels, fill = sig), - segment.colour = "black", - colour = "white", - min.segment.length = 0, - show.legend = FALSE) - #else -# Add gene labels -p <- p + geom_text_repel(aes(label = labels, col = sig), - min.segment.length = 0, - box.padding = 0.3, - point.padding = 0.3, - show.legend = FALSE) - #end if -#end if +# Print plot +print(p) -print(p) +# Close PDF graphics device dev.off() -#if $out_options.rdata_out -# Save RData ------------------------------------------------------------- -save.image(file="volcanoplot.RData") -#end if - - # R and Package versions ------------------------------------------------- sessionInfo() @@ -177,6 +186,11 @@ + + + + + @@ -198,7 +212,7 @@
- + @@ -209,21 +223,15 @@
- - - +
- + out_options['rscript_out'] - - out_options['rdata_out'] - @@ -236,7 +244,7 @@ - + @@ -252,13 +260,14 @@ - + - - + + + @@ -267,18 +276,12 @@ - - + - - - - - - + -
+
\ No newline at end of file