[Rflptools-commits] r14 - in pkg/RFLPtools: . R inst/doc man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jan 4 17:42:46 CET 2013
Author: stamats
Date: 2013-01-04 17:42:46 +0100 (Fri, 04 Jan 2013)
New Revision: 14
Added:
pkg/RFLPtools/R/RFLPcombine.R
pkg/RFLPtools/R/RFLPlod.R
Modified:
pkg/RFLPtools/DESCRIPTION
pkg/RFLPtools/NAMESPACE
pkg/RFLPtools/NEWS
pkg/RFLPtools/R/RFLPdist2.R
pkg/RFLPtools/R/RFLPplot.R
pkg/RFLPtools/R/RFLPqc.R
pkg/RFLPtools/R/RFLPrefplot.R
pkg/RFLPtools/inst/doc/RFLPtools.pdf
pkg/RFLPtools/man/0RFLP-package.Rd
pkg/RFLPtools/man/RFLPdist2.Rd
pkg/RFLPtools/man/RFLPplot.Rd
pkg/RFLPtools/man/RFLPrefplot.Rd
pkg/RFLPtools/vignettes/RFLPtools.Rnw
Log:
several updates and extensions see NEWS file
Modified: pkg/RFLPtools/DESCRIPTION
===================================================================
--- pkg/RFLPtools/DESCRIPTION 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/DESCRIPTION 2013-01-04 16:42:46 UTC (rev 14)
@@ -2,7 +2,7 @@
Type: Package
Title: Tools to analyse RFLP data
Version: 1.5
-Date: 2013-01-03
+Date: 2013-01-04
Author: Fabienne Flessa, Alexandra Kehl, Matthias Kohl
Maintainer: Matthias Kohl <Matthias.Kohl at stamats.de>
Description: RFLPtools provides functions to analyse DNA fragment samples
Modified: pkg/RFLPtools/NAMESPACE
===================================================================
--- pkg/RFLPtools/NAMESPACE 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/NAMESPACE 2013-01-04 16:42:46 UTC (rev 14)
@@ -8,6 +8,7 @@
RFLPdist2ref,
RFLPrefplot,
RFLPcombine,
+ RFLPlod,
nrBands,
read.blast,
simMatrix,
Modified: pkg/RFLPtools/NEWS
===================================================================
--- pkg/RFLPtools/NEWS 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/NEWS 2013-01-04 16:42:46 UTC (rev 14)
@@ -5,7 +5,12 @@
###########################################################
## Version 1.5
###########################################################
+- update of vignette
+- extension of function RFLPdist2: additional option that missing bands
+ occur only below a specified LOD
- new function RFLPcombine to combine RFLP datasets
+- new function RFLPlod to remove bands below a given limit LOD
+- more flexible arguments for functions RFLPplot and RFLPrefplot
###########################################################
Added: pkg/RFLPtools/R/RFLPcombine.R
===================================================================
--- pkg/RFLPtools/R/RFLPcombine.R (rev 0)
+++ pkg/RFLPtools/R/RFLPcombine.R 2013-01-04 16:42:46 UTC (rev 14)
@@ -0,0 +1,27 @@
+###############################################################################
+## Combine data sets
+###############################################################################
+
+RFLPcombine <- function(...){
+ x <- list(...)
+ if(length(x) < 2)
+ stop("You have to specify at least two data sets!")
+ nams0 <- unique(x[[1]]$Sample)
+ for(i in 2:length(x)){
+ n0 <- length(nams0)
+ ## extract sample names for dataset i
+ nams1 <- unique(x[[i]]$Sample)
+ ## make unique names
+ nams0 <- make.unique(c(nams0, nams1))
+ ## extract unique names for dataset i
+ nams2 <- nams0[(n0+1):length(nams0)]
+ ## names that have been changed
+ nams3 <- nams1[nams1 != nams2]
+ nams4 <- nams2[nams1 != nams2]
+ ## replace names that have been changed by unique names
+ for(j in 1:length(nams3)){
+ x[[i]]$Sample[x[[i]]$Sample == nams3[j]] <- nams4[j]
+ }
+ }
+ do.call('rbind', x)
+}
Modified: pkg/RFLPtools/R/RFLPdist2.R
===================================================================
--- pkg/RFLPtools/R/RFLPdist2.R 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/R/RFLPdist2.R 2013-01-04 16:42:46 UTC (rev 14)
@@ -14,37 +14,94 @@
## diag: see ?dist
## upper: see ?dist
## compares samples with number of bands in: nrBands, nrBands + 1, ..., nrBands + nrMissing
-RFLPdist2 <- function(x, distfun = dist, nrBands, nrMissing, diag = FALSE, upper = FALSE){
+RFLPdist2 <- function(x, distfun = dist, nrBands, nrMissing, LOD, diag = FALSE, upper = FALSE){
stopifnot(is.data.frame(x))
stopifnot(is.function(distfun))
+ if(missing(nrMissing))
+ stop("'nrMissing' is not specified!")
+ if(nrMissing == 0)
+ stop("'nrMissing == 0', please use function 'RFLPdist'!")
- x1 <- split(x, x$Sample)
- x1.bands <- sapply(x1, nrow)
+ if(missing(LOD)){
+ x1 <- split(x, x$Sample)
+ x1.bands <- sapply(x1, nrow)
- temp <- do.call("rbind", x1[x1.bands %in% c(nrBands:(nrBands+nrMissing))])
- temp1 <- split(temp[,"MW"], factor(temp[,"Sample"]))
- N <- length(temp1)
- temp2 <- matrix(NA, ncol = nrBands + nrMissing, nrow = N)
- rownames(temp2) <- names(temp1)
- for(i in 1:N){
- temp2[i,1:length(temp1[[i]])] <- temp1[[i]]
- }
- d <- matrix(NA, nrow = N, ncol = N)
- dfun <- function(x, y){
- m <- sum(!is.na(x))
- min(as.matrix(distfun(rbind(x[1:m], t(combn(y, m)))))[-1,1])
- }
- for(i in 1:N){
- for(j in 1:i){
- if(sum(!is.na(temp2[i,])) == sum(!is.na(temp2[j,]))){
- m <- sum(!is.na(temp2[i,]))
- d[i,j] <- as.vector(distfun(rbind(temp2[i,1:m], temp2[j,1:m])))
+ temp <- do.call("rbind", x1[x1.bands %in% c(nrBands:(nrBands+nrMissing))])
+ temp1 <- split(temp[,"MW"], factor(temp[,"Sample"]))
+ N <- length(temp1)
+ temp2 <- matrix(NA, ncol = nrBands + nrMissing, nrow = N)
+ rownames(temp2) <- names(temp1)
+ for(i in 1:N){
+ temp2[i,1:length(temp1[[i]])] <- temp1[[i]]
+ }
+ d <- matrix(NA, nrow = N, ncol = N)
+ dfun1 <- function(x, y){
+ y <- y[!is.na(y)]
+ m <- sum(!is.na(x))
+ min(as.matrix(distfun(rbind(x[1:m], t(combn(y, m)))))[-1,1])
+ }
+ for(i in 1:N){
+ for(j in 1:i){
+ if(sum(!is.na(temp2[i,])) == sum(!is.na(temp2[j,]))){
+ m <- sum(!is.na(temp2[i,]))
+ d[i,j] <- as.vector(distfun(rbind(temp2[i,1:m], temp2[j,1:m])))
+ }
+ if(sum(!is.na(temp2[i,])) > sum(!is.na(temp2[j,])))
+ d[i,j] <- dfun1(temp2[j,], temp2[i,])
+ if(sum(!is.na(temp2[i,])) < sum(!is.na(temp2[j,])))
+ d[i,j] <- dfun1(temp2[i,], temp2[j,])
}
- if(sum(!is.na(temp2[i,])) > sum(!is.na(temp2[j,])))
- d[i,j] <- dfun(temp2[j,], temp2[i,])
- if(sum(!is.na(temp2[i,])) < sum(!is.na(temp2[j,])))
- d[i,j] <- dfun(temp2[i,], temp2[j,])
}
+ }else{
+ if(nrMissing == 0)
+ stop("'nrMissing' has to be at least 1")
+ ## consider bands >= LOD
+ x1 <- x[x$MW >= LOD,]
+ x2 <- split(x1, x1$Sample)
+ x2.bands <- sapply(x2, nrow)
+
+ ## remove samples with no band >= LOD
+ x3 <- split(x, x$Sample)
+ x4 <- x3[names(x3) %in% names(x2)]
+
+ ## consider only samples where number of bands with MW >= LOD
+ ## is equal to nrBands (missing bands only for MW < LOD)
+ x5 <- do.call("rbind", x4[x2.bands == nrBands])
+ x6 <- split(x5, x5$Sample)
+ x6.bands <- sapply(x6, nrow)
+
+ ## extract samples where up to nrMissing number of bands occur
+ ## for MW < LOD
+ temp <- do.call("rbind", x6[x6.bands %in% c(nrBands:(nrBands+nrMissing))])
+ temp1 <- split(temp[,"MW"], factor(temp[,"Sample"]))
+ N <- length(temp1)
+ temp2 <- matrix(NA, ncol = nrBands + nrMissing, nrow = N)
+ rownames(temp2) <- names(temp1)
+ for(i in 1:N){
+ temp2[i,1:length(temp1[[i]])] <- temp1[[i]]
+ }
+ dfun2 <- function(x, y, LOD){
+ y <- y[!is.na(y)]
+ m <- sum(!is.na(x))
+ m.lod <- sum(!is.na(x[x < LOD]))
+ y1 <- t(combn(y[y < LOD], m.lod))
+ y2 <- matrix(rep(y[y >= LOD], nrow(y1)), nrow = nrow(y1), byrow = TRUE)
+ y3 <- cbind(y2, y1)
+ min(as.matrix(distfun(rbind(x[1:m], y3)))[-1,1])
+ }
+ d <- matrix(NA, nrow = N, ncol = N)
+ for(i in 1:N){
+ for(j in 1:i){
+ if(sum(!is.na(temp2[i,])) == sum(!is.na(temp2[j,]))){
+ m <- sum(!is.na(temp2[i,]))
+ d[i,j] <- as.vector(distfun(rbind(temp2[i,1:m], temp2[j,1:m])))
+ }
+ if(sum(!is.na(temp2[i,])) > sum(!is.na(temp2[j,])))
+ d[i,j] <- dfun2(temp2[j,], temp2[i,], LOD = LOD)
+ if(sum(!is.na(temp2[i,])) < sum(!is.na(temp2[j,])))
+ d[i,j] <- dfun2(temp2[i,], temp2[j,], LOD = LOD)
+ }
+ }
}
d <- d[lower.tri(d)]
attr(d, "Size") <- N
Added: pkg/RFLPtools/R/RFLPlod.R
===================================================================
--- pkg/RFLPtools/R/RFLPlod.R (rev 0)
+++ pkg/RFLPtools/R/RFLPlod.R 2013-01-04 16:42:46 UTC (rev 14)
@@ -0,0 +1,13 @@
+###############################################################################
+## Remove bands below LOD
+###############################################################################
+
+RFLPlod <- function(x, LOD){
+ if(length(LOD) > 1){
+ warning("Only first element of 'LOD' is used.")
+ LOD <- LOD[1]
+ }
+
+ message(paste(sum(x$MW < LOD), "bands were removed."))
+ x[x$MW >= LOD, ]
+}
Modified: pkg/RFLPtools/R/RFLPplot.R
===================================================================
--- pkg/RFLPtools/R/RFLPplot.R 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/R/RFLPplot.R 2013-01-04 16:42:46 UTC (rev 14)
@@ -7,7 +7,8 @@
RFLPplot <- function(x, nrBands, nrMissing, distfun = dist,
hclust.method = "complete",
mar.bottom = 5, cex.axis = 0.5,
- colBands){
+ colBands, xlab = "", ylab = "molecular weight",
+ ylim, ...){
stopifnot(is.data.frame(x))
stopifnot(is.function(distfun))
@@ -32,20 +33,23 @@
temp <- x1[ind]
temp1 <- do.call("rbind", temp)
- par(mar = c(mar.bottom, 4, 4, 2) + 0.1)
- lo <- 10*trunc(min(temp1$MW)/10)
- up <- 10*ceiling(max(temp1$MW)/10)
- if(up-lo < 1) up <- up + 1
+ par(mar = c(mar.bottom, 4, 4, 2) + 0.1)
+ if(missing(ylim)){
+ lo <- 10*trunc(min(temp1$MW)/10)
+ up <- 10*ceiling(max(temp1$MW)/10)
+ if(up-lo < 1) up <- up + 1
+ ylim <- c(lo, up)
+ }
-
- plot(NA, NA, xlim = c(0.25,length(temp)+0.75), ylim = c(lo, up),
- xlab = "", ylab = "molecular weight", axes = FALSE)
- axis(1, at = 1:length(temp), labels = names(temp)[dend.ord], las = 2, cex.axis = cex.axis)
-
- At <- round(seq(lo, up, length = 11), 0)
+ plot(NA, NA, xlim = c(0.25,length(temp)+0.75), ylim = ylim,
+ xlab = xlab, ylab = ylab, axes = FALSE, ...)
+ At <- round(seq(ylim[1], ylim[2], length = 11), 0)
axis(2, at = At, labels = as.character(At), las = 2)
+ axis(1, at = 1:length(temp), labels = names(temp)[dend.ord], las = 2,
+ cex.axis = cex.axis)
abline(h = At, col = "grey", lty = 2)
box()
+
if(missing(nrMissing)){
title(paste("Samples with", nrBands, "bands"))
}else{
Modified: pkg/RFLPtools/R/RFLPqc.R
===================================================================
--- pkg/RFLPtools/R/RFLPqc.R 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/R/RFLPqc.R 2013-01-04 16:42:46 UTC (rev 14)
@@ -37,5 +37,5 @@
if(rm.band1 || QC.rm) rownames(x) <- 1:nrow(x)
- return(x)
+ x
}
Modified: pkg/RFLPtools/R/RFLPrefplot.R
===================================================================
--- pkg/RFLPtools/R/RFLPrefplot.R 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/R/RFLPrefplot.R 2013-01-04 16:42:46 UTC (rev 14)
@@ -6,7 +6,8 @@
## distfun: function to compute distance (cf. ?dist)
RFLPrefplot <- function(x, ref, distfun = dist, nrBands, mar.bottom = 5,
cex.main = 1.2, cex.axis = 0.5, devNew = FALSE,
- colBands){
+ colBands, xlab = "", ylab = "molecular weight",
+ ylim, ...){
res <- RFLPdist2ref(x, ref, distfun, nrBands)
x1 <- split(x, x$Sample)
@@ -20,10 +21,13 @@
ref.temp1 <- do.call("rbind", ref.temp)
par(mar = c(mar.bottom, 4, 4, 2) + 0.1)
- lo <- 10*trunc(min(temp1$MW, ref.temp1$MW)/10)
- up <- 10*ceiling(max(temp1$MW, ref.temp1$MW)/10)
- if(up-lo < 1) up <- up + 1
- At <- round(seq(lo, up, length = 11), 0)
+ if(missing(ylim)){
+ lo <- 10*trunc(min(temp1$MW, ref.temp1$MW)/10)
+ up <- 10*ceiling(max(temp1$MW, ref.temp1$MW)/10)
+ if(up-lo < 1) up <- up + 1
+ ylim <- c(lo, up)
+ }
+ At <- round(seq(ylim[1], ylim[2], length = 11), 0)
grp1 <- paste(ref.temp1[, "Taxonname"], " (", ref.temp1[, "Accession"], ")", sep = "")
if(devNew){
@@ -74,8 +78,8 @@
temp.mw <- temp.o[[i]]$MW
reps <- length(temp.mw)
matlines(rbind(rep(i+2-0.25, reps), rep(i+2+0.25, reps)),
- rbind(temp.mw, temp.mw),
- lwd = 3, lty = 1, col = mycol[i])
+ rbind(temp.mw, temp.mw),
+ lwd = 3, lty = 1, col = mycol[i])
}
}
invisible()
Modified: pkg/RFLPtools/inst/doc/RFLPtools.pdf
===================================================================
(Binary files differ)
Modified: pkg/RFLPtools/man/0RFLP-package.Rd
===================================================================
--- pkg/RFLPtools/man/0RFLP-package.Rd 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/man/0RFLP-package.Rd 2013-01-04 16:42:46 UTC (rev 14)
@@ -15,7 +15,7 @@
\tabular{ll}{
Package: \tab RFLPtools\cr
Version: \tab 1.5 \cr
-Date: \tab 2013-01-03 \cr
+Date: \tab 2013-01-04 \cr
Depends: \tab R(>= 2.10.0), stats, utils, grDevices, RColorBrewer\cr
Suggests: \tab lattice, MKmisc(>= 0.8)\cr
License: \tab LGPL-3\cr
Modified: pkg/RFLPtools/man/RFLPdist2.Rd
===================================================================
--- pkg/RFLPtools/man/RFLPdist2.Rd 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/man/RFLPdist2.Rd 2013-01-04 16:42:46 UTC (rev 14)
@@ -13,7 +13,7 @@
argument \code{nrMissing}.
}
\usage{
-RFLPdist2(x, distfun = dist, nrBands, nrMissing,
+RFLPdist2(x, distfun = dist, nrBands, nrMissing, LOD,
diag = FALSE, upper = FALSE)
}
\arguments{
@@ -22,6 +22,7 @@
cf. \code{\link[stats]{dist}}.}
\item{nrBands}{ samples with number of bands equal to \code{nrBands} are to be considered.}
\item{nrMissing}{ number of bands that might be missing.}
+ \item{LOD}{ threshold for low-bp bands. }
\item{diag}{ see \code{\link[stats]{dist}} }
\item{upper}{ see \code{\link[stats]{dist}} }
}
@@ -30,12 +31,20 @@
is computed. It is assumed that a number of bands might be missing. Hence
all samples with number of bands in nrBands, nrBands+1, ..., nrBands+nrMissing
are compared.
+
+ If \code{LOD} is specified, it is assumed that missing bands can only occur for
+ molecular weights smaller than \code{LOD}. As a consequence only samples which
+ have \code{nrBands} bands with molecular weight larger or equal to \code{LOD} are
+ selected.
For computing the distance between the molecular weight of a sample S1 with x bands
and a Sample S2 with x+y bands the distances between the molecular weight of sample S1
and the molecular weight of all possible subsets of S2 with x bands are computed.
The distance between S1 and S2 is then defined as the minimum of all these distances.
+ If \code{LOD} is specified, only all combinations of values below \code{LOD} are
+ considered.
+
This option may be useful, if gel image quality is low, and the detection of bands
is doubtful.
}
@@ -58,11 +67,14 @@
## Euclidean distance
data(RFLPdata)
nrBands(RFLPdata)
-res0 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 0)
-res1 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 1)
-res2 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 2)
-res3 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 3)
+res0 <- RFLPdist(RFLPdata, nrBands = 4)
+res1 <- RFLPdist2(RFLPdata, nrBands = 4, nrMissing = 1)
+res2 <- RFLPdist2(RFLPdata, nrBands = 4, nrMissing = 2)
+res3 <- RFLPdist2(RFLPdata, nrBands = 4, nrMissing = 3)
+## assume missing bands only below LOD
+res1.lod <- RFLPdist2(RFLPdata, nrBands = 4, nrMissing = 1, LOD = 60)
+
## hierarchical clustering
par(mfrow = c(2,2))
plot(hclust(res0), main = "0 bands missing")
@@ -70,6 +82,11 @@
plot(hclust(res2), main = "2 bands missing")
plot(hclust(res3), main = "3 bands missing")
+## missing bands only below LOD
+par(mfrow = c(1,2))
+plot(hclust(res0), main = "0 bands missing")
+plot(hclust(res1.lod), main = "1 band missing below LOD")
+
## Similarity matrix
library(MKmisc)
myCol <- colorRampPalette(brewer.pal(8, "RdYlGn"))(128)
@@ -78,7 +95,13 @@
simPlot(temp[ord,ord], col = rev(myCol), minVal = 0,
labels = colnames(temp), title = "(Dis-)Similarity Plot")
+## missing bands only below LOD
+ord <- order.dendrogram(as.dendrogram(hclust(res1.lod)))
+temp <- as.matrix(res1.lod)
+simPlot(temp[ord,ord], col = rev(myCol), minVal = 0,
+ labels = colnames(temp), title = "(Dis-)Similarity Plot\n1 band missing below LOD")
+
## or
library(lattice)
levelplot(temp[ord,ord], col.regions = rev(myCol),
@@ -91,11 +114,14 @@
## Other distances
res11 <- RFLPdist2(RFLPdata, distfun = function(x) dist(x, method = "manhattan"),
- nrBands = 9, nrMissing = 1)
-res12 <- RFLPdist2(RFLPdata, distfun = corDist, nrBands = 9, nrMissing = 1)
-res1
-res11
-res12
+ nrBands = 4, nrMissing = 1)
+res12 <- RFLPdist2(RFLPdata, distfun = corDist, nrBands = 4, nrMissing = 1)
+res13 <- RFLPdist2(RFLPdata, distfun = corDist, nrBands = 4, nrMissing = 1, LOD = 60)
+par(mfrow = c(2,2))
+plot(hclust(res1), main = "Euclidean distance\n1 band missing")
+plot(hclust(res11), main = "Manhattan distance\n1 band missing")
+plot(hclust(res12), main = "Pearson correlation distance\n1 band missing")
+plot(hclust(res13), main = "Pearson correlation distance\n1 band missing below LOD")
}
\keyword{multivariate}
\keyword{cluster}
Modified: pkg/RFLPtools/man/RFLPplot.Rd
===================================================================
--- pkg/RFLPtools/man/RFLPplot.Rd 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/man/RFLPplot.Rd 2013-01-04 16:42:46 UTC (rev 14)
@@ -10,7 +10,8 @@
\usage{
RFLPplot(x, nrBands, nrMissing, distfun = dist,
hclust.method = "complete", mar.bottom = 5,
- cex.axis = 0.5, colBands)
+ cex.axis = 0.5, colBands, xlab = "",
+ ylab = "molecular weight", ylim, \dots)
}
\arguments{
\item{x}{ data.frame with RFLP data; see \code{\link{RFLPdata}}.}
@@ -28,6 +29,12 @@
\item{colBands}{ color for the bands. Has to be of length 1 or number of samples.
If missing, \code{"Set1"} of \pkg{RColorBrewer} is used; see
\code{\link[RColorBrewer]{brewer.pal}}. }
+ \item{xlab}{ passed to function \code{\link[graphics]{plot}}. }
+ \item{ylab}{ passed to function \code{\link[graphics]{plot}}. }
+ \item{ylim}{ passed to function \code{\link[graphics]{plot}}. If missing an appropriate
+ range of y-values is computed. }
+ \item{\dots}{ additional arguments passed to function \code{\link[graphics]{plot}}
+ except \code{xlim} which is defined inside of \code{RFLPplot}. }
}
\details{
RFLP data is plotted. The samples are sorted according to the corresponding
Modified: pkg/RFLPtools/man/RFLPrefplot.Rd
===================================================================
--- pkg/RFLPtools/man/RFLPrefplot.Rd 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/man/RFLPrefplot.Rd 2013-01-04 16:42:46 UTC (rev 14)
@@ -10,7 +10,8 @@
\usage{
RFLPrefplot(x, ref, distfun = dist, nrBands, mar.bottom = 5,
cex.main = 1.2, cex.axis = 0.5, devNew = FALSE,
- colBands)
+ colBands, xlab = "", ylab = "molecular weight",
+ ylim, ...)
}
\arguments{
\item{x}{ data.frame with RFLP data; e.g. \code{\link{RFLPdata}}.}
@@ -26,6 +27,12 @@
\item{colBands}{ color for the bands. Has to be of length 1 or number of samples.
If missing, \code{"Set1"} of \pkg{RColorBrewer} is used; see
\code{\link[RColorBrewer]{brewer.pal}}. }
+ \item{xlab}{ passed to function \code{\link[graphics]{plot}}. }
+ \item{ylab}{ passed to function \code{\link[graphics]{plot}}. }
+ \item{ylim}{ passed to function \code{\link[graphics]{plot}}. If missing an appropriate
+ range of y-values is computed. }
+ \item{\dots}{ additional arguments passed to function \code{\link[graphics]{plot}}
+ except \code{xlim} which is defined inside of \code{RFLPplot}. }
}
\details{
Given RFLP samples are plotted together with reference samples and
@@ -45,8 +52,8 @@
data(RFLPref)
dev.new(width = 12)
RFLPrefplot(RFLPdata, RFLPref, nrBands = 4, cex.axis = 0.5)
-dev.off()
+dev.new()
RFLPrefplot(RFLPdata, RFLPref, nrBands = 6, cex.axis = 0.8)
RFLPrefplot(RFLPdata, RFLPref, nrBands = 9, cex.axis = 0.8)
@@ -59,8 +66,8 @@
dev.new(width = 12)
RFLPrefplot(RFLP1, RFLPref, nrBands = 4, cex.axis = 0.8)
-dev.off()
+dev.new()
RFLPrefplot(RFLP1, RFLPref, nrBands = 5, cex.axis = 0.8)
}
\keyword{multivariate}
Modified: pkg/RFLPtools/vignettes/RFLPtools.Rnw
===================================================================
--- pkg/RFLPtools/vignettes/RFLPtools.Rnw 2013-01-03 05:51:10 UTC (rev 13)
+++ pkg/RFLPtools/vignettes/RFLPtools.Rnw 2013-01-04 16:42:46 UTC (rev 14)
@@ -66,7 +66,28 @@
%-------------------------------------------------------------------------------
\section{RFLP data}
%-------------------------------------------------------------------------------
-We load example data and compute the Euclidean distance ...
+As a first step we can perform a QC of the samples using function \code{RFLPqc}.
+This is possible if the first band corresponds to the total length of the fragment.
+The QC consists of a comparison of the length of the first band with the sum of
+the lengths of the remaining bands for each sample. If the sum is smaller than
+\code{QC.lo} times the length of the first band or larger than \code{QC.up} times
+the length of the first band, respectively, a text message is printed.
+<<RFLPqc>>=
+Dir <- system.file("extdata", package = "RFLPtools") # input directory
+filename <- file.path(Dir, "AZ091016_report.txt")
+RFLP1 <- read.rflp(file = filename)
+str(RFLP1)
+
+RFLP2 <- RFLPqc(RFLP1, rm.band1 = FALSE) # identical to RFLP1
+identical(RFLP1, RFLP2)
+
+RFLP3 <- RFLPqc(RFLP1)
+str(RFLP3)
+
+RFLP4 <- RFLPqc(RFLP1, rm.band1 = TRUE, QC.rm = TRUE)
+str(RFLP4)
+@
+We load some example data and compute the Euclidean distance ...
<<eucl>>=
data(RFLPdata)
res <- RFLPdist(RFLPdata)
@@ -137,7 +158,7 @@
data(RFLPdata)
data(RFLPref)
nrBands(RFLPdata)
-res0 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 0)
+res0 <- RFLPdist(RFLPdata, nrBands = 9)
res1 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 1)
res2 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 2)
res3 <- RFLPdist2(RFLPdata, nrBands = 9, nrMissing = 3)
@@ -151,13 +172,31 @@
plot(hclust(res3), main = "3 bands missing")
@
\myinfig{1}{RFLPtools-sim4.pdf}
-In function \code{RFLPplot} we have also implemented another possibility for visualization.
-<<RFLPplot, fig = TRUE>>=
-par(mfrow = c(1,2))
-plot(hclust(RFLPdist(RFLPdata, nrBands = 3)), cex = 0.7)
-RFLPplot(RFLPdata, nrBands = 3, mar.bottom = 6, cex.axis = 0.8)
+There are also ways to handle low-bp bands which are likely to be absent in some
+of the samples. First, one can use function \code{RFLPlod} to remove all bands
+below a given threshold \code{LOD} before further analyses. For displaying the
+data we use function \code{RFLPplot}.
+<<RFLPlod, fig = TRUE>>=
+RFLPdata.lod <- RFLPlod(RFLPdata, LOD = 60)
+par(mfrow = c(1, 2))
+RFLPplot(RFLPdata, nrBands = 4, ylim = c(40, 670))
+RFLPplot(RFLPdata.lod, nrBands = 4, ylim = c(40, 670))
+title(sub = "After applying RFLPlod")
@
-\myinfig{1}{RFLPtools-RFLPplot.pdf}
+\myinfig{1}{RFLPtools-RFLPlod.pdf}
+In addition, one can specify \code{LOD} in a call to function \code{RFLPdist2}.
+If \code{LOD} is specified, it is assumed that missing bands only occur for
+molecular weights smaller than \code{LOD}.
+<<sim5, fig = TRUE>>=
+res0 <- RFLPdist(RFLPdata, nrBands = 4)
+res1.lod <- RFLPdist2(RFLPdata, nrBands = 4, nrMissing = 1, LOD = 60)
+ord <- order.dendrogram(as.dendrogram(hclust(res1.lod)))
+temp <- as.matrix(res1.lod)
+simPlot(temp[ord,ord], col = rev(myCol), minVal = 0,
+ labels = colnames(temp),
+ title = "(Dis-)Similarity Plot\n1 band missing below LOD")
+@
+\myinfig{1}{RFLPtools-sim5.pdf}
We can also make a comparison to reference data.
<<RFLPrefplot, fig = TRUE>>=
RFLPrefplot(RFLPdata, RFLPref, nrBands = 9, cex.axis = 0.8)
More information about the Rflptools-commits
mailing list