[Qpcr-commits] r131 - in pkg/NormqPCR: R inst/exData man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 23 09:51:26 CET 2011
Author: jperkins
Date: 2011-03-23 09:51:26 +0100 (Wed, 23 Mar 2011)
New Revision: 131
Modified:
pkg/NormqPCR/R/allGenerics.R
pkg/NormqPCR/R/combineTechReps.R
pkg/NormqPCR/R/dealWithNA.R
pkg/NormqPCR/inst/exData/qPCR.techReps.txt
pkg/NormqPCR/man/combineTechReps.Rd
pkg/NormqPCR/man/makeAllNAs.Rd
pkg/NormqPCR/man/replaceAboveCutOff.Rd
pkg/NormqPCR/man/replaceNAs.Rd
Log:
replaced generics and allowed combineTechReps to use median or geometric mean alongisde arithmetic mean
Modified: pkg/NormqPCR/R/allGenerics.R
===================================================================
--- pkg/NormqPCR/R/allGenerics.R 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/R/allGenerics.R 2011-03-23 08:51:26 UTC (rev 131)
@@ -7,3 +7,23 @@
function(qPCRBatch, ...)
standardGeneric("deltaDeltaCt")
)
+
+setGeneric("combineTechReps",
+ function(qPCRBatch, ...)
+ standardGeneric("combineTechReps")
+)
+
+setGeneric("replaceNAs",
+ function(qPCRBatch, ...)
+ standardGeneric("replaceNAs")
+)
+
+setGeneric("replaceAboveCutOff",
+ function(qPCRBatch, ...)
+ standardGeneric("replaceAboveCutOff")
+)
+
+setGeneric("makeAllNAs",
+ function(qPCRBatch, ...)
+ standardGeneric("makeAllNAs")
+)
Modified: pkg/NormqPCR/R/combineTechReps.R
===================================================================
--- pkg/NormqPCR/R/combineTechReps.R 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/R/combineTechReps.R 2011-03-23 08:51:26 UTC (rev 131)
@@ -1,18 +1,32 @@
-setGeneric("combineTechReps",
- function(qPCRBatch)
- standardGeneric("combineTechReps")
-)
setMethod("combineTechReps", signature = "qPCRBatch", definition =
- function(qPCRBatch) {
+ function(qPCRBatch, calc = "arith") {
expM <- exprs(qPCRBatch)
origDetectors <- row.names(expM)
if (FALSE %in% grepl("_TechReps", origDetectors)) stop("These are not tech reps")
newDetectors <- unique(gsub("_TechReps.\\d","", origDetectors))
NewExpM <- matrix(nrow = length(newDetectors), ncol = dim(expM)[2], dimnames = list(newDetectors,colnames(expM)))
- for(detector in newDetectors){ # for each detector
- dValues <- colMeans(expM[gsub("_TechReps.\\d","", origDetectors) %in% detector,],na.rm=TRUE) # find everything that begins with new detector, and find the mean
- NewExpM[detector,] <- dValues # add values to the matrix
+ if (calc == "arith") {
+ for (detector in newDetectors) {
+ dValues <- colMeans(expM[gsub("_TechReps.\\d", "", origDetectors) %in% detector, ], na.rm = TRUE)
+ NewExpM[detector, ] <- dValues
+ }
}
+ else if (calc == "geom") {
+ for (detector in newDetectors) {
+ dValues <- apply(expM[gsub("_TechReps.\\d", "", origDetectors) %in% detector, ], 2, geomMean, na.rm = TRUE)
+ NewExpM[detector, ] <- dValues
+ }
+ }
+ else if (calc == "median") {
+ for (detector in newDetectors) {
+ dValues <- apply(expM[gsub("_TechReps.\\d", "", origDetectors) %in% detector, ], 2, median, na.rm = TRUE)
+# dValues <- colMedians(expM[gsub("_TechReps.\\d", "", origDetectors) %in% detector, ], na.rm = TRUE)
+ NewExpM[detector, ] <- dValues
+ }
+ }
+ else {
+ stop("ensure you have specified the correct centrality measure, 'arith', 'geom' or 'median'")
+ }
NewExpM[is.na(NewExpM)] <- NA # make NAs real NAs
qPCRBatch <- new("qPCRBatch", exprs = NewExpM, phenoData = phenoData(qPCRBatch))
return(qPCRBatch)
Modified: pkg/NormqPCR/R/dealWithNA.R
===================================================================
--- pkg/NormqPCR/R/dealWithNA.R 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/R/dealWithNA.R 2011-03-23 08:51:26 UTC (rev 131)
@@ -1,9 +1,5 @@
#######################################################
# replaceNAs - this replaces all NAs with a set number
-setGeneric("replaceNAs",
- function(qPCRBatch, newNA=40)
- standardGeneric("replaceNAs")
-)
setMethod("replaceNAs", signature = "qPCRBatch", definition =
function(qPCRBatch, newNA) {
exprs(qPCRBatch)[is.na(exprs(qPCRBatch))] <- newNA
@@ -12,12 +8,8 @@
)
###############################################################################################
# replaceAboveCutOff - this replaces anything above a given number with a (supplied) new value
-setGeneric("replaceAboveCutOff",
- function(qPCRBatch, newVal=NA, cutOff=38)
- standardGeneric("replaceAboveCutOff")
-)
setMethod("replaceAboveCutOff", signature = "qPCRBatch", definition =
- function(qPCRBatch, newVal, cutOff) {
+ function(qPCRBatch, newVal = NA, cutOff = 38) {
exprs(qPCRBatch)[exprs(qPCRBatch) > cutOff] <- newVal
return(qPCRBatch)
}
@@ -25,10 +17,6 @@
################################################################################################################
# makeAllNAs - for each detector, if you have > a given number of NAs, then all values are all replaced with NA
# This means we can ignore any NAs in future calculations (since they can be dealt with using these functions
-setGeneric("makeAllNAs",
- function(qPCRBatch, contrastM, sampleMaxM)
- standardGeneric("makeAllNAs")
-)
setMethod("makeAllNAs", signature = "qPCRBatch", definition =
function(qPCRBatch, contrastM, sampleMaxM) {
expM <- exprs(qPCRBatch)
Modified: pkg/NormqPCR/inst/exData/qPCR.techReps.txt
===================================================================
--- pkg/NormqPCR/inst/exData/qPCR.techReps.txt 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/inst/exData/qPCR.techReps.txt 2011-03-23 08:51:26 UTC (rev 131)
@@ -7,7 +7,7 @@
6 caseA one gene_ei 20.7773052257951
7 caseA one gene_bo 18.8705150882936
8 caseA one gene_cp 20.3037101230571
-1 caseB one gene_dx 20.2712554227792
+1 caseB one gene_dx NA
2 caseB one gene_aj 19.8498329931463
3 caseB one gene_jy 19.5007131087816
4 caseB one gene_ax 19.1686621517887
Modified: pkg/NormqPCR/man/combineTechReps.Rd
===================================================================
--- pkg/NormqPCR/man/combineTechReps.Rd 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/man/combineTechReps.Rd 2011-03-23 08:51:26 UTC (rev 131)
@@ -6,18 +6,22 @@
Takes expression set of qPCR values containing technical replicates and combines them.
}
\usage{
-combineTechReps(qPCRBatch)
+combineTechReps(qPCRBatch, \dots)
+
+\S4method{combineTechReps}{qPCRBatch}(qPCRBatch, calc="arith")
}
\arguments{
- \item{qPCRBatch}{ Expression set containing qPCR data, read in by a ReadqPCR function and containing technical reps, denoted by \code{_TechRep.n} suffix.
+ \item{qPCRBatch}{ Expression set containing qPCR data, read in by a ReadqPCR function and containing technical reps, denoted by \code{_TechRep.n} suffix. }
+ \item{\dots}{ Extra arguments, detailed below }
+ \item{calc}{ use median, arithmetic or geometric mean for combining the values}
}
-}
\details{
- Takes \code{exprs} of qPCR values containing technical replicates and combines them.
+ Takes \code{exprs} of qPCR values containing technical replicates and combines them using a specified centrality measure.
}
\value{
\code{qPCRBatch} with same number of samples, but with less features, since all technical replicates are replaced with a single value of their means.
}
+
%\references{ }
\author{ James Perkins \email{jperkins at biochem.ucl.ac.uk}}
%\note{}
Modified: pkg/NormqPCR/man/makeAllNAs.Rd
===================================================================
--- pkg/NormqPCR/man/makeAllNAs.Rd 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/man/makeAllNAs.Rd 2011-03-23 08:51:26 UTC (rev 131)
@@ -5,17 +5,17 @@
\description{ Make all Ct values for a given detector NA when the number of NAs for that detector is above a given threshold
}
\usage{
- makeAllNAs(qPCRBatch, contrastM, sampleMaxM)
+makeAllNAs(qPCRBatch, \dots)
+
+\S4method{makeAllNAs}{qPCRBatch}(qPCRBatch, contrastM, sampleMaxM)
}
\arguments{
- \item{qPCRBatch}{ Expression set containing qPCR data.
-}
+ \item{qPCRBatch}{ Expression set containing qPCR data.}
+ \item{\dots}{ Extra arguments, detailed below}
\item{contrastM}{ Contrast Matrix like that used in \code{limma}. Columns represent the different samples types, rows are the different samples,
-with a 1 or 0 in the matrix indicating which sample types the different samples belong to.
+with a 1 or 0 in the matrix indicating which sample types the different samples belong to.}
+ \item{sampleMaxM}{ Sample Max Matrix. Columns represent the different sample types. There is one value per column, which represents the max number of NAs allowed for that sample type.}
}
- \item{sampleMaxM}{ Sample Max Matrix. Columns represent the different sample types. There is one value per column, which represents the max number of NAs allowed for that sample type.
-}
-}
\details{
Make all NAs when number of NAs above a given threshold
}
@@ -50,4 +50,4 @@
qPCRBatch.taqman.replaced <- makeAllNAs(qPCRBatch.taqman, contM, sMaxM)
exprs(qPCRBatch.taqman.replaced)["Ccl20.Rn00570287_m1",]
}
-\keyword{data}
\ No newline at end of file
+\keyword{data}
Modified: pkg/NormqPCR/man/replaceAboveCutOff.Rd
===================================================================
--- pkg/NormqPCR/man/replaceAboveCutOff.Rd 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/man/replaceAboveCutOff.Rd 2011-03-23 08:51:26 UTC (rev 131)
@@ -5,16 +5,16 @@
\description{ Replace Ct values above a given threshold with a new value
}
\usage{
-replaceAboveCutOff(qPCRBatch, newVal=NA, cutOff=38)
+replaceAboveCutOff(qPCRBatch, \dots)
+
+\S4method{replaceAboveCutOff}{qPCRBatch}(qPCRBatch, newVal=NA, cutOff=38)
}
\arguments{
- \item{qPCRBatch}{ Expression set containing qPCR data.
+ \item{qPCRBatch}{ Expression set containing qPCR data. }
+ \item{\dots}{ Extra arguments, detailed below }
+ \item{newVal}{ The new value with which to replace the values above the cutoff }
+ \item{cutOff}{ the minimal threshold above which the values will be replaced }
}
- \item{newVal}{ The new value with which to replace the values above the cutoff
-}
- \item{cutOff}{ the minimal threshold above which the values will be replaced
-}
-}
\details{
Replaces values in the exprs slot of the \code{qPCRBatch} object that are above a threshold value with a new number
}
Modified: pkg/NormqPCR/man/replaceNAs.Rd
===================================================================
--- pkg/NormqPCR/man/replaceNAs.Rd 2011-02-22 19:50:14 UTC (rev 130)
+++ pkg/NormqPCR/man/replaceNAs.Rd 2011-03-23 08:51:26 UTC (rev 131)
@@ -5,14 +5,15 @@
\description{ Replace NAs with a given value
}
\usage{
-replaceNAs(qPCRBatch, newNA)
+replaceNAs(qPCRBatch, \dots)
+
+\S4method{replaceNAs}{qPCRBatch}(qPCRBatch, newNA)
}
\arguments{
- \item{qPCRBatch}{ Expression set containing qPCR data.
+ \item{qPCRBatch}{ Expression set containing qPCR data.}
+ \item{\dots}{ Extra arguments, detailed below}
+ \item{newNA}{ The new value to replace the NAs with}
}
- \item{newNA}{ The new value to replace the NAs with
-}
-}
\details{
Replaces NA values in the exprs slot of the qPCRBatch object with a given number
}
More information about the Qpcr-commits
mailing list