Repository 'ggplot2_pca'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/ggplot2_pca

Changeset 0:c21099566418 (2018-06-11)
Next changeset 1:bb6ec8e5387f (2019-02-11)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ggplot2 commit f9fb73a88ab8b52ce11c25a966d4fe99e67c9fbf
added:
ggplot2_pca.xml
macros.xml
test-data/ggplot_heatmap2_result1.pdf
test-data/ggplot_heatmap_result1.pdf
test-data/ggplot_histogram_result1.pdf
test-data/ggplot_pca_result1.pdf
test-data/ggplot_point_result1.pdf
test-data/ggplot_violin_result1.pdf
test-data/mtcars.txt
b
diff -r 000000000000 -r c21099566418 ggplot2_pca.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ggplot2_pca.xml Mon Jun 11 16:05:29 2018 -0400
[
b'@@ -0,0 +1,395 @@\n+<tool id="ggplot2_pca" name="PCA plot w ggplot2" version="@VERSION@">\n+    <macros>\n+        <import>macros.xml</import>\n+    </macros>\n+    <requirements>\n+        <requirement type="package" version="0.4.3">r-ggfortify</requirement>\n+        <requirement type="package" version="1.2.1">r-svglite</requirement>\n+    </requirements>\n+    <command detect_errors="exit_code"><![CDATA[\n+cat \'$script\' &&\n+Rscript \'$script\'\n+    ]]></command>\n+    <configfiles>\n+        <configfile name="script"><![CDATA[\n+@R_INIT@\n+\n+## Import libraries\n+library(ggfortify)\n+library(scales)\n+\n+## static VARs\n+groups <- TRUE\n+circles_boolean <- TRUE\n+group_name <- list()\n+group_cols <- list()\n+group_colors <- list()\n+group_feature <- ""\n+group_colors_vector <- ""\n+\n+input <- \'$input1\'\n+header <- ${inputdata.header}\n+rowname_index <- as.integer(\'$inputdata.row_names_index\')\n+\n+horizontal <- ${inputdata.sample_name_orientation}\n+## title <- \'$title\'\n+transform <- \'$adv.transform\'\n+## background <- \'$adv.theme\'\n+## scaling <- \'$adv.scaling.plot_scaling\'\n+## legend <- \'$adv.legend\'\n+group_type <- \'$groups.group_type\'\n+\n+##if(group_type == "define_groups"){\n+#if str($groups.group_type) == "define_groups":\n+    #for $q in $groups.group_names:\n+        group_name <- append(group_name, \'$q.groupName\')\n+        group_cols <- append(group_cols, \'$q.groupCols\')\n+        group_colors <- append(group_colors, \'$q.color_cond.plot_color\')\n+    #end for\n+#end if\n+group_name <- unlist(group_name)\n+group_cols <- unlist(group_cols)\n+group_colors <- unlist(group_colors)\n+\n+circles <- \'$groups.circle\'\n+plot_param <- \'$plotoptions\'\n+\n+## split plotoptions\n+plot_param_list <- strsplit(x = plot_param, split = ",")\n+plot_options <- c("shape", "label") %in% plot_param_list[[1]]\n+\n+## read table with or with out header or row_names\n+if(rowname_index > 0){\n+    df <- read.table(input, header = header, row.names = rowname_index, sep = "\\t")\n+}else{\n+    df <- read.table(input, header = header, sep = "\\t")\n+}\n+\n+## check if indices are out of range\n+num_cols <- length(names(df))\n+if(group_type == "define_groups"){\n+    check_col_indices <- as.integer(unlist(strsplit(group_cols, split = ",")))\n+    if(any(check_col_indices > num_cols)){\n+        stop("Error: column indices for grouping are out of range! Check help!")\n+    }\n+}\n+\n+## check if table has only numbers\n+if(any(!sapply(df, is.numeric))){\n+    stop("Error: table contains not only numbers!")\n+}\n+\n+## check if group_names are unique\n+if(length(unique(c(group_name, "no_group"))) != length(c(group_name, "no_group"))){\n+    stop("Error: group_names must be unique: ", paste(group_name, "no_group", collapse = ","), " is not unique!")\n+}\n+\n+## prepare group_features for grouping of samples accouring to orientation\n+if(horizontal){\n+    num_cols <- length(names(df))\n+    group_feature <- rep("no_group", num_cols)\n+}else{\n+    num_rows <- nrow(df)\n+    group_feature <- rep("no_group", num_rows)\n+}\n+\n+default_ggplot_colors <- ""\n+default_ggplot_colors_autoplot <- ""\n+## split group elements and assign indexes\n+if(group_type == "define_groups"){\n+    ## set up colors\n+    color_names <- c(group_name, "no_group")\n+    cat("\\ncolor_names: ", color_names)\n+    default_ggplot_colors <- hue_pal()(length(color_names))\n+    names(default_ggplot_colors) <- color_names\n+    cat("\\ndefault_ggplot_colors: ", default_ggplot_colors)\n+    names(group_colors) <- group_name\n+    group_colors <- group_colors[group_colors != "none"]\n+    default_ggplot_colors[names(group_colors)] <- group_colors\n+    cat("\\ndefault_ggplot_colors: ", default_ggplot_colors)\n+    group_string <- lapply(seq_along(group_name), function(k){\n+        gname <- group_name[k]\n+        gindex <- as.integer(strsplit(group_cols[k], split = ",")[[1]])\n+        gnames <- rep(gname, length(gindex))\n+        names(gindex) <- gnames\n+        gindex\n+    })\n+    group_string <- do.call(c, group_string)\n+    group_feature[group_string] <- names(group_string)\n+    ## sub'..b'ion" value="TRUE"/>\n+            </conditional>\n+            <conditional name="groups">\n+                <param name="group_type" value="define_groups"/>\n+                <repeat name="group_names">\n+                    <param name="groupName" value="group1"/>\n+                    <param name="groupCols" value="3,4"/>\n+                    <conditional name="color_cond">\n+                        <param name="color_bool" value="default"/>\n+                        <param name="plot_color" value="none"/>\n+                    </conditional>\n+                </repeat>\n+                <repeat name="group_names">\n+                    <param name="groupName" value="group2"/>\n+                    <param name="groupCols" value="2,5,6,8,9,10,11"/>\n+                    <conditional name="color_cond">\n+                        <param name="color_bool" value="default"/>\n+                        <param name="plot_color" value="none"/>\n+                    </conditional>\n+                </repeat>\n+                <param name="circle" value="convex"/>\n+            </conditional>\n+            <param name="additional_output_format" value="pdf"/>\n+            <output name="output2" file="ggplot_pca_result1.pdf" compare="sim_size"/>\n+        </test>\n+    </tests>\n+    <help><![CDATA[\n+**What it does**\n+\n+This tool generates a Principal component analysis (PCA) for a given table using a combination of ggplot2 and ggfortify.\n+\n+-----\n+\n+**Example**\n+\n+**WARNING:** Be carefull when selecting row names in the second option because the grouping elements do not update automaticly before executing the script. This means that columns have to be chosen as if the row name column was already be removed.\n+\n+**Example for row names in table**\n+\n++--------+-----------+-----------+---------------+---------------+\n+| name   | control 1 | control 2 |  treatment 1  |  treatment 2  |\n++========+===========+===========+===============+===============+\n+| gene 1 |   10      |     12    |       3455    |        232    |\n++--------+-----------+-----------+---------------+---------------+\n+| gene 2 |      20   |     2     |       345     |        334    |\n++--------+-----------+-----------+---------------+---------------+\n+| gene 3 |      200  |     210   |       20      |        2      |\n++--------+-----------+-----------+---------------+---------------+\n+|        |           |           |               |               |\n++--------+-----------+-----------+---------------+---------------+\n+|   1    |       2   |      3    |      4        |       5       |\n++--------+-----------+-----------+---------------+---------------+\n+\n+The new index after reading the table will be:\n+\n++--------+-----------+-----------+--------------+---------------+\n+| name   | control 1 | control 2 | treatment 1  |  treatment 2  |\n++========+===========+===========+==============+===============+\n+|*       |      1    |     2     |      3       |      4        |\n++--------+-----------+-----------+--------------+---------------+\n+\n+-----\n+\n+Pictures coming soon.\n+    ]]></help>\n+    <expand macro="citations">\n+        <citation type="bibtex">@article{tang2016ggfortify,\n+            title={ggfortify: unified interface to visualize statistical results of popular R packages},\n+            author={Tang, Yuan and Horikoshi, Masaaki and Li, Wenxuan},\n+            journal={The R Journal},\n+            volume={8},\n+            number={2},\n+            pages={478-489},\n+            year={2016},\n+            url = {https://journal.r-project.org/archive/2016/RJ-2016-060/RJ-2016-060.pdf}\n+            }\n+        </citation>\n+        <citation type="bibtex">@manual{gu2016getoptlong,\n+            title = {GetoptLong: Parsing Command-Line Arguments and Variable Interpolation},\n+            author = {Zuguang Gu},\n+            year = {2016},\n+            note = {R package version 0.1.5},\n+            url = {https://CRAN.R-project.org/package=GetoptLong},\n+            }\n+        </citation>\n+    </expand>\n+</tool>\n'
b
diff -r 000000000000 -r c21099566418 macros.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml Mon Jun 11 16:05:29 2018 -0400
[
b'@@ -0,0 +1,291 @@\n+<?xml version="1.0"?>\n+<macros>\n+    <xml name="requirements">\n+        <requirements>\n+            <requirement type="package" version="@VERSION@">r-ggplot2</requirement>\n+            <yield />\n+        </requirements>\n+    </xml>\n+    <token name="@VERSION@">2.2.1</token>\n+\n+    <token name="@R_INIT@"><![CDATA[\n+        ## Setup R error handling to go to stderr\n+        options(show.error.messages=F, error=function(){cat(geterrmessage(), file=stderr()); q("no",1,F)})\n+\n+        ## Unify locale settings\n+        loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")\n+    ]]></token>\n+\n+    <token name="@TRANSFORM@"><![CDATA[\n+        #if $adv.transform == "log2"\n+            input["value"] <- log2(input["value"])\n+        #elif $adv.transform == "log2plus1"\n+            input["value"] <- log2(input["value"]+1)\n+        #elif $adv.transform == "log10"\n+            input["value"] <- log10(input["value"])\n+        #elif $adv.transform == "log10plus1"\n+            input["value"] <- log10(input["value"]+1)\n+        #end if\n+    ]]></token>\n+\n+    <token name="@XY_SCALING@"><![CDATA[\n+        #Choose between automatically scaled x and y axis or user defined\n+        #if $adv.scaling.plot_scaling == "Automatic"\n+            gg_scalex = NULL\n+            gg_scaley = NULL\n+        #else\n+            gg_scalex = xlim($adv.scaling.xaxismin, $adv.scaling.xaxismax)\n+            gg_scaley = ylim($adv.scaling.yaxismin, $adv.scaling.yaxismax)\n+            cat("\\n xaxismin: ", $adv.scaling.xaxismin)\n+            cat("\\n xaxismax: ", $adv.scaling.xaxismax)\n+            cat("\\n yaxismin: ", $adv.scaling.yaxismin)\n+            cat("\\n yaxismax: ", $adv.scaling.yaxismax)\n+        #end if\n+    ]]></token>\n+\n+    <token name="@THEME@"><![CDATA[\n+        ## Choose theme for plot\n+        #if $adv.theme == "bw"\n+            gg_theme = theme_bw()\n+        #else\n+            gg_theme = NULL\n+        #end if\n+    ]]></token>\n+\n+    <token name="@LEGEND@"><![CDATA[\n+        ## Show/hide legend\n+        #if $adv.legend == "yes"\n+            gg_legend = theme(legend.position="right")\n+        #else\n+            gg_legend = theme(legend.position="none")\n+            cat("\\n no legend")\n+        #end if\n+    ]]></token>\n+    <token name="@SAVE_OUTPUT@"><![CDATA[\n+        ## output options need to be in out section\n+        gg_width <- as.double(\'$out.width_output_dim\')\n+        gg_height <- as.double(\'$out.height_output_dim\')\n+        gg_unit <- \'$out.unit_output_dim\'\n+        gg_dpi <- as.double(\'$out.dpi_output_dim\')\n+        gg_add_device <- \'$out.additional_output_format\'\n+        output1 <- \'$output1\'\n+        output2 <- \'$output2\'\n+\n+        ## ggsave to png\n+        ggsave(filename = output1, plot = plot_out, width = gg_width, height = gg_height, units = gg_unit, dpi = gg_dpi, device = "png")\n+        if(gg_add_device != "none"){\n+          ggsave(filename = output2, plot = plot_out, width = gg_width, height = gg_height, units = gg_unit, dpi = gg_dpi, device = gg_add_device)\n+        }\n+    ]]></token>\n+    <xml name="read_complex_input">\n+        <param name="input1" type="data" format="tabular" label="Select table"/>\n+        <conditional name="inputdata">\n+            <param name="input_type" type="select" label="Select input dataset options" help="specific dataset input for reading">\n+                <option value="with_header" selected="true">Dataset with header</option>\n+                <option value="with_rownames">Dataset with row names</option>\n+                <option value="with_header_rownames">Dataset with header and row names</option>\n+                <option value="no_header_rownames">Dataset without header or row names</option>\n+            </param>\n+            <when value="with_header">\n+                <param name="header" type="hidden" value="TRUE"/>\n+                <param name="row_names_index" type="hidden" value="0"/>\n+                <param name="sample_name_orientation" type="select" display="radio" multiple="'..b'ption>\n+            <option value="YlGn">Yellow to green (discrete, max=9 colors)</option>\n+            <option value="Reds">Shades of red from light to dark (discrete, max=9 colors)</option>\n+            <option value="RdPu">Red to purple (discrete, max=9 colors)</option>\n+            <option value="Purples">Shades of purple from light to dark (discrete, max=9 colors)</option>\n+            <option value="PuRd">Purple to red (discrete, max=9 colors)</option>\n+            <option value="PuBuGn">Purple to blue to green (discrete, max=9 colors)</option>\n+            <option value="PuBu">Purple to blue(discrete, max=9 colors)</option>\n+            <option value="OrRd">Orange to red (discrete, max=9 colors)</option>\n+            <option value="Oranges">Shades of orange from light to dark (discrete, max=9 colors)</option>\n+            <option value="Greys">Shades of grey from light to dark (discrete, max=9 colors)</option>\n+            <option value="Greens">Shades of greens from light to dark (discrete, max=9 colors)</option>\n+            <option value="GnBu">Green to blue (discrete, max=9 colors)</option>\n+            <option value="BuPu">Blue to purple (discrete, max=9 colors)</option>\n+            <option value="BuGn">Blue to green (discrete, max=9 colors)</option>\n+            <option value="Blues">Shades of blue from light to dark (discrete, max=9 colors)</option>\n+            <option value="Set1">Set 1 - predefined color pallete (discrete, max=9 colors)</option>\n+            <option value="Set2">Set 2 - predefined color pallete (discrete, max=8 colors)</option>\n+            <option value="Set3">Set 3 - predefined color pallete (discrete, max=12 colors)</option>\n+            <option value="Pastel1">Pastel 1 - predefined pastel color pallete (discrete, max=9 colors)</option>\n+            <option value="Pastel2">Pastel 2 - predefined pastel color pallete (discrete, max=8 colors)</option>\n+            <option value="Paired">Paired - predefined color pallete (discrete, max=12 colors)</option>\n+            <option value="Dark2">Dark 2 - predefined color pallete (discrete, max=12 colors)</option>\n+            <option value="Accent">Accent - predefined color pallete (discrete, max=12 colors)</option>\n+            <option value="Spectral">Spectral - Red to yellow to purple (discrete, max=11 colors)</option>\n+            <option value="RdYlGn">Red to yellow to green (discrete, max=11 colors)</option>\n+            <option value="RdYlBu">Red to yellow to blue (discrete, max=11 colors)</option>\n+            <option value="RdGy">Red to grey (discrete, max=11 colors)</option>\n+            <option value="RdBu">Red to blue (discrete, max=11 colors)</option>\n+            <option value="PuOr">Purple to orange (discrete, max=11 colors)</option>\n+            <option value="PRGn">Purple to green (discrete, max=11 colors)</option>\n+            <option value="BrBG">Brown to teal (discrete, max=11 colors)</option>\n+        </param>\n+    </xml>\n+    <xml name="additional_output">\n+        <data name="output1" format="png" label="${tool.name} on ${on_string}: png"/>\n+        <data format="pdf" name="output2" label="${tool.name} on ${on_string}: ${out.additional_output_format}">\n+            <change_format>\n+                <when input="out.additional_output_format" value="svg" format="svg" />\n+                <when input="out.additional_output_format" value="eps" format="eps" />\n+                <when input="out.additional_output_format" value="ps" format="ps" />\n+                <when input="out.additional_output_format" value="tex" format="txt" />\n+                <when input="out.additional_output_format" value="jpeg" format="jpg" />\n+                <when input="out.additional_output_format" value="tiff" format="tiff" />\n+                <when input="out.additional_output_format" value="bmp" format="bmp" />\n+            </change_format>\n+            <filter>out[\'additional_output_format\'] != "none"</filter>\n+        </data>\n+    </xml>\n+</macros>\n'
b
diff -r 000000000000 -r c21099566418 test-data/ggplot_heatmap2_result1.pdf
b
Binary file test-data/ggplot_heatmap2_result1.pdf has changed
b
diff -r 000000000000 -r c21099566418 test-data/ggplot_heatmap_result1.pdf
b
Binary file test-data/ggplot_heatmap_result1.pdf has changed
b
diff -r 000000000000 -r c21099566418 test-data/ggplot_histogram_result1.pdf
b
Binary file test-data/ggplot_histogram_result1.pdf has changed
b
diff -r 000000000000 -r c21099566418 test-data/ggplot_pca_result1.pdf
b
Binary file test-data/ggplot_pca_result1.pdf has changed
b
diff -r 000000000000 -r c21099566418 test-data/ggplot_point_result1.pdf
b
Binary file test-data/ggplot_point_result1.pdf has changed
b
diff -r 000000000000 -r c21099566418 test-data/ggplot_violin_result1.pdf
b
Binary file test-data/ggplot_violin_result1.pdf has changed
b
diff -r 000000000000 -r c21099566418 test-data/mtcars.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/mtcars.txt Mon Jun 11 16:05:29 2018 -0400
b
@@ -0,0 +1,33 @@
+brand mpg cyl disp hp drat wt qsec vs am gear carb
+Mazda RX4 21 6 160 110 3.9 2.62 16.46 0 1 4 4
+Mazda RX4 Wag 21 6 160 110 3.9 2.875 17.02 0 1 4 4
+Datsun 710 22.8 4 108 93 3.85 2.32 18.61 1 1 4 1
+Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
+Hornet Sportabout 18.7 8 360 175 3.15 3.44 17.02 0 0 3 2
+Valiant 18.1 6 225 105 2.76 3.46 20.22 1 0 3 1
+Duster 360 14.3 8 360 245 3.21 3.57 15.84 0 0 3 4
+Merc 240D 24.4 4 146.7 62 3.69 3.19 20 1 0 4 2
+Merc 230 22.8 4 140.8 95 3.92 3.15 22.9 1 0 4 2
+Merc 280 19.2 6 167.6 123 3.92 3.44 18.3 1 0 4 4
+Merc 280C 17.8 6 167.6 123 3.92 3.44 18.9 1 0 4 4
+Merc 450SE 16.4 8 275.8 180 3.07 4.07 17.4 0 0 3 3
+Merc 450SL 17.3 8 275.8 180 3.07 3.73 17.6 0 0 3 3
+Merc 450SLC 15.2 8 275.8 180 3.07 3.78 18 0 0 3 3
+Cadillac Fleetwood 10.4 8 472 205 2.93 5.25 17.98 0 0 3 4
+Lincoln Continental 10.4 8 460 215 3 5.424 17.82 0 0 3 4
+Chrysler Imperial 14.7 8 440 230 3.23 5.345 17.42 0 0 3 4
+Fiat 128 32.4 4 78.7 66 4.08 2.2 19.47 1 1 4 1
+Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2
+Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.9 1 1 4 1
+Toyota Corona 21.5 4 120.1 97 3.7 2.465 20.01 1 0 3 1
+Dodge Challenger 15.5 8 318 150 2.76 3.52 16.87 0 0 3 2
+AMC Javelin 15.2 8 304 150 3.15 3.435 17.3 0 0 3 2
+Camaro Z28 13.3 8 350 245 3.73 3.84 15.41 0 0 3 4
+Pontiac Firebird 19.2 8 400 175 3.08 3.845 17.05 0 0 3 2
+Fiat X1-9 27.3 4 79 66 4.08 1.935 18.9 1 1 4 1
+Porsche 914-2 26 4 120.3 91 4.43 2.14 16.7 0 1 5 2
+Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.9 1 1 5 2
+Ford Pantera L 15.8 8 351 264 4.22 3.17 14.5 0 1 5 4
+Ferrari Dino 19.7 6 145 175 3.62 2.77 15.5 0 1 5 6
+Maserati Bora 15 8 301 335 3.54 3.57 14.6 0 1 5 8
+Volvo 142E 21.4 4 121 109 4.11 2.78 18.6 1 1 4 2