Browse code

Fixed minor bugs in verbosity

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

Benilton Carvalho authored on 15/01/2009 04:04:31
Showing7 changed files

... ...
@@ -1,13 +1,14 @@
1 1
 Package: crlmm
2 2
 Type: Package
3 3
 Title: Genotype Calling via CRLMM Algorithm
4
-Version: 1.24
4
+Version: 1.27
5 5
 Date: 2008-12-28
6 6
 Author: Rafael A Irizarry
7 7
 Maintainer: Benilton S Carvalho <bcarvalh@jhsph.edu>
8 8
 Description: Faster implementation of CRLMM specific to SNP 5.0 and 6.0 arrays.
9 9
 License: Artistic-2.0
10 10
 Depends: methods, affyio, preprocessCore, utils
11
+Suggests: hapmapsnp5, genomewidesnp5Crlmm
11 12
 Collate: crlmmGT.R
12 13
          crlmm.R
13 14
          fitAffySnpMixture56.R
... ...
@@ -8,11 +8,12 @@ crlmm <- function(filenames, row.names=TRUE, col.names=TRUE,
8 8
     stop("'intensityFile' is missing, and you chose either load.it or save.it")
9 9
   
10 10
   if (missing(sns)) sns <- basename(filenames)
11
-  if (load.it & !file.exists(intensityFile)){
12
-    load.it <- FALSE
13
-    message("File ", intensityFile, " does not exist.")
14
-    message("Not loading it, but running SNPRMA from scratch.")
15
-  }
11
+  if (!missing(intensityFile))
12
+    if (load.it & !file.exists(intensityFile)){
13
+      load.it <- FALSE
14
+      message("File ", intensityFile, " does not exist.")
15
+      message("Not loading it, but running SNPRMA from scratch.")
16
+    }
16 17
   if (!load.it){
17 18
     res <- snprma(filenames, fitMixture=TRUE,
18 19
                   mixtureSampleSize=mixtureSampleSize, verbose=verbose,
... ...
@@ -38,7 +39,8 @@ crlmm <- function(filenames, row.names=TRUE, col.names=TRUE,
38 39
                   gender=gender, row.names=row.names,
39 40
                   col.names=col.names, recallMin=recallMin,
40 41
                   recallRegMin=1000, SNRMin=SNRMin,
41
-                  returnParams=returnParams, badSNP=badSNP)
42
+                  returnParams=returnParams, badSNP=badSNP,
43
+                  verbose=verbose)
42 44
 
43 45
   res2[["SNR"]] <- res[["SNR"]]
44 46
   res2[["SKW"]] <- res[["SKW"]]
... ...
@@ -11,7 +11,7 @@ crlmmGT <- function(A, B, SNR, mixtureParams, cdfName, row.names=NULL,
11 11
   NR <- nrow(A)
12 12
   
13 13
   pkgname <- getCrlmmAnnotationName(cdfName)
14
-  if(!require(pkgname, character.only=TRUE)){
14
+  if(!require(pkgname, character.only=TRUE, quietly=!verbose)){
15 15
     suggCall <- paste("library(", pkgname, ", lib.loc='/Altern/Lib/Loc')", sep="")
16 16
     msg <- paste("If", pkgname, "is installed on an alternative location, please load it manually by using", suggCall)
17 17
     message(strwrap(msg))
... ...
@@ -30,6 +30,7 @@ crlmmGT <- function(A, B, SNR, mixtureParams, cdfName, row.names=NULL,
30 30
   SMEDIAN <- getVarInEnv("SMEDIAN")
31 31
   theKnots <- getVarInEnv("theKnots")
32 32
   regionInfo <- getVarInEnv("regionInfo")
33
+  params <- getVarInEnv("params")
33 34
   
34 35
   ##IF gender not provide, we predict
35 36
   if(is.null(gender)){
... ...
@@ -4,7 +4,7 @@ snprma <- function(filenames, mixtureSampleSize=10^5, fitMixture=FALSE, eps=0.1,
4 4
     cdfName <- read.celfile.header(filenames[1])$cdfName
5 5
 ##  stuffDir <- changeToCrlmmAnnotationName(cdfName)
6 6
   pkgname <- getCrlmmAnnotationName(cdfName)
7
-  if(!require(pkgname, character.only=TRUE)){
7
+  if(!require(pkgname, character.only=TRUE, quietly=!verbose)){
8 8
     suggCall <- paste("library(", pkgname, ", lib.loc='/Altern/Lib/Loc')", sep="")
9 9
     msg <- paste("If", pkgname, "is installed on an alternative location, please load it manually by using", suggCall)
10 10
     message(strwrap(msg))
... ...
@@ -73,7 +73,7 @@ snprma <- function(filenames, mixtureSampleSize=10^5, fitMixture=FALSE, eps=0.1,
73 73
     }
74 74
     if (verbose) setTxtProgressBar(pb, i)
75 75
   }
76
-  close(pb)
76
+  if (verbose) close(pb)
77 77
   if (!fitMixture) SNR <- mixtureParams <- NA
78 78
   ## gns comes from preprocStuff.rda
79 79
   list(A=A, B=B, sns=sns, gns=gns, SNR=SNR, SKW=SKW, mixtureParams=mixtureParams, cdfName=cdfName)
80 80
new file mode 100644
... ...
@@ -0,0 +1,84 @@
1
+%\VignetteIndexEntry{crlmm Vignette}
2
+%\VignetteDepends{crlmm, hapmapsnp5, genomewidesnp5Crlmm}
3
+%\VignetteKeywords{genotype, crlmm, SNP 5, SNP 6}
4
+%\VignettePackage{crlmm}
5
+\documentclass{article}
6
+
7
+\newcommand{\Rfunction}[1]{{\texttt{#1}}}
8
+\newcommand{\Rmethod}[1]{{\texttt{#1}}}
9
+\newcommand{\Rcode}[1]{{\texttt{#1}}}
10
+\newcommand{\Robject}[1]{{\texttt{#1}}}
11
+\newcommand{\Rpackage}[1]{{\textsf{#1}}}
12
+\newcommand{\Rclass}[1]{{\textit{#1}}}
13
+\newcommand{\oligo}{\Rpackage{oligo }}
14
+
15
+\begin{document}
16
+\title{Genotyping with the \Rpackage{crlmm} Package}
17
+\date{January, 2009}
18
+\author{Benilton Carvalho}
19
+\maketitle
20
+
21
+<<setup, echo=FALSE, results=hide>>=
22
+options(width=60)
23
+options(continue=" ")
24
+options(prompt="R> ")
25
+@ 
26
+
27
+\section{Quick intro to \Rpackage{crlmm}}
28
+
29
+The \Rpackage{crlmm} package contains a new implementation for the
30
+CRLMM algorithm (Carvalho et. al. 2007). Our focus is on efficient
31
+genotyping of SNP 5.0 and 6.0 Affymetrix arrays, although extensions
32
+of the method are under development for similar platforms.
33
+
34
+This implementation, compared to the previous one (in
35
+\Rpackage{oligo}), offers improved confidence scores, quality scores
36
+for SNP's and batches, higher accuracy on different datasets and
37
+better performance.
38
+
39
+Additionally, this package does not use the pd.genomewidesnp packages
40
+created via pdInfoBuilder for \Rpackage{oligo}. Instead, it uses
41
+different annotation packages (\Rpackage{genomewidesnp.5} and
42
+\Rpackage{genomewidesnp.6}), which use simple R objects to store only
43
+the information needed for genotyping. This allowed us to improve the
44
+speed of the method, as SQL queries are no longer performed here.
45
+
46
+It is also our priority to make the package simple to use. Below we
47
+demonstrate how to get genotype calls with the 'new' CRLMM. We use 3
48
+samples on SNP 5.0 made available via the \Rpackage{hapmapsnp5}
49
+package.
50
+
51
+<<crlmm>>=
52
+library(crlmm)
53
+library(hapmapsnp5)
54
+path <- system.file("celFiles", package="hapmapsnp5")
55
+celFiles <- list.celfiles(path, full.names=TRUE)
56
+system.time(crlmmResult <- crlmm(celFiles, verbose=FALSE))
57
+@ 
58
+
59
+The \Robject{crlmmResult} is a list with the following components:
60
+\begin{itemize}
61
+\item \Robject{calls}: genotype calls (1 - AA; 2 - AB; 3 - BB);
62
+\item \Robject{confs}: confidence scores, which can be translated to probabilities by using:
63
+  \[ 1-2^-(\mbox{confs}/1000), \] although we prefer this
64
+  representation as it saves a significant amount of memory;
65
+\item \Robject{SNPQC}: SNP quality score;
66
+\item \Robject{batchQC}: Batch quality score;
67
+\item \Robject{SNR}: Signal-to-noise ratio.
68
+\end{itemize}
69
+
70
+<<out>>=
71
+crlmmResult[["calls"]][1:10,]
72
+crlmmResult[["confs"]][1:10,]
73
+@ 
74
+
75
+\section{Details}
76
+
77
+This document was written using:
78
+
79
+<<>>=
80
+sessionInfo()
81
+@ 
82
+
83
+
84
+\end{document}
0 85
new file mode 100644
1 86
Binary files /dev/null and b/inst/doc/crlmm.pdf differ
... ...
@@ -131,7 +131,7 @@ SEXP gtypeCallerPart1(SEXP A, SEXP B, SEXP fIndex, SEXP mIndex,
131 131
     int ibv[ib2];
132 132
     if (nSnpsPerClass[h] > 0)
133 133
       for (i=0; i < ptr2nIndexes[h]; i++){
134
-	if (i%100000 == 0) Rprintf("+");
134
+	/* if (i%100000 == 0) Rprintf("+");*/
135 135
 	// Substract 1, as coming from R it is 1-based and C is 0-based.
136 136
 	ii=INTEGER(VECTOR_ELT(Indexes, h))[i] - 1;
137 137
 	for (j=0; j < colsAB; j++){
... ...
@@ -348,7 +348,7 @@ SEXP gtypeCallerPart2(SEXP A, SEXP B, SEXP fIndex, SEXP mIndex,
348 348
   for (h=0; h < nSnpClasses; h++){
349 349
     if (nSnpsPerClass[h] > 0)
350 350
       for (i=0; i < ptr2nIndexes[h]; i++){
351
-	if (i%100000 == 0) Rprintf("+");
351
+	/* if (i%100000 == 0) Rprintf("+"); */
352 352
 	// Substract 1, as coming from R it is 1-based and C is 0-based.
353 353
 	ii=INTEGER(VECTOR_ELT(Indexes, h))[i] - 1;
354 354
 	intbuffer = ii+1;