Previous changeset 5:44608d0193ed (2021-06-06) Next changeset 7:a363ba287b88 (2024-05-15) |
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/volcanoplot commit e880a5736a65605ae8a38ca9bc6f17c92c798ccd" |
modified:
static/images/volcano_plot.png test-data/out.rscript volcanoplot.xml |
b |
diff -r 44608d0193ed -r 83c573f2e73c static/images/volcano_plot.png |
b |
Binary file static/images/volcano_plot.png has changed |
b |
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() |
b |
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 |
[ |
b'@@ -1,4 +1,4 @@\n-<tool id="volcanoplot" name="Volcano Plot" version="0.0.4">\n+<tool id="volcanoplot" name="Volcano Plot" version="0.0.5">\n <description>create a volcano plot</description>\n <edam_topics>\n <edam_topic>topic_0092</edam_topic>\n@@ -30,6 +30,7 @@\n # we need that to not crash galaxy with an UTF8 error on German LC settings.\n loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")\n \n+# Galaxy settings end -----------------------------------------------------\n \n # Load packages -----------------------------------------------------------\n \n@@ -42,12 +43,16 @@\n \n # Import data ------------------------------------------------------------\n \n-# Check if header is present by checking if P value column is numeric or not\n+#if $header == "yes"\n+results <- read.delim(\'$input\', header = TRUE)\n \n+#elif $header == "no"\n+results <- read.delim(\'$input\', header = FALSE)\n+\n+#else\n+# Auto-detect header by checking if P value column is numeric or not\n first_line <- read.delim(\'$input\', header = FALSE, nrow = 1)\n-\n first_pvalue <- first_line[, $pval_col]\n-\n if (is.numeric(first_pvalue)) {\n print("No header row detected")\n results <- read.delim(\'$input\', header = FALSE)\n@@ -55,7 +60,7 @@\n print("Header row detected")\n results <- read.delim(\'$input\', header = TRUE)\n }\n-\n+#end if\n \n # Format data ------------------------------------------------------------\n \n@@ -75,28 +80,36 @@\n \n # Create significant (sig) column\n results <- mutate(results, sig = case_when(\n- fdr < $signif_thresh & logfc > $lfc_thresh ~ up, \n- fdr < $signif_thresh & logfc < -$lfc_thresh ~ down, \n+ fdr < $signif_thresh & logfc > $lfc_thresh ~ up,\n+ fdr < $signif_thresh & logfc < -$lfc_thresh ~ down,\n TRUE ~ notsig))\n \n ## R code below is left aligned for R script output\n \n #if $labels.label_select != "none"\n # Specify genes to label --------------------------------------------------\n- #if $labels.label_select == "file" \n-labelfile <- read.delim(\'$labels.label_file\')\n+\n+ #if $labels.label_select == "file"\n+# Import file with genes of interest\n+labelfile <- read.delim(\'$labels.label_file\', header = TRUE)\n+\n+# Label the genes of interest in results table\n results <- mutate(results, labels = ifelse(labels %in% labelfile[, 1], labels, ""))\n+\n #elif $labels.label_select == "signif"\n- #if $labels.top_num <= 0\n-results <- mutate(results, labels = "")\n+ #if not $labels.top_num\n+# Label all significant genes in results table\n+results <- mutate(results, labels=ifelse(sig != notsig, labels, ""))\n+\n #elif $labels.top_num > 0\n-top <- results %>% \n- filter(sig != notsig) %>% \n- slice_min(order_by = pvalue, n = $labels.top_num)\n+# Get top genes by P value\n+top <- slice_min(results, order_by = pvalue, n = $labels.top_num)\n+\n+# Extract into vector\n toplabels <- pull(top, labels)\n+\n+# Label just the top genes in results table\n results <- mutate(results, labels = ifelse(labels %in% toplabels, labels, ""))\n- #else \n-results <- mutate(results, labels = ifelse(sig != notsig, labels, ""))\n #end if\n #end if\n #end if\n@@ -104,17 +117,34 @@\n \n # Create plot -------------------------------------------------------------\n \n-pdf("out.pdf")\n-p <- ggplot(results, aes(x = logfc, y = -log10(pvalue))) +\n+# Open file to save plot as PDF\n+pdf("volcano_plot.pdf")\n+\n+# Set up base plot\n+p <- ggplot(data = results, aes(x = logfc, y = -log10(pvalue))) +\n geom_point(aes(colour = sig)) +\n scale_color_manual(values = colours) +\n- scale_fill_manual(values = colours) +\n theme(panel.grid.major = element_blank(),\n panel.grid.minor = element_blank(),\n panel.background = element_blank(),\n axis.line = element_line(colour = "black"),\n legend.key = element_blank())\n \n+#if $labels.label_select != "none"\n+# Add gene labels\n+ #if $plot_options.boxes\n+'..b'data name="plot" format="pdf" from_work_dir="out.pdf" label="${tool.name} on ${on_string}: PDF"/>\n+ <data name="plot" format="pdf" from_work_dir="volcano_plot.pdf" label="${tool.name} on ${on_string}: PDF"/>\n <data name="rscript" format="txt" from_work_dir="rscript.txt" label="${tool.name} on ${on_string}: Rscript">\n <filter>out_options[\'rscript_out\']</filter>\n </data>\n- <data name="rdata" format="rdata" from_work_dir="volcanoplot.RData" label="${tool.name} on ${on_string}: RData">\n- <filter>out_options[\'rdata_out\']</filter>\n- </data>\n </outputs>\n <tests>\n <test expect_num_outputs="1">\n@@ -236,7 +244,7 @@\n <param name="lfc_thresh" value="0" />\n <output name="plot">\n <assert_contents>\n- <has_size value= "933447" delta="1000" />\n+ <has_size value= "933451" delta="1000" />\n </assert_contents>\n </output>\n </test>\n@@ -252,13 +260,14 @@\n <param name="label_file" ftype="tabular" value="labels.tab" />\n <output name="plot">\n <assert_contents>\n- <has_size value= "936522" delta="1000" />\n+ <has_size value= "933832" delta="1000" />\n </assert_contents>\n </output>\n </test>\n- <test expect_num_outputs="3">\n- <!-- Ensure rscript and rdata outputs work -->\n+ <test expect_num_outputs="2">\n+ <!-- Ensure rscript output works -->\n <param name="input" ftype="tabular" value="input.tab"/>\n+ <param name="header" value="yes"/>\n <param name="fdr_col" value="4" />\n <param name="pval_col" value="3" />\n <param name="lfc_col" value="2" />\n@@ -267,18 +276,12 @@\n <param name="label_select" value="file"/>\n <param name="label_file" ftype="tabular" value="labels.tab" />\n <param name="rscript_out" value="True"/>\n- <param name="rdata_out" value="True"/>\n <output name="plot">\n <assert_contents>\n- <has_size value= "936522" delta="1000" />\n+ <has_size value= "933832" delta="1000" />\n </assert_contents>\n </output>\n- <output name="rscript" value= "out.rscript" lines_diff="8"/>\n- <output name="rdata">\n- <assert_contents>\n- <has_size value= "589613" delta="1000" />\n- </assert_contents>\n- </output>\n+ <output name="rscript" value= "out.rscript" lines_diff="4"/>\n </test>\n </tests>\n <help><![CDATA[\n@@ -305,13 +308,11 @@\n * Log fold change\n * Labels (e.g. Gene symbols or IDs)\n \n-The tool will auto-detect if a header is present, by checking if the first row in the P value column is a number or not. \n-\n All significant points, those meeting the specified FDR and Log Fold Change thresholds, will be coloured, red for upregulated, blue for downregulated. Users can choose to apply labels to the points (such as gene symbols) from the Labels column. To label all significant points, select "Significant" for the **Points to label** option, or to only label the top most significant specify a number under "Only label top most significant". Users can label any points of interest through selecting **Points to label** "Input from file" and providing a tabular labels file. The labels file must contain a header row and have the labels in the first column. These labels must match the labels in the main input file.\n \n **Outputs**\n \n-A PDF containing a Volcano plot like below.\n+A PDF containing a Volcano plot like below. The R code can be output through *Output Options* in the tool form.\n \n .. image:: $PATH_TO_IMAGES/volcano_plot.png\n \n@@ -321,4 +322,4 @@\n ]]></help>\n <citations>\n </citations>\n-</tool>\n+</tool>\n\\ No newline at end of file\n' |