Browse code

Changed totalCopyNumber to totalCopynumber to be consistent with caps in crlmmCopynumber. Fixed a few bugs in the .Rd files

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/crlmm@48962 bc3139a8-67e5-0310-9ffc-ced21a209358

Rob Scharp authored on 21/08/2010 02:50:10
Showing7 changed files

... ...
@@ -75,18 +75,19 @@ export(crlmm,
75 75
        crlmmCopynumber2, crlmmCopynumberLD, crlmmCopynumber)
76 76
 export(constructIlluminaCNSet)
77 77
 ##export(linesCNSet)
78
-export(fit.lm1, fit.lm2, fit.lm3, fit.lm4, construct,
79
-       dqrlsWrapper, fit.wls)
80
-export(computeCopynumber, ACN)
81
-export(totalCopyNumber)
78
+##export(fit.lm1, fit.lm2, fit.lm3, fit.lm4, construct,
79
+##       dqrlsWrapper, fit.wls)
80
+export(computeCopynumber, totalCopynumber)
82 81
 export(cnrma, cnrma2)
82
+exportMethods(A, B, nuA, nuB, phiA, phiB, corr, tau2, Ns)
83
+export(genotypeSummary,
84
+       shrinkSummary,
85
+       estimateCnParameters)
86
+##       summarizeSnps,
87
+##       summarizeNps,
88
+##       shrinkGenotypeSummaries,
89
+##       summarizeMaleXGenotypes
83 90
 
84
-exportMethods("A<-", "B<-", "nuA", "nuB", "phiA", "phiB", "nuA<-", "nuB<-", "phiA<-", "phiB<-")
85
-exportMethods(Ns, medians, mads, tau2, corr)
86
-exportClasses(ff_or_matrix)
87
-export(genotypeSummary, summarizeSnps, summarizeNps, shrinkSummary, shrinkGenotypeSummaries, summarizeMaleXGenotypes,
88
-       indexComplete)
89
-export(Ns)
90 91
 ## For debugging
91 92
 ## exportPattern("^[^\\.]")
92 93
 
... ...
@@ -2428,7 +2428,7 @@ shrinkSummary <- function(object,
2428 2428
 		is.annotated <- !is.na(chromosome(object))
2429 2429
 		is.X <- chromosome(object) == 23
2430 2430
 		is.lds <- is(calls(object), "ffdf") | is(calls(object), "ff_matrix")
2431
-		if(is.lds) require(ff)
2431
+		if(is.lds) stopifnot(isPackageLoaded("ff"))
2432 2432
 		marker.index <- whichMarkers(type[[1]], is.snp, is.autosome, is.annotated, is.X)
2433 2433
 	}
