Repository 'apostl_static_bubblegraph_generator'
hg clone https://toolshed.g2.bx.psu.edu/repos/bornea/apostl_static_bubblegraph_generator

Changeset 15:651a602e0c7f (2016-05-11)
Previous changeset 14:8fe500f4e2cc (2016-05-11) Next changeset 16:0a740024e014 (2016-05-11)
Commit message:
Uploaded
added:
Static_Bubble_Plot_Cmdln.R
b
diff -r 8fe500f4e2cc -r 651a602e0c7f Static_Bubble_Plot_Cmdln.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Static_Bubble_Plot_Cmdln.R Wed May 11 11:00:59 2016 -0400
[
b'@@ -0,0 +1,193 @@\n+###################################################################################################\n+# R-code: APOSTL Global Variables\n+# Author: Brent Kuenzi\n+################################## Dependencies ###################################################\n+library(dplyr); library(tidyr); library(ggplot2); library(ggrepel)\n+colors <- c("Air Force blue" = "#5D8AA8", "Alice blue" = "#F0F8FF", "Alizarin crimson" = "#E32636", "Almond" = "#EFDECD", "Amaranth" = "#E52B50", "Amber" = "#FFBF00", "American rose" = "#FF033E", "Amethyst" = "#9966CC", "Android Green" = "#A4C639", "Anti flash white" = "#F2F3F4", "Antique brass" = "#CD9575", "Antique fuchsia" = "#915C83", "Antique white" = "#FAEBD7", "Ao" = "#008000", "Apple green" = "#8DB600", "Apricot" = "#FBCEB1", "Aqua" = "#00FFFF", "Aquamarine" = "#7FFFD4", "Army green" = "#4B5320", "Arsenic" = "#3B444B", "Arylide yellow" = "#E9D66B", "Ash gray" = "#B2BEB5", "Asparagus" = "#87A96B", "Atomic tangerine" = "#FF9966", "Auburn" = "#A52A2A", "Aureolin" = "#FDEE00", "AuroMetalSaurus" = "#6E7F80", "Awesome" = "#FF2052", "Azure" = "#007FFF", "Azure mist" = "#F0FFFF", "Baby blue" = "#89CFF0", "Baby blue eyes" = "#A1CAF1", "Baby pink" = "#F4C2C2", "Ball Blue" = "#21ABCD", "Banana Mania" = "#FAE7B5", "Banana yellow" = "#FFE135", "Battleship gray" = "#848482", "Bazaar" = "#98777B", "Beau blue" = "#BCD4E6", "Beaver" = "#9F8170", "Beige" = "#F5F5DC", "Bisque" = "#FFE4C4", "Bistre" = "#3D2B1F", "Bittersweet" = "#FE6F5E", "Obsidian" = "#000000", "Onyx" = "#000000", "Lost Soul" = "#000000", "Midnight" = "#000000", "Rolling Blackout" = "#000000", "Sleeping Panther" = "#000000", "Void by Armani" = "#000000", "Blanched Almond" = "#FFEBCD", "Bleu de France" = "#318CE7", "Blizzard Blue" = "#ACE5EE", "Blond" = "#FAF0BE", "Blue" = "#0000FF", "Blue Bell" = "#A2A2D0", "Blue Gray" = "#6699CC", "Blue green" = "#00DDDD", "Blue violet" = "#8A2BE2", "Blush" = "#DE5D83", "Bole" = "#79443B", "Bondi blue" = "#0095B6", "Boston University Red" = "#CC0000", "Brandeis blue" = "#0070FF", "Brass" = "#B5A642", "Brick red" = "#CB4154", "Bright cerulean" = "#1DACD6", "Bright green" = "#66FF00", "Bright lavender" = "#BF94E4", "Bright maroon" = "#C32148", "Bright pink" = "#FF007F", "Bright turquoise" = "#08E8DE", "Bright ube" = "#D19FE8", "Brilliant lavender" = "#F4BBFF", "Brilliant rose" = "#FF55A3", "Brink pink" = "#FB607F", "British racing green" = "#004225", "Bronze" = "#CD7F32", "Brown" = "#964B00", "Bubble gum" = "#FFC1CC", "Bubbles" = "#E7FEFF", "Buff" = "#F0DC82", "Bulgarian rose" = "#480607", "Burgundy" = "#800020", "Burlywood" = "#DEB887", "Burnt orange" = "#CC5500", "Burnt sienna" = "#E97451", "Burnt umber" = "#8A3324", "Byzantine" = "#BD33A4", "Byzantium" = "#702963", "Cadet" = "#536872", "Cadet blue" = "#5F9EA0", "Cadet gray" = "#91A3B0", "Cadmium Green" = "#006B3C", "Cadmium Orange" = "#ED872D", "Cadmium Red" = "#E30022", "Cadmium Yellow" = "#FFF600", "Cal Poly Pomona green" = "#1E4D2B", "Cambridge Blue" = "#A3C1AD", "Camel" = "#C19A6B", "Camouflage green" = "#78866B", "Canary yellow" = "#FFEF00", "Candy apple red" = "#FF0800", "Candy pink" = "#E4717A", "Capri" = "#00BFFF", "Caput mortuum" = "#592720", "Cardinal" = "#C41E3A", "Caribbean green" = "#00CC99", "Carmine" = "#960018", "Carmine pink" = "#EB4C42", "Carmine red" = "#FF0038", "Carnation pink" = "#FFA6C9", "Carnelian" = "#B31B1B", "Carolina blue" = "#99BADD", "Carrot orange" = "#ED9121", "Ceil" = "#92A1CF", "Celadon" = "#ACE1AF", "Celestial blue" = "#4997D0", "Cerise" = "#DE3163", "Cerise pink" = "#EC3B83", "Cerulean" = "#007BA7", "Cerulean blue" = "#2A52BE", "CG Blue" = "#007AA5", "CG Red" = "#E03C31", "Chamoisee" = "#A0785A", "Champagne" = "#F7E7CE", "Charcoal" = "#36454F", "Chartreuse" = "#DFFF00", "Cherry blossom pink" = "#FFB7C5", "Chestnut" = "#CD5C5C", "Chocolate" = "#7B3F00", "Chrome yellow" = "#FFA700", "Cinereous" = "#98817B", "Cinnabar" = "#E34234", "Cinnamon" = "#D2691E", "Citrine" = "#E4D00A", "Classic rose" = "#FBCCE7", "Cob'..b'y,label=PreyGene),\n+                                                                                           segment.color=label_color,force=1, fontface=\'bold\',\n+                                                                                           box.padding=unit(0.25,\'lines\'), \n+                                                                                           point.padding=unit(0.25,\'lines\'),\n+                                                                                           color=label_color,\n+                                                                                           max.iter=1e4, segment.size=0.5)}\n+    if(plot_theme== "classic") {p <- p + theme_classic()}\n+    if(plot_theme== "b/w") {p <- p + theme_bw()}\n+    if(plot_theme== "minimal") {p <- p + theme_minimal()}\n+    if(plot_theme== "dark") {p <- p + theme_dark()}\n+    if(plot_theme== "linedraw") {p <- p + theme_linedraw()}\n+  }\n+  p <- p + theme(axis.title.y = element_text(size=rel(1.5),face="bold"),\n+                 axis.title.x = element_text(size=rel(1.5),face="bold"),\n+                 axis.text.x = element_text(size=rel(1.5),face="bold"),\n+                 axis.text.y = element_text(size=rel(1.5),face="bold"),\n+                 strip.text.x = element_text(size=rel(1.5),face="bold"),\n+                 legend.text = element_text(face="bold"),\n+                 legend.title = element_text(face="bold"))\n+  if(file_type == ".png"){png(paste("BubbleGraph",file_type,sep="")); print(p); dev.off()}\n+  if(file_type == ".pdf"){pdf(paste("BubbleGraph",file_type,sep="")); print(p); dev.off()}\n+  if(file_type == ".tif"){tiff(paste("BubbleGraph",file_type,sep="")); print(p); dev.off()}\n+  if(file_type == ".jpg"){jpeg(paste("BubbleGraph",file_type,sep="")); print(p); dev.off()}\n+  if(file_type == ".svg"){svg(paste("BubbleGraph",file_type,sep="")); print(p); dev.off()}\n+  if(file_type == ".eps"){postscript(paste("BubbleGraph",file_type,sep="")); print(p); dev.off()}\n+}\n+################################################################################\n+args <- commandArgs(trailingOnly = TRUE)\n+working <- as.data.frame(merge_files(args[1], args[2], args[3]))\n+inter_df <- read.table(args[4], sep=\'\\t\', header=FALSE)\n+working$temp <- strsplit(as.character(working$ctrlCounts),"[|]")\n+cnt <- 0\n+for(i in working$temp){\n+  cnt <- cnt+1\n+  working$ctrl_mean[cnt] <- mean(as.numeric(unlist(i)))\n+  working$ctrl_number[cnt] <- length(i)}\n+working$ctrl_SAF <- working$ctrl_mean / working$Length\n+main.data <-  working %>% group_by(Bait) %>% mutate("control_NSAF" = ctrl_SAF/sum(ctrl_SAF))\n+ctrl_SAF_constant <- 1/mean(main.data$ctrl_SAF)\n+# add ctrl_SAF_constant to prevent dividing by 0\n+cnt <- 0\n+for(i in main.data$control_NSAF){\n+  cnt <- cnt + 1\n+  main.data$nsafScore[cnt] <- ((main.data$NSAF[cnt])+ctrl_SAF_constant)/((i/main.data$ctrl_number[cnt])+ctrl_SAF_constant)\n+}\n+main.data$NSAF <- log(main.data$NSAF)\n+main.data$nsafScore <- log(main.data$nsafScore)\n+main.data <- filter(main.data, NSAF > -Inf)\n+colnames(main.data)[colnames(main.data)=="NSAF"] <- "ln(NSAF)"\n+colnames(main.data)[colnames(main.data)=="nsafScore"] <- "NSAFScore"\n+main.data$SAF <- NULL; main.data$ctrl_SAF <- NULL\n+main.data$control_NSAF <- NULL; main.data$temp <- NULL\n+main.data$ctrl_mean <- NULL\n+################################################################################\n+bubblebeam(main.data = main.data, main.exclude = FALSE,main.x = args[5],\n+                 main.y = args[6],main.size = args[7],main.color = colors[[args[8]]],\n+                 SS_cutoff = args[8],FC_cutoff = args[9],\n+                 NS_cutoff = args[10], plot_theme = args[11],\n+                 bubble_label = args[12],label_color = args[13],\n+                 bubble_color = colors[[args[14]]], outline_color = args[15],\n+                 filt_color = colors[[args[16]]], plot_scale = c(0,10), \n+                 file_type = ".png")\n+################################################################################\n+\n'