[Qpcr-commits] r103 - pkg/NormqPCR/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 17 00:54:21 CEST 2010
Author: jperkins
Date: 2010-05-17 00:54:21 +0200 (Mon, 17 May 2010)
New Revision: 103
Removed:
pkg/NormqPCR/R/deltaDeltaAvgCt.R
pkg/NormqPCR/R/gM_ddAvgCt.R
Modified:
pkg/NormqPCR/R/deltaCt.R
pkg/NormqPCR/R/deltaDeltaCt.R
Log:
cleaning up a few things and the vignette
Modified: pkg/NormqPCR/R/deltaCt.R
===================================================================
--- pkg/NormqPCR/R/deltaCt.R 2010-05-16 17:23:06 UTC (rev 102)
+++ pkg/NormqPCR/R/deltaCt.R 2010-05-16 22:54:21 UTC (rev 103)
@@ -1,9 +1,9 @@
setGeneric("deltaCt",
- function(qPCRBatch, hkgs)
+ function(qPCRBatch, hkgs, combineHkgs=FALSE)
standardGeneric("deltaCt")
)
setMethod("deltaCt", signature = "qPCRBatch", definition =
- function(qPCRBatch, hkgs) {
+ function(qPCRBatch, hkgs, combineHkgs) {
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)
Deleted: pkg/NormqPCR/R/deltaDeltaAvgCt.R
===================================================================
--- pkg/NormqPCR/R/deltaDeltaAvgCt.R 2010-05-16 17:23:06 UTC (rev 102)
+++ pkg/NormqPCR/R/deltaDeltaAvgCt.R 2010-05-16 22:54:21 UTC (rev 103)
@@ -1,92 +0,0 @@
-setGeneric("deltaDeltaAvgCt",
- function(qPCRBatch, maxNACase=0, maxNAControl=0, hkg, contrastM, case, control)
- standardGeneric("deltaDeltaAvgCt")
-)
-setMethod("deltaDeltaAvgCt", signature = "qPCRBatch", definition =
- function(qPCRBatch, maxNACase, maxNAControl, hkg, contrastM, case, control) {
- hkg <- make.names(hkg)
- if(! hkg %in% featureNames(qPCRBatch)) stop("invalid housekeeping gene")
- if(sum(is.na(hkg)) > 0) warning(hkg, " May be a bad housekeeping gene to normalise with since it did not produce a reading ", sum(is.na(hkg)), "times out of", length(hkg), ".")
-
- case <- row.names(contrastM)[contrastM[,case] == 1]
- control <- row.names(contrastM)[contrastM[,control] == 1]
- expM <- exprs(qPCRBatch)
- caseM <- expM[,case]
- controlM <- expM[,control]
- hkgVCase <- caseM[hkg, ]
- hkgVControl <- controlM[hkg, ]
-
- if(length(hkgVCase) == 1 || length(hkgVControl) == 1) {
- meanHkgCase <- hkgVCase
- meanHkgControl <- hkgVControl
- sdHkgCase <- NA
- sdHkgControl <- NA
- }
- else {
- meanHkgCase <- geomMean(hkgVCase, na.rm=TRUE)
- meanHkgControl <- geomMean(hkgVControl, na.rm=TRUE)
- sdHkgCase <- sd(hkgVCase, na.rm=TRUE)
- sdHkgControl <- sd(hkgVControl, na.rm=TRUE)
- }
- if(is.na(meanHkgCase) || is.na(meanHkgControl)) stop("Need at least 1 non NA for the housekeeper")
-
- ddCts <- vector(length=length(featureNames(qPCRBatch)))
- minddCts <- vector(length=length(ddCts))
- maxddCts <- vector(length=length(ddCts))
-
- i <- 1
- for (detector in featureNames(qPCRBatch)) {
- VCase <- caseM[detector,]
- VControl <- controlM[detector,]
- if(! FALSE %in% is.na(VCase)) {
- warning("No Detector for Case")
- VCase <- rep(NA, length(VCase))
- }
- else meanCase <- geomMean(VCase, na.rm=TRUE)
- if(! FALSE %in% is.na(VControl)) {
- warning("No Detector for Control")
- VControl <- rep(NA, length(VControl))
- }
- else meanControl <- geomMean(VControl, na.rm=TRUE)
- sdCase <- sd(VCase, na.rm=TRUE)
- sdControl <- sd(VControl, na.rm=TRUE)
-
- if(sum(is.na(VCase)) > maxNACase) {
- meanCase <- NA
- sdCase <- NA
- }
- else {
- meanCase <- geomMean(VCase, na.rm=TRUE)
- sdCase <- sd(VCase, na.rm=TRUE)
- }
- if(sum(is.na(VControl)) > maxNAControl) {
- meanControl <- NA
- sdControl <- NA
- }
- else {
- meanControl <- geomMean(VControl, na.rm=TRUE)
- sdControl <- sd(VControl, na.rm=TRUE)
- }
- dCtCase <- meanCase - meanHkgCase
- dCtControl <- meanControl - meanHkgControl
- ddCt <- (dCtCase - dCtControl)
-
- if(is.na(ddCt)) {
- if(is.na(dCtCase) && ! is.na(dCtControl)) ddCt <- "-"
- else if(is.na(dCtControl) && ! is.na(dCtCase)) ddCt <- "+"
- else if(is.na(dCtControl) && is.na(dCtCase)) ddCt <- NA
- minddCts[i] <- NA
- maxddCts[i] <- NA
- ddCts[i] <- ddCt
- }
- else {
- sdCt <- sqrt((sdControl^2) + (sdCase^2))
- minddCts[i] <- 2 ^ -(ddCt + sdCt)
- maxddCts[i] <- 2 ^ -(ddCt - sdCt)
- ddCts[i] <- 2^-ddCt
- }
- i <- i+1
- }
- return(cbind(featureNames(qPCRBatch),ddCts,minddCts,maxddCts))
- }
-)
Modified: pkg/NormqPCR/R/deltaDeltaCt.R
===================================================================
--- pkg/NormqPCR/R/deltaDeltaCt.R 2010-05-16 17:23:06 UTC (rev 102)
+++ pkg/NormqPCR/R/deltaDeltaCt.R 2010-05-16 22:54:21 UTC (rev 103)
@@ -1,11 +1,11 @@
setGeneric("deltaDeltaCt",
- function(qPCRBatch, maxNACase=0, maxNAControl=0, hkgs, contrastM, case, control, paired=TRUE, combineHkg=FALSE)
+ function(qPCRBatch, maxNACase=0, maxNAControl=0, hkgs, contrastM, case, control, paired=TRUE, combineHkgs=FALSE)
standardGeneric("deltaDeltaCt")
)
setMethod("deltaDeltaCt", signature = "qPCRBatch", definition =
- function(qPCRBatch, maxNACase, maxNAControl, hkgs, contrastM, case, control, paired, combineHkg) {
+ function(qPCRBatch, maxNACase, maxNAControl, hkgs, contrastM, case, control, paired, combineHkgs) {
hkgs <- make.names(hkgs)
- if(combineHkg == TRUE) {
+ if(combineHkgs == TRUE) {
if(length(hkgs) == 1) stop("Not enough hkgs given")
}
# for(hkg in hkgs) {
@@ -22,11 +22,11 @@
# hkgMCase <- caseM[hkgs, ]
# hkgMControl <- controlM[hkgs, ]
- if(combineHkg == TRUE) {
+ if(combineHkgs == TRUE) {
hkgMCase <- caseM[hkgs, ]
hkgMControl <- controlM[hkgs, ]
- hkgVCase <- apply(hkgMCase, 2, geomMean, na.rm=TRUE)
- hkgVControl <- apply(hkgMControl, 2, geomMean, na.rm=TRUE)
+ hkgVCase <- apply(hkgMCase, 2, mean, na.rm=TRUE)
+ hkgVControl <- apply(hkgMControl, 2, mean, na.rm=TRUE)
} else {
hkg <- hkgs[1]
}
@@ -62,7 +62,7 @@
dCtCase <- rep(NA, length = VCase)
dCtControl <- NA
} else {
- dCtCase <- geomMean(VCase, na.rm=TRUE) - geomMean(hkgVCase, na.rm=TRUE)
+ dCtCase <- mean(VCase, na.rm=TRUE) - mean(hkgVCase, na.rm=TRUE)
if (paired == TRUE) {
sdCase <- sd(VCase - hkgVCase, na.rm=TRUE)
} else {
@@ -77,7 +77,7 @@
warning("No Detector for Control")
dCtControl <- rep(NA, length = VControl)
} else {
- dCtControl <- geomMean(VControl, na.rm=TRUE) - geomMean(hkgVControl, na.rm=TRUE)
+ dCtControl <- mean(VControl, na.rm=TRUE) - mean(hkgVControl, na.rm=TRUE)
if (paired == TRUE) {
sdControl <- sd(VControl - hkgVControl, na.rm=TRUE)
} else {
Deleted: pkg/NormqPCR/R/gM_ddAvgCt.R
===================================================================
--- pkg/NormqPCR/R/gM_ddAvgCt.R 2010-05-16 17:23:06 UTC (rev 102)
+++ pkg/NormqPCR/R/gM_ddAvgCt.R 2010-05-16 22:54:21 UTC (rev 103)
@@ -1,104 +0,0 @@
-setGeneric("gM_ddAvgCt",
- function(qPCRBatch, maxNACase=0, maxNAControl=0, hkgs, contrastM, case, control)
- standardGeneric("gM_ddAvgCt")
-)
-setMethod("gM_ddAvgCt", signature = "qPCRBatch", definition =
- function(qPCRBatch, maxNACase, maxNAControl, hkgs, contrastM, case, control) {
- if(length(hkgs)<=1) stop("More than 1 houskeeping gene required")
- hkgs <- make.names(hkgs)
- if(FALSE %in% (hkgs %in% featureNames(qPCRBatch))) stop("invalid housekeeping gene")
-
-
-
- case <- row.names(contrastM)[contrastM[,case] == 1]
- control <- row.names(contrastM)[contrastM[,control] == 1]
- expM <- exprs(qPCRBatch)
- caseM <- expM[,case]
- controlM <- expM[,control]
- hkgM <- expM[hkgs,]
-#return(hkgM)
- if (TRUE %in% apply(apply(hkgM, 1, is.na),2,sum)>0) {
- warning("NAs present in housekeeping genes. NAs will be excluded when combining housekeepers to make pseudogenes")
- if (0 %in% apply(! apply(hkgM, 1, is.na),2,sum)) stop("Need at least 1 non NA for each housekeeper")
- }
- hkgMCase <- caseM[hkgs, ]
- hkgMControl <- controlM[hkgs, ]
-
-hkgVCase <- apply(hkgMCase, 2, geomMean, na.rm=TRUE)
-hkgVControl <- apply(hkgMControl, 2, geomMean, na.rm=TRUE)
- ##############################################
- # Here we use the geoMean function to find the geometric mean of the chosen housekeepers
-
-
- if(! FALSE %in% is.na(hkgVCase) || ! FALSE %in% is.na(hkgVControl)) stop("Need at least 1 non NA for the housekeeper")
- gMhkgControl <- geomMean(hkgVControl, na.rm=TRUE)
- gMhkgCase <- geomMean(hkgVCase, na.rm=TRUE)
-
- ddCts <- vector(length=length(featureNames(qPCRBatch)))
- minddCts <- vector(length=length(ddCts))
- maxddCts <- vector(length=length(ddCts))
-
- i <- 1
- for (detector in featureNames(qPCRBatch)) {
- VCase <- caseM[detector,]
- VControl <- controlM[detector,]
- if(! FALSE %in% is.na(VCase)) {
- warning("No Detector for Case")
- dCtCase <- rep(NA, length(VCase))
- sdCase <- NA
- }
-# if(length(VCase) == 1) {
-# warning("Only one Detector for Case")
-# dCtCase <- VCase
-# sdCase <- NA
-# }
- else {
- dCtCase <- geomMean(VCase, na.rm=T) - gMhkgCase
- sdCase <- sd(VCase, na.rm=TRUE)
- }
-# if(length(VControl) == 1) {
-# warning("Only one Detector for Control")
-# dCtControl <- VControl
-# }
- if(! FALSE %in% is.na(VControl)) {
- warning("No Detector for Control")
- dCtControl <- rep(NA, length(VControl))
- sdControl <- NA
- }
- else {
- dCtControl <- geomMean(VControl, na.rm=TRUE) - gMhkgControl
- sdControl <- sd(VControl, na.rm=TRUE)
- }
- if(sum(is.na(VCase)) > maxNACase) {
- dCtCase <- NA
- }
- if(sum(is.na(VControl)) > maxNAControl) {
- dCtControl <- NA
- }
- ddCt <- (dCtCase - dCtControl)
-
- if(is.na(ddCt)) {
- if(is.na(dCtCase) && ! is.na(dCtControl)) ddCt <- "-"
- else if(is.na(dCtControl) && ! is.na(dCtCase)) ddCt <- "+"
- else if(is.na(dCtControl) && is.na(dCtCase)) ddCt <- NA
- minddCts[i] <- NA
- maxddCts[i] <- NA
- ddCts[i] <- ddCt
- }
- else {
- if(is.na(sdCase) | is.na(sdControl)) {
- minddCts[i] <- NA
- maxddCts[i] <- NA
- }
- else {
- sdCt <- sqrt((sdCase^2) + (sdControl^2))
- minddCts[i] <- 2 ^ -(ddCt + sdCt)
- maxddCts[i] <- 2 ^ -(ddCt - sdCt)
- ddCts[i] <- 2^-ddCt
- }
- }
- i <- i+1
- }
- return(cbind(featureNames(qPCRBatch),ddCts,minddCts,maxddCts))
- }
-)
More information about the Qpcr-commits
mailing list