[Qpcr-commits] r95 - pkg/NormqPCR/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 25 19:20:36 CET 2010


Author: jperkins
Date: 2010-02-25 19:20:36 +0100 (Thu, 25 Feb 2010)
New Revision: 95

Added:
   pkg/NormqPCR/R/deltaCt.R
Log:
Can normalise without comparing - could be useful for pseudocard perhaps

Copied: pkg/NormqPCR/R/deltaCt.R (from rev 90, pkg/NormqPCR/R/normByHKG.R)
===================================================================
--- pkg/NormqPCR/R/deltaCt.R	                        (rev 0)
+++ pkg/NormqPCR/R/deltaCt.R	2010-02-25 18:20:36 UTC (rev 95)
@@ -0,0 +1,36 @@
+setGeneric("deltaCt",
+  function(qPCRBatch, hkgs)
+  standardGeneric("deltaCt")
+)
+setMethod("deltaCt", signature = "qPCRBatch", definition =
+  function(qPCRBatch, hkgs) {
+    hkgs <- make.names(hkgs)
+    if(FALSE %in% (hkgs %in% featureNames(qPCRBatch))) stop ("given housekeeping gene, ", hkgs," not found in file. Ensure entered housekeeping genes appear in the file")
+    expM <- exprs(qPCRBatch)
+    hkgM <- expM[hkgs, ]
+    print(hkgM)
+
+    if(length(hkgs) > 1) {
+      if (TRUE %in% apply(hkgM, 1, is.na))  {
+          warning("NAs present in housekeeping genes readings")
+          if (0 %in% apply(! apply(hkgM, 1, is.na),2,sum)) stop("Need at least 1 non NA for each housekeeper")
+      }
+#     hkgV <- apply(hkgM,2,geomMean,na.rm=TRUE) CANT CURRENTLY DO THIS BECAUS EOF PROBLEMS WITH DOUBLE NAS
+      hkgV <- vector(length = dim(hkgM)[2])
+      for(i in 1:dim(hkgM)[2]) {
+          if(! FALSE %in% is.na(hkgM[,i])) next # go to next sequence if we have only NAs
+          hkgV[i] <- geomMean(hkgM[,i], na.rm=TRUE)
+      }
+    }
+    else {
+      if(TRUE %in% is.na(hkgM)) {
+          warning("NAs present in housekeeping gene readings")
+          if(! FALSE %in% is.na(hkgM)) stop("Need at least 1 non NA for the housekeeper")
+      }
+      hkgV <- hkgM # Because it's a vector really anyway
+      cat(hkgV)
+    }
+    exprs(qPCRBatch) <- 2^-(t(t(exprs(qPCRBatch)) - hkgV))
+    return(qPCRBatch)
+  }
+)



More information about the Qpcr-commits mailing list