changeset 5:a31f3f802b2b draft

Uploaded
author melpetera
date Wed, 22 Jan 2020 09:34:08 -0500
parents 49c36c54e0cf
children ec75de7f1e08
files Intchecks/Script_intensity_check.R Intchecks/xml_intensity_check.xml
diffstat 2 files changed, 43 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Intchecks/Script_intensity_check.R	Fri Jan 03 11:09:05 2020 -0500
+++ b/Intchecks/Script_intensity_check.R	Wed Jan 22 09:34:08 2020 -0500
@@ -69,12 +69,19 @@
   table.check <- match3(DM, SM, VM)
   check.err(table.check)
 
-  
+  # Transposing the dataMatrix
   rownames(DM) <- DM[,1]
   var_names <- DM[,1]
   DM <- DM[,-1]
   DM <- data.frame(t(DM))
-
+  
+  # Re-ordering the dataMatrix to match the sampleMetadata file order
+  DM <- merge(x=cbind(1:nrow(SM),SM), y=DM, by.x=2, by.y=0)
+  DM <- DM[order(DM[,2]),]
+  rownames(DM) <- DM[,1]
+  DM <- DM[,-c(1:(ncol(SM)+1))]
+  
+  
   stat.list <- strsplit(chosen.stat,",")[[1]]
   
   
@@ -103,13 +110,13 @@
     classnames <- levels(c_class)
   
     if((nb_class < 2)&&(test.fold=="Yes")){
-      err.1class <- c("\n The column",class.col, "contains only one class, fold calculation could not be executed \n")
+      err.1class <- c("\n The column",class.col, "contains only one class, fold calculation could not be executed. \n")
       cat(err.1class)  
     }
   
     if((nb_class > (nrow(SM))/3)&&(method == "each_class")){
       class.err <- c("\n There are too many classes, think about reducing the number of classes and excluding those
-                    with few samples \n")
+                    with few samples. \n")
       cat(class.err)
     }
 
@@ -139,6 +146,37 @@
     
   # Statistics ------------------------------------------------------------------------------------------------
   
+  # Check whether the dataMatrix contains non-numeric values
+  if(!(is.numeric(as.matrix(DM)))){
+    # findchar definition
+    findchar <- function(myval){
+      if(is.na(myval)){
+        return("ok")
+      }else{
+        mytest <- as.character(myval)
+        if(is.na(as.numeric(mytest[1]))){
+          return("char")
+        }else{
+          return("ok")
+        }
+      }
+    }
+    # findchar application
+    chardiag <- suppressWarnings(apply(DM,2,vapply,findchar,"character"))
+    charlist <- which(chardiag == "char")
+    err.stock <- paste("\n- - - - - - - - -\nYour dataMatrix contains",
+                       length(charlist),
+                       "non-numeric value(s). To help you check your data, please find below a short overview:\n")
+    charover <- 1
+    while((length(err.stock)<10)&(length(err.stock)<(length(charlist)+1))){
+      charex <- paste("variable",colnames(DM)[ceiling(charlist[charover]/nrow(DM))],
+                      "- sample",rownames(DM)[charlist[charover]-floor(charlist[charover]/nrow(DM))*nrow(DM)],
+                      "~> value:",as.matrix(DM)[charlist[charover]],"\n")
+      err.stock <- c(err.stock,charex)
+      charover <- charover + 1
+    }
+    stop(c(err.stock,"The dataMatrix file is supposed to contain only numeric values.\n- - - - - - - - -\n"))
+  }
   
   ### Initialization
   
--- a/Intchecks/xml_intensity_check.xml	Fri Jan 03 11:09:05 2020 -0500
+++ b/Intchecks/xml_intensity_check.xml	Wed Jan 22 09:34:08 2020 -0500
@@ -129,6 +129,7 @@
 	</outputs>
 	
 	
+
 	
 	<help>