Repository 'intensity_checks'
hg clone https://toolshed.g2.bx.psu.edu/repos/melpetera/intensity_checks

Changeset 1:4973a2104cfd (2018-12-05)
Previous changeset 0:c2c2e1be904a (2018-10-11) Next changeset 2:a7553caa2572 (2019-01-14)
Commit message:
Uploaded
modified:
Intchecks/Script_intensity_check.R
Intchecks/wrapper_intensity_check.R
Intchecks/xml_intensity_check.xml
b
diff -r c2c2e1be904a -r 4973a2104cfd Intchecks/Script_intensity_check.R
--- a/Intchecks/Script_intensity_check.R Thu Oct 11 05:33:19 2018 -0400
+++ b/Intchecks/Script_intensity_check.R Wed Dec 05 10:27:45 2018 -0500
[
b'@@ -1,13 +1,12 @@\n-####################################################################\r\n-# SCRIPT INTENSITY CHECK\r\n-# V1: Fold and NA\r\n-#\r\n-# Input: Data Matrix, VariableMetadata, SampleMetadata\r\n-# Output: VariableMetadata, Graphics (barplots and boxplots)\r\n-#\r\n-# Dependencies: RcheckLibrary.R \r\n-#\r\n-####################################################################\r\n+#########################################################################\r\n+# SCRIPT INTENSITY CHECK                                                #\r\n+#                                                                       #\r\n+# Input: Data Matrix, VariableMetadata, SampleMetadata                  #\r\n+# Output: VariableMetadata, Graphics (barplots and boxplots)            #\r\n+#                                                                       #\r\n+# Dependencies: RcheckLibrary.R                                         #\r\n+#                                                                       #\r\n+#########################################################################\r\n \r\n \r\n # Parameters (for dev)\r\n@@ -19,16 +18,24 @@\n   DM.name <- "DM_NA.tabular"\r\n   SM.name <- "SM_NA.tabular"\r\n   VM.name <- "vM_NA.tabular"\r\n+  class.col <- "2"\r\n   type <- "One_class"\r\n-  class.col <- "2"\r\n   class1 <- "Blanks"\r\n+  fold.frac <- "Top"\r\n+  logarithm <- "log2"\r\n   VM.output <- "new_VM.txt"\r\n   graphs.output <- "Barplots_and_Boxplots.pdf"\r\n }\r\n \r\n-intens_check <- function(DM.name, SM.name, VM.name, type, class.col, class1, VM.output, graphs.output){\r\n-  # This function allows to check the intensities considering classes with a fold calculation, the number and\r\n-  # the proportion of NA\r\n+\r\n+\r\n+\r\n+intens_check <- function(DM.name, SM.name, VM.name, class.col, type, class1, fold.frac, logarithm,\r\n+                         VM.output, graphs.output){\r\n+  \r\n+  \r\n+  # This function allows to check the intensities considering classes with a mean fold change calculation,  \r\n+  # the number and the proportion of missing values (NA) in dataMatrix\r\n   #\r\n   # Two options: \r\n   # - one class (selected by the user) against all the remaining samples ("One_class")\r\n@@ -36,16 +43,19 @@\n   #\r\n   # Parameters:\r\n   # DM.name, SM.name, VM.name: dataMatrix, sampleMetadata, variableMetadata files access\r\n+  # class.col: number of the sampleMetadata\'s column with classes\r\n   # type: "One_class" or "Each_class"\r\n-  # class.col: number of the sampleMetadata\'s column with classes\r\n-  # class1: name of the class if type="One_class"\r\n-  # VM.output: output file\'s access (VM with the new columns)\r\n-  # graphs.output: pdf with barplots for the proportion of NA and boxplots with the folds values\r\n+  # class1: name of the class, only if type="One_class"\r\n+  # fold.frac: if type="One class": class1/other ("Top") or other/class1 ("Bottom")\r\n+  # logarithm: "log2", "log10" or "none" for log mean fold change\r\n+  # VM.output: output file\'s access (VM with new columns)\r\n+  # graphs.output: pdf file\'s access with barplots for the proportion of NA and boxplots with the folds values\r\n+\r\n   \r\n   \r\n   \r\n   \r\n-  # Input ---------------------------------------------------------\r\n+  # Input ---------------------------------------------------------------------------------------------------\r\n   \r\n   DM <- read.table(DM.name, header=TRUE, sep="\\t", check.names=FALSE)\r\n   SM <- read.table(SM.name, header=TRUE, sep="\\t", check.names=FALSE)\r\n@@ -58,6 +68,7 @@\n   check.err(table.check)\r\n   \r\n   \r\n+  \r\n   rownames(DM) <- DM[,1]\r\n   var_names <- DM[,1]\r\n   DM <- DM[,-1]\r\n@@ -65,7 +76,8 @@\n   \r\n   class.col <- colnames(SM)[as.numeric(class.col)]\r\n   \r\n-  # check class.col, class1 and the number of classes---------------\r\n+  \r\n+  # check class.col, class1 and the number of classes ---------------------------------------------------------\r\n   \r\n   if(!(class.col %in% colnames(SM))){\r\n     stop("\\n- - - - - - - - -\\n", "The column ",class.col, " is not a part of the specify sample Metadata","\\n- - - - - - - - -\\n")\r\n@@ -76,6 +88,'..b'me()\r\n   for (i in 1:(length(DM)-1)){\r\n@@ -134,14 +186,13 @@\n         pct_NA[i,j] <- (calcul_NA[i,j]/length(new_DM))*100}\r\n     }\r\n   }\r\n-  names(calcul_NA) <- paste("Nb_NA",classnames, sep="_")\r\n+  names(calcul_NA) <- paste("NA",classnames, sep="_")\r\n   names(pct_NA) <- paste("Pct_NA", classnames, sep="_")\r\n   \r\n-  # Alert message if there is no NA\r\n+  # Alert message if there is no NA in data matrix\r\n   \r\n   sumNA <- colSums(calcul_NA)\r\n   sum_total <- sum(sumNA)\r\n-  \r\n   alerte <- NULL\r\n   if(sum_total==0){\r\n     alerte <- c(alerte, "Data Matrix contains no NA.\\n")\r\n@@ -150,23 +201,31 @@\n   if(length(alerte) != 0){ \r\n     cat(alerte,"\\n")\r\n   }\r\n-  \r\n   table_NA <- cbind(calcul_NA, pct_NA)\r\n   \r\n-  # check columns names ----------------------------------------\r\n+  \r\n+  \r\n+  # check columns names ---------------------------------------------------------------------------------------\r\n+  \r\n+\r\n+  VM.names <- colnames(VM)\r\n   \r\n   # Fold\r\n-  VM.names <- colnames(VM)\r\n-  fold.names <- colnames(fold)\r\n+  \r\n+  if(nb_class >=2){\r\n+    fold.names <- colnames(fold)\r\n   \r\n-  for (i in 1:length(VM.names)){\r\n-    for (j in 1:length(fold.names)){\r\n-      if (VM.names[i]==fold.names[j]){\r\n-        fold.names[j] <- paste(fold.names[j],"2", sep="_")\r\n+    for (i in 1:length(VM.names)){\r\n+      for (j in 1:length(fold.names)){\r\n+        if (VM.names[i]==fold.names[j]){\r\n+          fold.names[j] <- paste(fold.names[j],"2", sep="_")\r\n+        }\r\n       }\r\n     }\r\n+    colnames(fold) <- fold.names\r\n+    \r\n+    VM <- cbind(VM,fold)\r\n   }\r\n-  colnames(fold) <- fold.names\r\n   \r\n   # NA\r\n   NA.names <- colnames(table_NA)\r\n@@ -179,8 +238,10 @@\n     }\r\n   }\r\n   colnames(table_NA) <- NA.names\r\n+  VM <- cbind(VM,table_NA)\r\n   \r\n-  #for NA barplots ---------------------------------------------\r\n+  \r\n+  #for NA barplots -------------------------------------------------------------------------------------------\r\n   \r\n   data_bp <- data.frame()\r\n   \r\n@@ -214,14 +275,13 @@\n     data_bp[4,j] <- Nb_NA_60_80\r\n     data_bp[5,j] <- Nb_NA_80_100\r\n   }\r\n-  rownames(data_bp) <- c("0-20%", "20-40%", "40-60%", "60-80%", "80-100%")\r\n+  rownames(data_bp) <- c("0%-20%", "20%-40%", "40%-60%", "60%-80%", "80%-100%")\r\n   colnames(data_bp) <- classnames\r\n   data_bp <- as.matrix(data_bp)\r\n   \r\n   \r\n-  # Output--------------------------------------------------------\r\n+  # Output ---------------------------------------------------------------------------------------------------\r\n   \r\n-  VM <- cbind(VM,fold,table_NA)\r\n   \r\n   write.table(VM, VM.output,sep="\\t", quote=FALSE, row.names=FALSE)\r\n   \r\n@@ -229,36 +289,39 @@\n   \r\n   pdf(graphs.output)\r\n   \r\n-  #Boxplots for NA\r\n-  \r\n+  #Barplots for NA\r\n   par(mar=c(5.1, 4.1, 4.1, 8.1), xpd=TRUE)\r\n   \r\n   bp=barplot(data_bp, col=rainbow(nrow(data_bp)), main="Proportion of NA", xlab="Classes", ylab="Variables")\r\n   legend("topright", fill=rainbow(nrow(data_bp)),rownames(data_bp), inset=c(-0.3,0))\r\n   \r\n-  \r\n   stock=0\r\n   for (i in 1:nrow(data_bp)){\r\n-    text(bp, stock+data_bp[i,]/2, data_bp[i,], col="white")\r\n+    text(bp, stock+data_bp[i,]/2, data_bp[i,], col="white", cex=0.7)\r\n     stock <- stock+data_bp[i,]\r\n   }\r\n   \r\n   \r\n   #Boxplots for fold test\r\n-  for (j in 1:ncol(fold)){\r\n-    title=paste(fold.names[j])\r\n-    boxplot(fold[j], main=title)\r\n-  }\r\n+  \r\n+  if(nb_class >= 2){\r\n+    \r\n+    clean_fold <- fold\r\n+    for(i in 1:nrow(clean_fold)){\r\n+      for(j in 1:ncol(clean_fold)){\r\n+        if(is.infinite(clean_fold[i,j])){\r\n+          clean_fold[i,j] <- NA\r\n+        }\r\n+      }\r\n+    }\r\n+    for (j in 1:ncol(clean_fold)){\r\n+      title <- paste(fold.names[j])\r\n+      boxplot(clean_fold[j], main=title)\r\n+    }\r\n+    }\r\n   \r\n   dev.off()\r\n \r\n }  \r\n \r\n-\r\n-# Function call---------------\r\n-\r\n-#setwd("Y:\\\\Developpement\\\\Intensity check\\\\Pour tests")\r\n-#intens_check("DM_NA.tabular", "SM_NA.tabular", "VM_NA.tabular", "One_class", "class", "Blanks", "VM_oneclass_NA.txt", \r\n-#"Barplots_and_Boxplots")\r\n-\r\n   \n\\ No newline at end of file\n'
b
diff -r c2c2e1be904a -r 4973a2104cfd Intchecks/wrapper_intensity_check.R
--- a/Intchecks/wrapper_intensity_check.R Thu Oct 11 05:33:19 2018 -0400
+++ b/Intchecks/wrapper_intensity_check.R Wed Dec 05 10:27:45 2018 -0500
b
@@ -1,17 +1,18 @@
 #!/usr/bin/Rscript --vanilla --slave --no-site-file
 
-####################################################################
-# WRAPPER for INTENSITY CHECK
-#Script: Script_intensity_check_v1.R
-#Xml: xml_intensity_check_v1.xml
-#
-# V1: Fold and NA
-#
-# Input: Data Matrix, VariableMetadata, SampleMetadata
-# Output: VariableMetadata, Graphics (barplots and boxplots) 
-#
-#
-####################################################################
+
+#############################################################################
+# WRAPPER for INTENSITY CHECK                                               #
+#                                                                           #
+#Script: Script_intensity_check.R                                           #
+#Xml: xml_intensity_check.xml                                               #
+#                                                                           #
+#                                                                           #
+# Input: Data Matrix, VariableMetadata, SampleMetadata                      #
+# Output: VariableMetadata, Graphics (barplots and boxplots)                #
+#                                                                           #
+#                                                                           #
+#############################################################################
 
 
 library(batch) #necessary for parseCommandArgs function
@@ -26,21 +27,25 @@
 source_local("Script_intensity_check.R", "RcheckLibrary.R")
 
 
-if(length(args) < 7){ stop("NOT enough argument !!!") }
+if(length(args) < 8){ stop("NOT enough argument !!!") }
+
 
 class1 <- NULL
+fold_frac <- NULL
 if(args$type == "One_class"){
   class1 <- args$class1
+  fold_frac <- args$fold_frac
 }
 
+
 #print args
 cat("\n-------------------------------\nIntensity Check parameters:\n\n")
 print(args)
 cat("--------------------------------\n")
 
 
-intens_check(args$dataMatrix_in, args$sampleMetadata_in, args$variableMetadata_in, args$type,
-          args$class_col, class1, args$variableMetadata_out, args$graphs_out)
+intens_check(args$dataMatrix_in, args$sampleMetadata_in, args$variableMetadata_in, args$class_col, args$type,
+            class1, fold_frac, args$logarithm, args$variableMetadata_out, args$graphs_out)
 
 sessionInfo()
 cat("--------------------------------\n")
b
diff -r c2c2e1be904a -r 4973a2104cfd Intchecks/xml_intensity_check.xml
--- a/Intchecks/xml_intensity_check.xml Thu Oct 11 05:33:19 2018 -0400
+++ b/Intchecks/xml_intensity_check.xml Wed Dec 05 10:27:45 2018 -0500
b
@@ -1,5 +1,5 @@
 <tool id="intens_check" name="Intensity Check" version="1.0.1">
- <description>Adding informations about intensities in the Variable metadata</description>
+ <description>Adding informations about intensities (mean fold change and missing values) in the Variable metadata</description>
  <requirements>
  <requirement type="package" version="1.1_4">r-batch</requirement>
  </requirements>
@@ -16,7 +16,10 @@
  type "${type_cond.type}"
  #if $type_cond.type == "One_class" :
  class1 "${type_cond.class1}"
+ fold_frac "${type_cond.fold_frac}"
  #end if
+
+ logarithm "$logarithm"
 
  variableMetadata_out "$variableMetadata_out"
  graphs_out "$graphs_out"
@@ -30,17 +33,27 @@
  <param name="class_col" type="data_column" data_ref="sampleMetadata_in" use_header_names="true" label="Class column" help="Class column in Sample metadata" />
 
  <conditional name="type_cond">
- <param name="type" type="select" label="Type" display="radio" help="Which class do you want to test ?">
+ <param name="type" type="select" label="What kind of tests do you want to perform?" display="radio" help="If you only have two classes, 'One class' could be selected to choose which class should be on the numerator/denominator.">
  <option value="One_class">Tests between one class and the remaining samples </option>
- <option value="Each_class">Tests for each class </option>
+ <option value="Each_class" selected="true">Tests for each class </option>
  </param>
  <when value="One_class">
- <param name="class1" type="text" label="Selected class" help="This class is the numerator for the fold test" />
+ <param name="class1" type="text" label="Selected class" help="Class name if you choose to test one class against the remaining samples." />
+ <param name="fold_frac" type="select" label="Where should the class be placed for the mean fold change calculation?" display="radio">
+ <option value="Top">Numerator (Top) </option>
+ <option value="Bottom">Denominator (Bottom) </option>
+ </param>
  </when>
  <when value="Each_class">
  </when>
  </conditional>
 
+ <param name="logarithm" type="select" label="Logarithm" help="Choose if you want the mean fold change to be converted into a log mean fold change (log2 or log10)">
+ <option value="none">none </option>
+ <option value="log2">log2 </option>
+ <option value="log10">log10 </option>
+ </param>
+
  </inputs>
 
  <outputs>
@@ -65,19 +78,19 @@
 Description
 -----------
 
-This tool performs two tests: the fold calculation, the number and the proportion of missing values. 
+This tool performs two tests: a mean fold change calculation and the number of missing values. 
 
 **Fold:**
-The test calculates the ratio between two classes.
+The test calculates the mean fold change between two classes. It could be converted into a logarithm.
 In the column name, the first class specified is the one used like numerator for the ratio.
 
 **Missing values:**
-This tool calculates the number and the proportion of missing values considering the class. 
+This tool calculates the number and the proportion of missing values in data matrix considering the class. 
 Missing values in numerical columns of data must be coded NA.
 
 **Two types of tests:**
  | - Between **one class** and the remaining samples: if you have only two classes or if you want to test only one class.
- | - **Each class**: if the column class contains at least three classes and you want to test each of them.
+ | - **Each class**: if the column class contains at least three classes and you want to test each of them. Otherwise, you have two classes and you want to choose the one used like numerator or denominator for the mean fold change.
 
 -----------
 Input files
@@ -100,23 +113,29 @@
 **Class column**
  | Select the class column in Sample metadata.
 
-**Type**
+**Type of test**
  |  Two options:
  |     - "One class" allows to perform tests on one class against the remaining samples.
- |     - "Each class" allows to add several columns with the ratio and the number of missing values for each class.
+ |     - "Each class" allows to add several columns with the ratio between all the classes and the number of missing values for each class.
 
 **Selected class**
  | If the type is "one class", specify it to calculate the ratio and the number of missing values. 
+
+**Numerator or denominator**
+ | If the type is "one class", choose "top" or "bottom" to put the selected class as numerator or denominator (respectively) for the mean fold change.
+
+**Logarithm**
+ | Choose if you want to transform the mean fold change with a log2 or log10.
 
 ------------
 Output file
 ------------
 
 **Variable metadata file**
- | Contains the previous columns in variable metadata and the new ones with fold tests, numbers and proportion of missing values.
+ | Contains the previous columns in variable metadata and the new ones with fold tests, number and proportion of missing values.
 
 **Graphs file**
- | Contains barplots with the proportion of NA considering classes and boxplots with the folds values
+ | Contains barplots with the proportion of NA considering classes and boxplots with the fold values
 
  </help>