2434 2434
 	summaryFxn <- function(type){
... ...
@@ -2484,7 +2484,7 @@ genotypeSummary <- function(object,
2484 2484
 		is.annotated <- !is.na(chromosome(object))
2485 2485
 		is.X <- chromosome(object) == 23
2486 2486
 		is.lds <- is(calls(object), "ffdf") | is(calls(object), "ff_matrix")
2487
-		if(is.lds) stopifnot(isPackagedLoaded("ff"))
2487
+		if(is.lds) stopifnot(isPackageLoaded("ff"))
2488 2488
 		marker.index <- whichMarkers(type[[1]], is.snp, is.autosome, is.annotated, is.X)
2489 2489
 	}
2490 2490
 	summaryFxn <- function(type){
... ...
@@ -2786,7 +2786,7 @@ estimateCnParameters <- function(object,
2786 2786
 		is.annotated <- !is.na(chromosome(object))
2787 2787
 		is.X <- chromosome(object) == 23
2788 2788
 		is.lds <- is(calls(object), "ffdf") | is(calls(object), "ff_matrix")
2789
-		if(is.lds) require(ff)
2789
+		if(is.lds) stopifnot(isPackageLoaded("ff"))
2790 2790
 		CHR.X <- ifelse(type[[1]] %in% c("X.SNP", "X.NP"), TRUE, FALSE)
2791 2791
 		marker.index <- whichMarkers(type[[1]], is.snp, is.autosome, is.annotated, is.X)
2792 2792
 	}
... ...
@@ -321,34 +321,34 @@ setReplaceMethod("flags", signature=signature(object="CNSet", value="ff_matrix")
321 321
 ##	ellipse.CNSet(x, copynumber, batch, ...)
322 322
 ##})
323 323
 
324
-ACN.X <- function(object, allele, i, j){
325
-	acn <- list()
326
-	batches <- unique(batch(object)[j])
327
-	for(k in seq_along(batches)){
328
-		l <- match(batches[k], bns)
329
-		nuA <- nuA(object)[ii, l]
330
-		nuB <- nuB(object)[ii, l]
331
-		phiA <- phiA(object)[ii, l]
332
-		phiB <- phiB(object)[ii, l]
333
-		phiPrimeA <- phiPrimeA(object)[ii, l]
334
-		phiPrimeB <- phiPrimeB(object)[ii, l]
335
-		if(all(is.na(phiPrimeA))){
336
-			I <- allele(object, allele)[ii, j]
337
-			if(allele=="A") acn[[k]] <- 1/phiA*(I - nuA)
338
-			if(allele=="B") acn[[k]] <- 1/phiB*(I - nuB)
339
-		} else {
340
-			A <- A(object)[ii, j]
341
-			B <- B(object)[ii, j]
342
-			phistar <- phiPrimeB/phiA
343
-			tmp <- (B-nuB - phistar*A + phistar*nuA)/phiB
344
-			cb <- tmp/(1-phistar*phiPrime/phiB)
345
-			ca <- A-nuA-phiPrimeA*cb/phiA
346
-			if(allele=="A") acn[[k]] <- ca
347
-			if(allele=="B") acn[[k]] <- cb
348
-		}
349
-	}
350
-	return(acn)
351
-}
324
+##ACN.X <- function(object, allele, i, j){
325
+##	acn <- list()
326
+##	batches <- unique(batch(object)[j])
327
+##	for(k in seq_along(batches)){
328
+##		l <- match(batches[k], bns)
329
+##		nuA <- nuA(object)[ii, l]
330
+##		nuB <- nuB(object)[ii, l]
331
+##		phiA <- phiA(object)[ii, l]
332
+##		phiB <- phiB(object)[ii, l]
333
+##		phiPrimeA <- phiPrimeA(object)[ii, l]
334
+##		phiPrimeB <- phiPrimeB(object)[ii, l]
335
+##		if(all(is.na(phiPrimeA))){
336
+##			I <- allele(object, allele)[ii, j]
337
+##			if(allele=="A") acn[[k]] <- 1/phiA*(I - nuA)
338
+##			if(allele=="B") acn[[k]] <- 1/phiB*(I - nuB)
339
+##		} else {
340
+##			A <- A(object)[ii, j]
341
+##			B <- B(object)[ii, j]
342
+##			phistar <- phiPrimeB/phiA
343
+##			tmp <- (B-nuB - phistar*A + phistar*nuA)/phiB
344
+##			cb <- tmp/(1-phistar*phiPrime/phiB)
345
+##			ca <- A-nuA-phiPrimeA*cb/phiA
346
+##			if(allele=="A") acn[[k]] <- ca
347
+##			if(allele=="B") acn[[k]] <- cb
348
+##		}
349
+##	}
350
+##	return(acn)
351
+##}
352 352
 
353 353
 
354 354
 ACN <- function(object, allele, i , j){
... ...
@@ -421,7 +421,7 @@ setMethod("CB", signature=signature(object="CNSet"),
421 421
 		  return(cb)
422 422
 	  })
423 423
 
424
-totalCopyNumber <- function(object, ...){
424
+totalCopynumber <- function(object, ...){
425 425
 	message("copy number at nonpolymorphic probes is not currently available")
426 426
 	ca <- CA(object, ...)
427 427
 	cb <- CB(object, ...)
... ...
@@ -4,7 +4,7 @@
4 4
 \alias{CA,CNSet-method}
5 5
 \alias{CB,CNSet-method}
6 6
 \alias{lines,CNSet-method}
7
-\alias{totalCopyNumber,CNSet-method}
7
+\alias{totalCopynumber,CNSet-method}
8 8
 
9 9
 \title{crlmm methods for class "CNSet"}
10 10
 \description{
... ...
@@ -26,7 +26,7 @@
26 26
     \item{CA}{\code{signature(object="CNSet")}: ...}
27 27
     \item{CB}{\code{signature(object="CNSet")}: ...}
28 28
     \item{lines}{\code{signature(x="CNSet")}: ...}
29
-    \item{totalCopyNumber}{\code{signature(object="CNSet")}: ...}
29
+    \item{totalCopynumber}{\code{signature(object="CNSet")}: ...}
30 30
 	 }
31 31
 }
32 32
 
... ...
@@ -1,7 +1,7 @@
1 1
 \name{copynumberAccessors}
2 2
 \alias{CA}
3 3
 \alias{CB}
4
-\alias{totalCopyNumber}
4
+\alias{totalCopynumber}
5 5
 
6 6
 \title{
7 7
 
... ...
@@ -19,20 +19,16 @@ been generated by the \code{crlmmCopynumber} function.
19 19
 \usage{
20 20
 CA(object, ...)
21 21
 CB(object, ...)
22
-totalCopyNumber(object,...)
22
+totalCopynumber(object,...)
23 23
 }
24 24
 
25 25
 \arguments{
26
-  \item{object}{
27
-  An object of class \code{CNSet}.
28
-}
26
+  \item{object}{  An object of class \code{CNSet}.}
29 27
   \item{\dots}{
30
-
31 28
   An additional argument named 'i' can be passed to subset the markers
32 29
   and an argument 'j' can be passed to subset the samples.  Other
33 30
   arguments are ignored.
34
-
35
-}
31
+  }
36 32
 }
37 33
 
38 34
 \details{
... ...
@@ -49,8 +45,11 @@ totalCopyNumber(object,...)
49 45
 }
50 46
 
51 47
 \seealso{
52
-	\code{\link{crlmmCopynumber}}, \code{\link{CNSet-class}} 
48
+
49
+	\code{\link{crlmmCopynumber}}, \code{\link{CNSet-class}}
50
+
53 51
 }
52
+
54 53
 \examples{
55 54
 data(sample.CNSetLM)
56 55
 ## update to class CNSet
... ...
@@ -75,9 +74,9 @@ cn2 <- CA(cnSet, i=index, j=1:2)
75 74
 ## note, ca+cb will give NAs at nonpolymorphic loci
76 75
 CA(cnSet, i=index, j=1:2) + cb
77 76
 ## A shortcut for total copy number
78
-cn3 <- totalCopyNumber(cnSet, i=1:5, j=1:2)
77
+cn3 <- totalCopynumber(cnSet, i=1:5, j=1:2)
79 78
 all.equal(cn3, cn1)
80
-cn4 <- totalCopyNumber(cnSet, i=index, j=1:2)
79
+cn4 <- totalCopynumber(cnSet, i=index, j=1:2)
81 80
 all.equal(cn4, cn2)
82 81
 
83 82
 ## markers 1-5, all samples
... ...
@@ -9,12 +9,12 @@
9 9
 	Preprocessing and genotyping of Affymetrix arrays.	
10 10
 }
11 11
 \usage{
12
-genotype(filenames, cdfName, batch, mixtureSampleSize = 10^5, eps =
13
-0.1, verbose = TRUE, seed = 1, sns, copynumber =TRUE, probs =
14
-rep(1/3, 3), DF = 6, SNRMin = 5, recallMin = 10, recallRegMin = 1000,
15
-gender = NULL, returnParams = TRUE, badSNP = 0.7)
12
+genotype(filenames, cdfName, batch, mixtureSampleSize = 10^5, eps =0.1,
13
+         verbose = TRUE, seed = 1, sns, probs = rep(1/3, 3),
14
+         DF = 6, SNRMin = 5, recallMin = 10, recallRegMin = 1000,
15
+         gender = NULL, returnParams = TRUE, badSNP = 0.7)
16
+
16 17
 
17
-genotypeLD(filenames, cdfName, batch, mixtureSampleSize = 10^5, eps = 0.1, verbose = TRUE, seed = 1, sns, copynumber = TRUE, probs = rep(1/3, 3), DF = 6, SNRMin = 5, recallMin = 10, recallRegMin = 1000, gender = NULL, returnParams = TRUE, badSNP = 0.7)
18 18
 }
19 19
 \arguments{
20 20
   \item{filenames}{ complete path to CEL files}
... ...
@@ -26,7 +26,6 @@ genotypeLD(filenames, cdfName, batch, mixtureSampleSize = 10^5, eps = 0.1, verbo
26 26
   \item{verbose}{  Logical.  Whether to print descriptive messages during processing.}
27 27
   \item{seed}{ Seed to be used when sampling. Useful for reproducibility}
28 28
   \item{sns}{The sample identifiers.  If missing, the default sample names are \code{basename(filenames)}}
29
-  \item{copynumber}{ Whether to quantile normalize the nonpolymorphic probes.  If TRUE, the quantile normalized intensities for nonpolymorphic markers are included in the 'A' matrix.}
30 29
   \item{probs}{'numeric' vector with priors for AA, AB and BB.}
31 30
   \item{DF}{'integer' with number of degrees of freedom to use with t-distribution.}
32 31
   \item{SNRMin}{'numeric' scalar defining the minimum SNR used to filter
... ...
@@ -42,17 +41,12 @@ genotypeLD(filenames, cdfName, batch, mixtureSampleSize = 10^5, eps = 0.1, verbo
42 41
 \details{
43 42
 
44 43
 	For large datasets it is important to utilize the large data
45
-	support by installing and loading the ff package before
46
-	calling the genotype or genotypeLD function.
47
-
48
-	Currently, two functions are provided for preprocessing and
49
-	genotyping Affymetrix platforms: genotype and genotypeLD. For
50
-	small datasets, genotype and genotypeLD are identical.  For
51
-	large datasets, genotypeLD provides large data support (via ff)
52
-	and permits the use of clusters or multiple cores (via snow
53
-	package) to speed up genotyping (similar to \code{crlmm2}).
54
-	The \code{genotype} function will be phased out in the future
55
-	and replaced by \code{genotypeLD}.
44
+	support by installing and loading the ff package before calling
45
+	the \code{genotype} function. In previous versions of the
46
+	\code{crlmm} package, we useed different functions for
47
+	genotyping depending on whether the ff package is loaded, namely
48
+	\code{genotype} and \code{genotype2}.  The \code{genotype}
49
+	function now handles both instances.
56 50
 
57 51
 }
58 52
 
... ...
@@ -89,19 +83,19 @@ if (require(ff) & require(genomewidesnp6Crlmm) & require(hapmapsnp6)){
89 83
   ## very useful when genotyping samples not in the working directory
90 84
   cels <- list.celfiles(path, full.names=TRUE)
91 85
 
86
+  ## Note: one would need at least 10 CEL files for copy number estimation
92 87
   ## To use less RAM, specify a smaller argument to ocProbesets
93 88
   ocProbesets(50e3)
94
-  (cnSet <- genotypeLD(cels, cdfName="genomewidesnp6",
95
-  copynumber=TRUE))
89
+  batch <- as.factor(rep("A", length(cels)))
90
+  (cnSet <- genotype(cels, cdfName="genomewidesnp6"))
96 91
 
97 92
   dim(cnSet)
98 93
   table(isSnp(cnSet))
99 94
 
100 95
 ## The above is a trivial example.  Typically you may have a large
101 96
 ##    number of cel files, many of which were processed at different
102
-##    times. For such datasets, it is important to set a batch
103
-##    variable.  If not specified, the scan date of the file is used
104
-##    as the batch variable.  
97
+##    times. For such datasets, it is important to specify a batch
98
+##    variable.  
105 99
       batch(cnSet)
106 100
       protocolData(cnSet)$ScanDate
107 101
 }
... ...
@@ -31,13 +31,13 @@ data(sample.CNSetLM)
31 31
 cnSet <- as(sample.CNSetLM, "CNSet")
32 32
 all(isCurrent(cnSet)) ## is the cnSet object current?
33 33
 
34
-library(crlmm)
34
+## updating class CNSetLM using ff objects
35 35
 library(ff)
36
-outdir <- "~/madman/Rpacks/crlmm/inst/extdata"
37
-ldPath(outdir)
36
+path <- system.file("extdata", package="crlmm")
37
+ldPath(path)
38 38
 data(sample.CNSetLMff)
39
-cnSetff <- as(sample.CNSetLMff, "CNSet")
40
-all(isCurrent(cnSetff))
39
+cnSet <- as(sample.CNSetLMff, "CNSet")
40
+all(isCurrent(cnSet))
41 41
 
42 42
 ## a bigger object with multiple batches
43 43
 \dontrun{