Commits

Cory Spencer  committed a57d978

Updates as per chat with Shannan ealier today.

  • Participants
  • Parent commits fa11ba5

Comments (0)

Files changed (5)

File tools/scde_pathprint/galaxy-pathprint.r

   }
 }
 
-calculateDistance <- function(fingerprint, pvalue = 1, file = "", verbose = 0) {
+calculateDistanceToGEO <- function() {
+  pluripotent.consensus <- consensusFingerprint(GEO.fingerprint.matrix[,pluripotents.frame$GSM], 0.9)
+  pluripotent.distance  <- consensusDistance(pluripotent.consensus, GEO.fingerprint.matrix)
+
+  return(pluripotent.distance)
+}
+
+calculateDistanceToPluripotent <- function(fingerprint, pvalue = 1, file = "", verbose = 0) {
   if (! is.null(attr(fingerprint, 'fingerprintType'))) {
     if ((attr(fingerprint, 'fingerprintType') == 'GSE') && (ncol(fingerprint) > 1)) {
       if (verbose) print("Calculating distances from pluripotent consensus for multiple sample")
       ## Calculate the distance from the pluripotent consensus for a multiple sample.
-      pluripotent.consensus <- consensusFingerprint(GEO.fingerprint.matrix[,pluripotents.frame$GSM],
-                                                    threshold = 0.9)
+      pluripotent.consensus <- consensusFingerprint(GEO.fingerprint.matrix[,pluripotents.frame$GSM], 0.9)
       fingerprint.distance  <- consensusDistance(pluripotent.consensus, fingerprint)    
     } else {
       if (verbose) print("Calculating distances from pluripotent consensus for single sample")
       ## Calculate the distance from the pluripotent consensus for a single sample.
       pluripotent <- GEO.fingerprint.matrix[,pluripotents.frame$GSM]
-      fingerprint.distance  <- data.frame(consensusDistance(fingerprint, pluripotent))
+      fingerprint.distance <- data.frame(consensusDistance(fingerprint, pluripotent))
     }
  
     ## If requested, write the fingerprint out to file.
   }
 }
 
-generateHistogram <- function(filename, fingerprint, distance) {
+generateHistograms <- function(filename, fingerprint, distance) {
   if (nrow(distance) == 0) {
     stop("Unable to generate histogram: no distances to plot - try increasing p-value?")
   }
     xlab2 <- "Distance of pluripotent experiments from input sample"
   }
 
+  ## Calculate the distance of the pluripotent to GEO.
+  geo.distance = calculateDistanceToGEO()
+  
   ## Output the first histogram.
   par(oma = c(5, 2, 2, 2), mfcol = c(2,1), mar = c(0, 4, 4, 2))
-  hist(distance[,"distance"], col    ="grey", 
-                              main   = "",
-                              nclass = 50,
-                              xlab   = xlab1,
-                              xlim   = c(0,1))
+  hist(geo.distance[,"distance"], col    ="grey", 
+                                  main   = "",
+                                  nclass = 50,
+                                  xlab   = xlab1,
+                                  xlim   = c(0,1))
 
   ## Output the second histogram.
   par(mar = c(7, 4, 4, 2))
   ## invisible(dev.off())
 }
 
-loadFingerprintFromCELFile <- function(filename, platform, file = "") {
-  if (! is.supportedPlatform(platform))
-    stop(sprintf("The '%s' platform is not supported by PathPrint", platform))
-  
+loadFingerprintFromCELFile <- function(filename, file = "") {
   ## Load the data from the provided CEL file.
   tryCatch({ data <- ReadAffy(filenames = c(filename)) },
              error = function(err) {
                      })
 
   ## Get the reported platform, if any, from the CEL file.
-  reportedPlatform <- getPlatformFromArrayName(cdfName(data))
-  if (! is.null(reportedPlatform)) {
-    if (platform != reportedPlatform) {
-      stop(sprintf("Specified platform '%s' differs from platform '%s' reported in CEL file",
-                   platform, reportedPlatform))
-    }
-  }
-                     
+  platform <- getPlatformFromArrayName(cdfName(data))
+  if (is.null(platform)) 
+    stop(sprintf("Unable to determine from platform from CEL file"))
+  if (! is.supportedPlatform(platform))
+    stop(sprintf("The '%s' platform is not supported by PathPrint", platform))
+
   ## Create the fingerprint based on the CEL file data.
   cel.fingerprint <- exprs2fingerprint(exprs(rma(data)), platform, getPlatformSpecies(platform))
 

File tools/scde_pathprint/pathprintCEL.pl

 
 sub usage {
   print <<USAGE;
-Usage: $0 <celfile> <platform> <consensus> <fingerprint> <histogram> [args]
+Usage: $0 <celfile> <consensus> <fingerprint> <histogram> [args]
 PathPrint command line interface.
   -h,--help          Display usage information and exit.
   -p,--p-value <N>   Use <N> as a cutoff p-value.  Defaults to 0.05.
 
   # Display the usage information and exit if no arguments were provided
   # or help flag was provided
-  usage && exit(0) if (@ARGV != 5) || $help;
+  usage && exit(0) if (@ARGV != 4) || $help;
 
   # Set some default values.
   my $pvalue = defined $pvalue ? $pvalue : 0.05;
 
   # Get the command line arguments and do some validation.
   my $cel         = shift @ARGV || die "Error: <celfile> is a required argument\n";
-  my $platform    = shift @ARGV || die "Error: <platform> is a required argument\n";
   my $consensus   = shift @ARGV || die "Error: <consensus> is a required argument\n";
   my $fingerprint = shift @ARGV || die "Error: <distance> is a required argument\n";
   my $histogram   = shift @ARGV || die "Error: <histograml> is a required argument\n";
 
         data(GEO.metadata.matrix)
 
-        fingerprint <- loadFingerprintFromCELFile('$cel', '$platform', file = '$fpfile')
-        distance    <- calculateDistance(fingerprint, pvalue = $pvalue, file = '$cdfile')
-	generateHistogram('$histogram', fingerprint, distance)
+        fingerprint <- loadFingerprintFromCELFile('$cel', file = '$fpfile')
+        distance    <- calculateDistanceToPluripotent(fingerprint, pvalue = $pvalue, file = '$cdfile')
+	generateHistograms('$histogram', fingerprint, distance)
 EOCODE
 
   my $res = eval { $R->run($code)  };

File tools/scde_pathprint/pathprintCEL.xml

     <option value="GPL1319">GPL1319 - Affymetrix Zebrafish Genome Array</option>
     <option value="GPL1322">GPL1322 - Affymetrix Drosophila Genome 2.0 Array</option>
     <option value="GPL1355">GPL1355 - Affymetrix Rat Genome 230 2.0 Array</option>
-    <option value="GPL2700">GPL2700 - Sentrix HumanRef-8 Expression BeadChip</option>
-    <option value="GPL2986">GPL2986 - ABI Human Genome Survey Microarray Version 2</option>
-    <option value="GPL2995">GPL2995 - ABI Mouse Genome Survey Microarray</option>
     <option value="GPL3921">GPL3921 - Affymetrix HT Human Genome U133A Array</option>
     <option value="GPL4685">GPL4685 - Affymetrix GeneChip HT-HG_U133A Early Access Array</option>
-    <option value="GPL6102">GPL6102 - Illumina human-6 v2.0 expression beadchip</option>
-    <option value="GPL6103">GPL6103 - Illumina mouseRef-8 v1.1 expression beadchip</option>
-    <option value="GPL6104">GPL6104 - Illumina humanRef-8 v2.0 expression beadchip</option>
-    <option value="GPL6105">GPL6105 - Illumina mouse-6 v1.1 expression beadchip</option>
-    <option value="GPL6333">GPL6333 - Illumina Mouse Ref-6 V1</option>
-    <option value="GPL6883">GPL6883 - Illumina HumanRef-8 v3.0 expression beadchip</option>
-    <option value="GPL6884">GPL6884 - Illumina HumanWG-6 v3.0 expression beadchip</option>
-    <option value="GPL6885">GPL6885 - Illumina MouseRef-8 v2.0 expression beadchip</option>
-    <option value="GPL6887">GPL6887 - Illumina MouseWG-6 v2.0 expression beadchip</option>
-    <option value="GPL6947">GPL6947 - Illumina HumanHT-12 V3.0 expression beadchip</option>
     <option value="GPL8300">GPL8300 - Affymetrix Human Genome U95 Version 2 Array</option>
     <option value="GPL8321">GPL8321 - Affymetrix Mouse Genome 430A 2.0 Array</option>
   </param>

File tools/scde_pathprint/pathprintExprsSet.pl

         data(GEO.metadata.matrix)
 
         fingerprint <- loadFingerprintFromExprsFile('$exprs', '$platform', file = '$fpfile')
-        distance    <- calculateDistance(fingerprint, pvalue = $pvalue, file = '$cdfile')
-	generateHistogram('$histogram', fingerprint, distance)
+        distance    <- calculateDistanceToPluripotent(fingerprint, pvalue = $pvalue, file = '$cdfile')
+	generateHistograms('$histogram', fingerprint, distance)
 EOCODE
 
   my $res = eval { $R->run($code)  };

File tools/scde_pathprint/pathprintGEO.pl

         library(galaxypathprint)
         data(GEO.metadata.matrix)
         fingerprint <- generateFingerprint('$geo', file = '$fpfile')
-        distance    <- calculateDistance(fingerprint, pvalue = $pvalue, file = '$cdfile')
-	generateHistogram('$histogram', fingerprint, distance)
+        distance    <- calculateDistanceToPluripotent(fingerprint, pvalue = $pvalue, file = '$cdfile')
+	generateHistograms('$histogram', fingerprint, distance)
 EOCODE
   my $res = eval { $R->run($code)  };
   if ($@) {