Browse code

Added SNP plotting functions

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

unknown authored on 06/05/2016 06:53:13
Showing3 changed files

... ...
@@ -1,8 +1,8 @@
1 1
 Package: crlmm
2 2
 Type: Package
3 3
 Title: Genotype Calling (CRLMM) and Copy Number Analysis tool for
4
-        Affymetrix SNP 5.0 and 6.0 and Illumina arrays.
5
-Version: 1.31.1
4
+        Affymetrix SNP 5.0 and 6.0 and Illumina arrays
5
+Version: 1.31.2
6 6
 Author: Benilton S Carvalho, Robert Scharpf, Matt Ritchie, Ingo
7 7
         Ruczinski, Rafael A Irizarry
8 8
 Maintainer: Benilton S Carvalho <benilton@unicamp.br>,
... ...
@@ -10,7 +10,7 @@ Maintainer: Benilton S Carvalho <benilton@unicamp.br>,
10 10
         <mritchie@wehi.EDU.AU>
11 11
 Description: Faster implementation of CRLMM specific to SNP 5.0 and 6.0
12 12
         arrays, as well as a copy number tool specific to 5.0, 6.0, and
13
-        Illumina platforms
13
+        Illumina platforms.
14 14
 License: Artistic-2.0
15 15
 Depends: R (>= 2.14.0), oligoClasses (>= 1.21.12), preprocessCore (>=
16 16
         1.17.7)
17 17
new file mode 100644
... ...
@@ -0,0 +1,48 @@
1
+plotSamples = function(cnSet, col=1, offset=0, xlim=c(9,16), ylim=c(-5,5), verbose=FALSE, sample=100000, seed=1, type="smoothScatter"){
2
+    if(missing(col)){
3
+        stop("col is missing, please specify which sample/(s) to plot")
4
+    }
5
+    set.seed(seed)
6
+    row = sample(nrow(cnSet), sample)
7
+    if(verbose)  
8
+      message("compute M values")        
9
+    M = computeLogRatio(cnSet, offset=offset, verbose=verbose, row=row, col=col)
10
+    if(type=="beanplot") {
11
+      sel = rowSums(is.finite(M[,]) & !is.na(M[,]))==ncol(M)
12
+      beanplot(as.vector(M[sel,])~factor(rep(col, each=sum(sel))), ylab="M", xlab="Sample", ylim=ylim,
13
+               beanlines="median", what=c(0,1,1,0), col="grey", border="black") #c("#CAB2D6", "#33A02C", "#B2DF8A"), border = "#CAB2D6", 
14
+      abline(h=0, col="gray", lty=2)
15
+      delete(M); rm(M)
16
+    }
17
+    if(type=="smoothScatter") {
18
+      if(verbose)
19
+        message("compute S values")
20
+      S = computeAverageLogIntensity(cnSet, offset=offset, verbose=verbose, row=row, col=col)
21
+      for(i in 1:length(col)) {
22
+        smoothScatter(S[,i], M[,i], main=colnames(M)[i], ylab="M", xlab="S", xlim=xlim, ylim=ylim)
23
+        abline(h=0, col="gray", lty=2)
24
+      }
25
+    delete(S, M); rm(S, M)
26
+    }
27
+}
28
+
29
+
30
+plotSNPs = function(cnSet, row=1, offset=0, xlim=c(9,16), ylim=c(-5,5), verbose=FALSE){
31
+    if(missing(row)){
32
+        stop("row is missing, please specify which SNP/(s) to plot")
33
+    }
34
+    if(verbose)  
35
+      message("compute M values")        
36
+    M = computeLogRatio(cnSet, offset=offset, verbose=verbose, row=row)
37
+    if(verbose)
38
+      message("compute S values")   
39
+    S = computeAverageLogIntensity(cnSet, offset=offset, verbose=verbose, row=row)
40
+    if(verbose)
41
+      message("get genotype calls")
42
+    for(i in 1:length(row)){
43
+       plot(S[i,], M[i,], xlab="S", ylab="M", xlim=xlim, ylim=ylim,
44
+            main=rownames(M)[i], pch=19, col=calls(cnSet)[row[i],])
45
+       abline(h=0, col="gray", lty=2)
46
+    }
47
+    rm(S, M)
48
+}
0 49
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+\name{plotSNPs}
2
+\alias{plotSNPs}
3
+\alias{plotSamples}
4
+
5
+\title{
6
+	Make M vs S plot for SNPs or samples.
7
+}
8
+
9
+\description{
10
+	These functions plot the M-values (log-ratios) versus S-values (average intensities)
11
+        for given SNP/(s) or sample/(s) or beanplots for M-values from different samples.
12
+}
13
+
14
+\usage{
15
+	plotSNPs(cnSet, row=1, offset=0, xlim=c(9,16), ylim=c(-5,5), verbose=FALSE)
16
+	plotSamples(cnSet, col=1, offset=0, xlim=c(9,16), ylim=c(-5,5), verbose=FALSE, sample=100000, seed=1, type="smoothScatter")
17
+}
18
+
19
+\arguments{
20
+  \item{cnSet}{An object of class \code{CNSet}}
21
+  \item{row}{scalar/vector of SNP indexes to plot}
22
+  \item{col}{scalar/vector of sample indexes to plot}
23
+  \item{offset}{numeric, offset to add to intensities in \code{cnSet} 
24
+        before log2-transforming to make log-ratios or average log-intensities}
25
+  \item{xlim}{the x limits of the plot}
26
+  \item{ylim}{the y limits of the plot}
27
+  \item{verbose}{'logical.'  Whether to print descriptive messages during processing}
28
+  \item{sample}{integer indicating the number of SNPs to sample for the plot}
29
+  \item{seed}{integer seed for the random number generator to sample the SNPs}
30
+  \item{type}{character vector specifying the type of sample plot (either 'smoothScatter' or 'beanplot')}
31
+}
32
+
33
+\details{
34
+	The \code{plotSNPs} and \code{plotSamples} functions plot the M and S
35
+        values derived from the \code{cnSet} object.
36
+      }
37
+
38
+\value{
39
+      One or more M vs S plot for \code{plotSNPs} for a given SNP(/s)
40
+      or either a smoothed scatter plot of M vs S or a beanplot of the M-values 
41
+      for a selected sample(/s) for \code{plotSamples}.
42
+}
43
+
44
+\author{
45
+      Matt Ritchie and Cynthia Liu
46
+}
47
+
48
+\seealso{
49
+	\code{\link{genotype.Illumina}}
50
+}
51
+\examples{
52
+\dontrun{
53
+   crlmmResult <- genotype.Illumina(sampleSheet=samples[1:10,], path=path,
54
+                                        arrayInfoColNames=list(barcode=NULL,
55
+                                        position="SentrixPosition"),
56
+                                        saveDate=TRUE, cdfName="human370v1c")
57
+   par(mfrow=c(2,2))
58
+   plotSamples(crlmmResult, col=1:4)
59
+   plotSNPs(crlmmResult, row=1:4)
60
+}
61
+}
62
+\keyword{hplot}
0 63
\ No newline at end of file