From noreply at r-forge.r-project.org Tue Apr 2 15:38:46 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Apr 2013 15:38:46 +0200 (CEST) Subject: [adegenet-commits] r1102 - www Message-ID: <20130402133846.2AC46183CD1@r-forge.r-project.org> Author: jombart Date: 2013-04-02 15:38:45 +0200 (Tue, 02 Apr 2013) New Revision: 1102 Modified: www/literature.html Log: +10 ref Modified: www/literature.html =================================================================== --- www/literature.html 2013-03-21 17:36:25 UTC (rev 1101) +++ www/literature.html 2013-04-02 13:38:45 UTC (rev 1102) @@ -59,6 +59,7 @@ + the bublisher's website]

@@ -87,6 +88,7 @@ + abstract]

- the paper presenting the spatial @@ -100,6 +102,7 @@ + principal component analysis (sPCA, function spca), global and @@ -116,6 +119,7 @@ + cryptic spatial patterns in genetic variability by a new multivariate method.  Heredity 101: 92-103. doi: @@ -133,6 +137,7 @@ + abstract]

@@ -152,6 +157,7 @@ + simulations of genealoies of haplotypes (haploGen):
Jombart T, Eggo RM, Dodd PJ, Balloux F (2010) @@ -171,6 +177,7 @@ + of Principal Components (DAPC, functions find.clusters @@ -198,6 +205,7 @@ + Behaviour76: 87-95.

@@ -214,6 +222,7 @@ + Genomics
9: 256.
@@ -245,6 +254,7 @@ + marmota.Molecular @@ -255,6 +265,7 @@ + Ecology 18: 1491-1503.

@@ -304,6 +315,7 @@ + australis in North America. Biological Invasions. doi: 10.1007/s10530-010-9699-6.
@@ -457,6 +469,7 @@ + Oct 6. [Epub ahead of print]

[24] SANTOS, H., BURBAN, C., ROUSSELET, J., @@ -471,6 +484,7 @@ + pityocampa, Lepidoptera, Notodontidae). Journal of Evolutionary Biology, no. doi: 10.1111/j.1420-9101.2010.02147.x
@@ -490,6 +504,7 @@ + Vol. Sci. Pap. ICCAT, 65(3): 988-995

[26] Vandewoestijne @@ -502,6 +517,7 @@ + S, Van Dyck H, 2010 Population Genetic @@ -517,6 +533,7 @@ + ONE5(11): e13810. doi:10.1371/journal.pone.0013810
@@ -543,6 +560,7 @@ +
DOI: 10.1007/s10329-010-0232-4

@@ -606,6 +624,7 @@ + tetradactylum: Polynemidae). Molecular Ecology, 20: no. doi: 10.1111/j.1365-294X.2011.05097.x

@@ -627,6 +646,7 @@ + neoformans Variety grubii Multilocus Sequence Types from Thailand Are Consistent with an Ancestral African Origin. PLoS @@ -880,6 +900,7 @@ + 10.1007/s10709-012-9640-2

[76] Samantha Baldwin, Meeghan Pither-Joyce, Kathryn Wright, @@ -1408,8 +1429,80 @@ (Dermochelys coriacea) Turtle Population. PLoS ONE 8(3): e58061. doi:10.1371/journal.pone.0058061

+ [165] Virgilio, M., Delatte, H., Quilici, S., Backeljau, T. and + De Meyer, M. (2013), Cryptic diversity and gene flow among three + African agricultural pests: Ceratitis rosa, Ceratitis + fasciventris and Ceratitis anonae (Diptera, Tephritidae). + Molecular Ecology. doi: 10.1111/mec.12278

+ [166] Mallez S, Castagnone C, Espada M, Vieira P, Eisenback JD, + et al. (2013) First Insights into the Genetic Diversity of the + Pinewood Nematode in Its Native Area Using New Polymorphic + Microsatellite Loci. PLoS ONE 8(3): e59165. + doi:10.1371/journal.pone.0059165

+ [167] Koji Yahara et al. (2013) Chromosome painting in silico in + a bacterial species reveals fine population structure. Mol Biol + Evol. doi: 10.1093/molbev/mst055
+
+ [168] Stockin, K. A., Amaral, A. R., Latimer, J., Lambert, D. M. + and Natoli, A. (2013), Population genetic structure and taxonomy + of the common dolphin (Delphinus sp.) at its southernmost range + limit: New Zealand waters. Marine Mammal Science. doi: + 10.1111/mms.12027
+
+ [169] Alexandra Pavlova et al. (2013) PERCHED AT THE + MITO-NUCLEAR CROSSROADS: DIVERGENT MITOCHONDRIAL LINEAGES + CORRELATE WITH ENVIRONMENT IN THE FACE OF ONGOING NUCLEAR GENE + FLOW IN AN AUSTRALIAN BIRD. Evolution. DOI: 10.1111/evo.12107
+
+ [170] Fontaine, M. C., Austerlitz, F., Giraud, T., Labb?, F., + Papura, D., Richard-Cervera, S. and Delmotte, F. (2013), Genetic + signature of a range expansion and leap-frog event after the + recent invasion of Europe by the grapevine downy mildew pathogen + Plasmopara viticola. Molecular Ecology. doi: 10.1111/mec.12293
+
+ [171] C Roullier et al. (2013) On the origin of sweet potato + (Ipomoea batatas (L.) Lam.) genetic diversity in New Guinea, a + secondary centre of diversity. Heredity. doi: + 10.1038/hdy.2013.14
+
+ [172] Laura I. Ferreyra et al. (2013) Genetic and morphometric + markers are able to differentiate three morphotypes belonging to + Section Algarobia of genus Prosopis (Leguminosae, Mimosoideae). + Plant Systematics and Evolution. Doi: 10.1007/s00606-013-0786-x
+
+ [173] Therkildsen, N. O., Hemmer-Hansen, J., Als, T. D., Swain, + D. P., Morgan, M. J., Trippel, E. A., Palumbi, S. R., Meldrup, + D. and Nielsen, E. E. (2013), Microevolution in time and space: + SNP analysis of historical DNA reveals dynamic signatures of + selection in Atlantic cod. Molecular Ecology. doi: + 10.1111/mec.12260
+
+ [174] Torres, J. B., Stone, A. C. and Kittles, R. (2013), An + anthropological genetic perspective on creolization in the + anglophone caribbean. Am. J. Phys. Anthropol.. doi: + 10.1002/ajpa.22261
+
+ [175] Vinceti B, Loo J, Gaisberger H, van Zonneveld MJ, Schueler + S, et al. (2013) Conservation Priorities for Prunus africana + Defined with the Aid of Spatial Analysis of Genetic Data and + Climatic Variables. PLoS ONE 8(3): e59987. + doi:10.1371/journal.pone.0059987
+
+ [176] H?glund, J., Cortazar-Chinarro, M., Jarnemo, A. and + Thulin, C.-G. (2013), Genetic variation and structure in + Scandinavian red deer (Cervus elaphus): influence of ancestry, + past hunting, and restoration management. Biological Journal of + the Linnean Society. doi: 10.1111/bij.12049
+
+ [177] C Hvilsom et al. (2013) Understanding geographic origins + and history of admixture among chimpanzees in European zoos, + with implications for future breeding programmes. Heredity. doi: + 10.1038/hdy.2013.9
+
+
+

* adegenet not or wrongly cited, but actually used in the paper.
From noreply at r-forge.r-project.org Fri Apr 5 12:25:24 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Apr 2013 12:25:24 +0200 (CEST) Subject: [adegenet-commits] r1103 - pkg/R Message-ID: <20130405102524.C47BB183A2B@r-forge.r-project.org> Author: jombart Date: 2013-04-05 12:25:24 +0200 (Fri, 05 Apr 2013) New Revision: 1103 Added: pkg/R/dapcXval.R Modified: pkg/R/import.R Log: added file for DAPC X validation Added: pkg/R/dapcXval.R =================================================================== --- pkg/R/dapcXval.R (rev 0) +++ pkg/R/dapcXval.R 2013-04-05 10:25:24 UTC (rev 1103) @@ -0,0 +1,1027 @@ +####### +## dapc +######## +dapc <- function (x, ...) UseMethod("dapc") + +################### +## dapc.data.frame +################### +dapc.data.frame <- function(x, grp, n.pca=NULL, n.da=NULL, + center=TRUE, scale=FALSE, var.contrib=TRUE, pca.info=TRUE, + pca.select=c("nbEig","percVar"), perc.pca=NULL, ..., dudi=NULL){ + + ## FIRST CHECKS + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") + grp <- as.factor(grp) + if(length(grp) != nrow(x)) stop("Inconsistent length for grp") + pca.select <- match.arg(pca.select) + if(!is.null(perc.pca) & is.null(n.pca)) pca.select <- "percVar" + if(is.null(perc.pca) & !is.null(n.pca)) pca.select <- "nbEig" + if(!is.null(dudi) && !inherits(dudi, "dudi")) stop("dudi provided, but not of class 'dudi'") + + + ## SOME GENERAL VARIABLES + N <- nrow(x) + REDUCEDIM <- is.null(dudi) + + if(REDUCEDIM){ # if no dudi provided + ## PERFORM PCA ## + maxRank <- min(dim(x)) + pcaX <- dudi.pca(x, center = center, scale = scale, scannf = FALSE, nf=maxRank) + } else { # else use the provided dudi + pcaX <- dudi + } + cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig) + + if(!REDUCEDIM){ + myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$li),length(pcaX$eig))) + } else { + myCol <- "black" + } + + ## select the number of retained PC for PCA + if(is.null(n.pca) & pca.select=="nbEig"){ + plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) + cat("Choose the number PCs to retain (>=1): ") + n.pca <- as.integer(readLines(n = 1)) + } + + if(is.null(perc.pca) & pca.select=="percVar"){ + plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) + cat("Choose the percentage of variance to retain (0-100): ") + nperc.pca <- as.numeric(readLines(n = 1)) + } + + ## get n.pca from the % of variance to conserve + if(!is.null(perc.pca)){ + n.pca <- min(which(cumVar >= perc.pca)) + if(perc.pca > 99.999) n.pca <- length(pcaX$eig) + if(n.pca<1) n.pca <- 1 + } + + + ## keep relevant PCs - stored in XU + X.rank <- sum(pcaX$eig > 1e-14) + n.pca <- min(X.rank, n.pca) + if(n.pca >= N) stop("number of retained PCs of PCA is greater than N") + if(n.pca > N/3) warning("number of retained PCs of PCA may be too large (> N /3)\n results may be unstable ") + n.pca <- round(n.pca) + + U <- pcaX$c1[, 1:n.pca, drop=FALSE] # principal axes + rownames(U) <- colnames(x) # force to restore names + XU <- pcaX$li[, 1:n.pca, drop=FALSE] # principal components + XU.lambda <- sum(pcaX$eig[1:n.pca])/sum(pcaX$eig) # sum of retained eigenvalues + names(U) <- paste("PCA-pa", 1:ncol(U), sep=".") + names(XU) <- paste("PCA-pc", 1:ncol(XU), sep=".") + + + ## PERFORM DA ## + ldaX <- lda(XU, grp, tol=1e-30) # tol=1e-30 is a kludge, but a safe (?) one to avoid fancy rescaling by lda.default + lda.dim <- sum(ldaX$svd^2 > 1e-10) + ldaX$svd <- ldaX$svd[1:lda.dim] + ldaX$scaling <- ldaX$scaling[,1:lda.dim,drop=FALSE] + + if(is.null(n.da)){ + barplot(ldaX$svd^2, xlab="Linear Discriminants", ylab="F-statistic", main="Discriminant analysis eigenvalues", col=heat.colors(length(levels(grp))) ) + cat("Choose the number discriminant functions to retain (>=1): ") + n.da <- as.integer(readLines(n = 1)) + } + + n.da <- min(n.da, length(levels(grp))-1, n.pca) # can't be more than K-1 disc. func., or more than n.pca + n.da <- round(n.da) + predX <- predict(ldaX, dimen=n.da) + + + ## BUILD RESULT + res <- list() + res$n.pca <- n.pca + res$n.da <- n.da + res$tab <- XU + res$grp <- grp + res$var <- XU.lambda + res$eig <- ldaX$svd^2 + res$loadings <- ldaX$scaling[, 1:n.da, drop=FALSE] + res$means <- ldaX$means + res$ind.coord <-predX$x + res$grp.coord <- apply(res$ind.coord, 2, tapply, grp, mean) + res$prior <- ldaX$prior + res$posterior <- predX$posterior + res$assign <- predX$class + res$call <- match.call() + + + ## optional: store loadings of variables + if(pca.info){ + res$pca.loadings <- as.matrix(U) + res$pca.cent <- pcaX$cent + res$pca.norm <- pcaX$norm + res$pca.eig <- pcaX$eig + } + + ## optional: get loadings of variables + if(var.contrib){ + res$var.contr <- as.matrix(U) %*% as.matrix(ldaX$scaling[,1:n.da,drop=FALSE]) + f1 <- function(x){ + temp <- sum(x*x) + if(temp < 1e-12) return(rep(0, length(x))) + return(x*x / temp) + } + res$var.contr <- apply(res$var.contr, 2, f1) + } + + class(res) <- "dapc" + return(res) +} # end dapc.data.frame + + + + + +############# +## dapc.matrix +############# +dapc.matrix <- function(x, ...){ + return(dapc(as.data.frame(x), ...)) +} + + + + +############# +## dapc.genind +############# +dapc.genind <- function(x, pop=NULL, n.pca=NULL, n.da=NULL, + scale=FALSE, scale.method=c("sigma", "binom"), truenames=TRUE, var.contrib=TRUE, pca.info=TRUE, + pca.select=c("nbEig","percVar"), perc.pca=NULL, ...){ + + ## FIRST CHECKS + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") + + if(!is.genind(x)) stop("x must be a genind object.") + + if(is.null(pop)) { + pop.fac <- pop(x) + } else { + pop.fac <- pop + } + + if(is.null(pop.fac)) stop("x does not include pre-defined populations, and `pop' is not provided") + + + ## SOME GENERAL VARIABLES + N <- nrow(x at tab) + + ## PERFORM PCA ## + maxRank <- min(dim(x at tab)) + + X <- scaleGen(x, center = TRUE, scale = scale, method = scale.method, + missing = "mean", truenames = truenames) + + ## CALL DATA.FRAME METHOD ## + res <- dapc(X, grp=pop.fac, n.pca=n.pca, n.da=n.da, + center=FALSE, scale=FALSE, var.contrib=var.contrib, + pca.select=pca.select, perc.pca=perc.pca) + + res$call <- match.call() + + ## restore centring/scaling + res$pca.cent <- attr(X, "scaled:center") + + if(scale) { + res$pca.norm <- attr(X, "scaled:scale") + } + + return(res) +} # end dapc.genind + + + + + + +###################### +## Function dapc.dudi +###################### +dapc.dudi <- function(x, grp, ...){ + return(dapc.data.frame(x$li, grp, dudi=x, ...)) +} + + + + + +################# +## dapc.genlight +################# +dapc.genlight <- function(x, pop=NULL, n.pca=NULL, n.da=NULL, + scale=FALSE, var.contrib=TRUE, pca.info=TRUE, + pca.select=c("nbEig","percVar"), perc.pca=NULL, glPca=NULL, ...){ + ## FIRST CHECKS ## + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") + if(!inherits(x, "genlight")) stop("x must be a genlight object.") + + pca.select <- match.arg(pca.select) + + if(is.null(pop)) { + pop.fac <- pop(x) + } else { + pop.fac <- pop + } + + if(is.null(pop.fac)) stop("x does not include pre-defined populations, and `pop' is not provided") + + + + ## PERFORM PCA ## + REDUCEDIM <- is.null(glPca) + + if(REDUCEDIM){ # if no glPca provided + maxRank <- min(c(nInd(x), nLoc(x))) + pcaX <- glPca(x, center = TRUE, scale = scale, nf=maxRank, loadings=FALSE, returnDotProd = TRUE, ...) + } + + if(!REDUCEDIM){ # else use the provided glPca object + if(is.null(glPca$loadings) & var.contrib) { + warning("Contribution of variables requested but glPca object provided without loadings.") + var.contrib <- FALSE + } + pcaX <- glPca + } + + if(is.null(n.pca)){ + cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig) + } + + + ## select the number of retained PC for PCA + if(!REDUCEDIM){ + myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$scores),length(pcaX$eig))) + } else { + myCol <- "black" + } + + if(is.null(n.pca) & pca.select=="nbEig"){ + plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) + cat("Choose the number PCs to retain (>=1): ") + n.pca <- as.integer(readLines(n = 1)) + } + + if(is.null(perc.pca) & pca.select=="percVar"){ + plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) + cat("Choose the percentage of variance to retain (0-100): ") + nperc.pca <- as.numeric(readLines(n = 1)) + } + + ## get n.pca from the % of variance to conserve + if(!is.null(perc.pca)){ + n.pca <- min(which(cumVar >= perc.pca)) + if(perc.pca > 99.999) n.pca <- length(pcaX$eig) + if(n.pca<1) n.pca <- 1 + } + + if(!REDUCEDIM){ + if(n.pca > ncol(pcaX$scores)) { + n.pca <- ncol(pcaX$scores) + } + } + + + ## recompute PCA with loadings if needed + if(REDUCEDIM){ + pcaX <- glPca(x, center = TRUE, scale = scale, nf=n.pca, loadings=var.contrib, matDotProd = pcaX$dotProd) + } + + + ## keep relevant PCs - stored in XU + N <- nInd(x) + X.rank <- sum(pcaX$eig > 1e-14) + n.pca <- min(X.rank, n.pca) + if(n.pca >= N) stop("number of retained PCs of PCA is greater than N") + if(n.pca > N/3) warning("number of retained PCs of PCA may be too large (> N /3)\n results may be unstable ") + + U <- pcaX$loadings[, 1:n.pca, drop=FALSE] # principal axes + XU <- pcaX$scores[, 1:n.pca, drop=FALSE] # principal components + XU.lambda <- sum(pcaX$eig[1:n.pca])/sum(pcaX$eig) # sum of retained eigenvalues + names(U) <- paste("PCA-pa", 1:ncol(U), sep=".") + names(XU) <- paste("PCA-pc", 1:ncol(XU), sep=".") + + + ## PERFORM DA ## + ldaX <- lda(XU, pop.fac, tol=1e-30) # tol=1e-30 is a kludge, but a safe (?) one to avoid fancy rescaling by lda.default + lda.dim <- sum(ldaX$svd^2 > 1e-10) + ldaX$svd <- ldaX$svd[1:lda.dim] + ldaX$scaling <- ldaX$scaling[,1:lda.dim,drop=FALSE] + + if(is.null(n.da)){ + barplot(ldaX$svd^2, xlab="Linear Discriminants", ylab="F-statistic", main="Discriminant analysis eigenvalues", col=heat.colors(length(levels(pop.fac))) ) + cat("Choose the number discriminant functions to retain (>=1): ") + n.da <- as.integer(readLines(n = 1)) + } + + n.da <- min(n.da, length(levels(pop.fac))-1, n.pca, sum(ldaX$svd>1e-10)) # can't be more than K-1 disc. func., or more than n.pca + n.da <- round(n.da) + predX <- predict(ldaX, dimen=n.da) + + + ## BUILD RESULT + res <- list() + res$n.pca <- n.pca + res$n.da <- n.da + res$tab <- XU + res$grp <- pop.fac + res$var <- XU.lambda + res$eig <- ldaX$svd^2 + res$loadings <- ldaX$scaling[, 1:n.da, drop=FALSE] + res$means <- ldaX$means + res$ind.coord <-predX$x + res$grp.coord <- apply(res$ind.coord, 2, tapply, pop.fac, mean) + res$prior <- ldaX$prior + res$posterior <- predX$posterior + res$assign <- predX$class + res$call <- match.call() + + + ## optional: store loadings of variables + if(pca.info){ + res$pca.loadings <- as.matrix(U) + res$pca.cent <- glMean(x,alleleAsUnit=FALSE) + if(scale) { + res$pca.norm <- sqrt(glVar(x,alleleAsUnit=FALSE)) + } else { + res$pca.norm <- rep(1, nLoc(x)) + } + res$pca.eig <- pcaX$eig + } + + ## optional: get loadings of variables + if(var.contrib){ + res$var.contr <- as.matrix(U) %*% as.matrix(ldaX$scaling[,1:n.da,drop=FALSE]) + f1 <- function(x){ + temp <- sum(x*x) + if(temp < 1e-12) return(rep(0, length(x))) + return(x*x / temp) + } + res$var.contr <- apply(res$var.contr, 2, f1) + } + + class(res) <- "dapc" + return(res) +} # end dapc.genlight + + + + + + +###################### +# Function print.dapc +###################### +print.dapc <- function(x, ...){ + cat("\t#################################################\n") + cat("\t# Discriminant Analysis of Principal Components #\n") + cat("\t#################################################\n") + cat("class: ") + cat(class(x)) + cat("\n$call: ") + print(x$call) + cat("\n$n.pca:", x$n.pca, "first PCs of PCA used") + cat("\n$n.da:", x$n.da, "discriminant functions saved") + cat("\n$var (proportion of conserved variance):", round(x$var,3)) + cat("\n\n$eig (eigenvalues): ") + l0 <- sum(x$eig >= 0) + cat(signif(x$eig, 4)[1:(min(5, l0))]) + if (l0 > 5) + cat(" ...\n\n") + + ## vectors + TABDIM <- 4 + if(!is.null(x$pca.loadings)){ + TABDIM <- TABDIM + 3 + } + sumry <- array("", c(TABDIM, 3), list(1:TABDIM, c("vector", "length", "content"))) + sumry[1, ] <- c('$eig', length(x$eig), 'eigenvalues') + sumry[2, ] <- c('$grp', length(x$grp), 'prior group assignment') + sumry[3, ] <- c('$prior', length(x$prior), 'prior group probabilities') + sumry[4, ] <- c('$assign', length(x$assign), 'posterior group assignment') + if(!is.null(x$pca.loadings)){ + sumry[5, ] <- c('$pca.cent', length(x$pca.cent), 'centring vector of PCA') + sumry[6, ] <- c('$pca.norm', length(x$pca.norm), 'scaling vector of PCA') + sumry[7, ] <- c('$pca.eig', length(x$pca.eig), 'eigenvalues of PCA') + } + class(sumry) <- "table" + print(sumry) + + ## data.frames + cat("\n") + TABDIM <- 6 + if(!is.null(x$pca.loadings)){ + TABDIM <- TABDIM + 1 + } + if(!is.null(x$var.contr)){ + TABDIM <- TABDIM + 1 + } + + sumry <- array("", c(TABDIM, 4), list(1:TABDIM, c("data.frame", "nrow", "ncol", "content"))) + + sumry[1, ] <- c("$tab", nrow(x$tab), ncol(x$tab), "retained PCs of PCA") + sumry[2, ] <- c("$means", nrow(x$means), ncol(x$means), "group means") + sumry[3, ] <- c("$loadings", nrow(x$loadings), ncol(x$loadings), "loadings of variables") + sumry[4, ] <- c("$ind.coord", nrow(x$ind.coord), ncol(x$ind.coord), "coordinates of individuals (principal components)") + sumry[5, ] <- c("$grp.coord", nrow(x$grp.coord), ncol(x$grp.coord), "coordinates of groups") + sumry[6, ] <- c("$posterior", nrow(x$posterior), ncol(x$posterior), "posterior membership probabilities") + if(!is.null(x$pca.loadings)){ + sumry[7, ] <- c("$pca.loadings", nrow(x$pca.loadings), ncol(x$pca.loadings), "PCA loadings of original variables") + } + if(!is.null(x$var.contr)){ + sumry[TABDIM, ] <- c("$var.contr", nrow(x$var.contr), ncol(x$var.contr), "contribution of original variables") + } + class(sumry) <- "table" + print(sumry) + + ## cat("\nother elements: ") + ## if (length(names(x)) > 15) + ## cat(names(x)[15:(length(names(x)))], "\n") + ## else cat("NULL\n") + cat("\n") +} # end print.dapc + + + + + + +############## +## summary.dapc +############## +summary.dapc <- function(object, ...){ + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + + x <- object + res <- list() + + ## number of dimensions + res$n.dim <- ncol(x$loadings) + res$n.pop <- length(levels(x$grp)) + + ## assignment success + temp <- as.character(x$grp)==as.character(x$assign) + res$assign.prop <- mean(temp) + res$assign.per.pop <- tapply(temp, x$grp, mean) + + ## group sizes + res$prior.grp.size <- table(x$grp) + res$post.grp.size <- table(x$assign) + + return(res) +} # end summary.dapc + + + + + + +############## +## scatter.dapc +############## +scatter.dapc <- function(x, xax=1, yax=2, grp=x$grp, col=rainbow(length(levels(grp))), pch=20, bg="lightgrey", solid=.7, + scree.da=TRUE, scree.pca=FALSE, posi.da="bottomright", posi.pca="bottomleft", bg.inset="white", + ratio.da=.25, ratio.pca=.25, inset.da=0.02, inset.pca=0.02, inset.solid=.5, + onedim.filled=TRUE, mstree=FALSE, lwd=1, lty=1, segcol="black", + legend=FALSE, posi.leg="topright", cleg=1, txt.leg=levels(grp), + cstar = 1, cellipse = 1.5, axesell = FALSE, label = levels(grp), clabel = 1, xlim = NULL, ylim = NULL, + grid = FALSE, addaxes = TRUE, origin = c(0,0), include.origin = TRUE, sub = "", csub = 1, possub = "bottomleft", + cgrid = 1, pixmap = NULL, contour = NULL, area = NULL, ...){ + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + ONEDIM <- xax==yax | ncol(x$ind.coord)==1 + + ## recycle color and pch + col <- rep(col, length(levels(grp))) + pch <- rep(pch, length(levels(grp))) + col <- transp(col, solid) + bg.inset <- transp(bg.inset, inset.solid) + + ## handle grp + if(is.null(grp)){ + grp <- x$grp + } + + if(!ONEDIM){ + ## set par + opar <- par(mar = par("mar")) + par(mar = c(0.1, 0.1, 0.1, 0.1), bg=bg) + on.exit(par(opar)) + axes <- c(xax,yax) + ## basic empty plot + ## s.label(x$ind.coord[,axes], clab=0, cpoint=0, grid=FALSE, addaxes = FALSE, cgrid = 1, include.origin = FALSE, ...) + s.class(x$ind.coord[,axes], fac=grp, col=col, cpoint=0, cstar = cstar, cellipse = cellipse, axesell = axesell, label = label, + clabel = clabel, xlim = xlim, ylim = ylim, grid = grid, addaxes = addaxes, origin = origin, include.origin = include.origin, + sub = sub, csub = csub, possub = possub, cgrid = cgrid, pixmap = pixmap, contour = contour, area = area) + + ## add points + colfac <- pchfac <- grp + levels(colfac) <- col + levels(pchfac) <- pch + colfac <- as.character(colfac) + pchfac <- as.character(pchfac) + if(is.numeric(col)) colfac <- as.numeric(colfac) + if(is.numeric(pch)) pchfac <- as.numeric(pchfac) + + points(x$ind.coord[,xax], x$ind.coord[,yax], col=colfac, pch=pchfac, ...) + s.class(x$ind.coord[,axes], fac=grp, col=col, cpoint=0, add.plot=TRUE, cstar = cstar, cellipse = cellipse, axesell = axesell, label = label, + clabel = clabel, xlim = xlim, ylim = ylim, grid = grid, addaxes = addaxes, origin = origin, include.origin = include.origin, + sub = sub, csub = csub, possub = possub, cgrid = cgrid, pixmap = pixmap, contour = contour, area = area) + + ## add minimum spanning tree if needed + if(mstree && require(ade4)){ + meanposi <- apply(x$tab,2, tapply, grp, mean) + D <- dist(meanposi)^2 + tre <- ade4::mstree(D) + x0 <- x$grp.coord[tre[,1], axes[1]] + y0 <- x$grp.coord[tre[,1], axes[2]] + x1 <- x$grp.coord[tre[,2], axes[1]] + y1 <- x$grp.coord[tre[,2], axes[2]] + segments(x0, y0, x1, y1, lwd=lwd, lty=lty, col=segcol) + } + + } else { + + ## get plotted axis + if(ncol(x$ind.coord)==1) { + pcLab <- 1 + } else{ + pcLab <- xax + } + ## get densities + ldens <- tapply(x$ind.coord[,pcLab], grp, density) + allx <- unlist(lapply(ldens, function(e) e$x)) + ally <- unlist(lapply(ldens, function(e) e$y)) + par(bg=bg) + plot(allx, ally, type="n", xlab=paste("Discriminant function", pcLab), ylab="Density") + for(i in 1:length(ldens)){ + if(!onedim.filled) { + lines(ldens[[i]]$x,ldens[[i]]$y, col=col[i], lwd=2) # add lines + } else { + polygon(c(ldens[[i]]$x,rev(ldens[[i]]$x)),c(ldens[[i]]$y,rep(0,length(ldens[[i]]$x))), col=col[i], lwd=2, border=col[i]) # add lines + } + points(x=x$ind.coord[grp==levels(grp)[i],pcLab], y=rep(0, sum(grp==levels(grp)[i])), pch="|", col=col[i]) # add points for indiv + } + } + + ## ADD INSETS ## + ## group legend + if(legend){ + ## add a legend + temp <- list(...)$cex + if(is.null(temp)) temp <- 1 + if(ONEDIM | temp<0.5 | all(pch=="")) { + legend(posi.leg, fill=col, legend=txt.leg, cex=cleg, bg=bg.inset) + } else { + legend(posi.leg, col=col, legend=txt.leg, cex=cleg, bg=bg.inset, pch=pch, pt.cex=temp) + } + } + + ## eigenvalues discriminant analysis + if(scree.da && ratio.da>.01) { + inset <- function(){ + myCol <- rep("white", length(x$eig)) + myCol[1:x$n.da] <- "grey" + myCol[c(xax, yax)] <- "black" + myCol <- transp(myCol, inset.solid) + barplot(x$eig, col=myCol, xaxt="n", yaxt="n", ylim=c(0, x$eig[1]*1.1)) + mtext(side=3, "DA eigenvalues", line=-1.2, adj=.8) + box() + } + + add.scatter(inset(), posi=posi.da, ratio=ratio.da, bg.col=bg.inset, inset=inset.da) + ##add.scatter.eig(x$eig, ncol(x$loadings), axes[1], axes[2], posi=posi, ratio=ratio, csub=csub) # does not allow for bg + } + + ## eigenvalues PCA + if(scree.pca && !is.null(x$pca.eig) && ratio.pca>.01) { + inset <- function(){ + temp <- 100* cumsum(x$pca.eig) / sum(x$pca.eig) + myCol <- rep(c("black","grey"), c(x$n.pca, length(x$pca.eig))) + myCol <- transp(myCol, inset.solid) + plot(temp, col=myCol, ylim=c(0,115), + type="h", xaxt="n", yaxt="n", xlab="", ylab="", lwd=2) + mtext(side=3, "PCA eigenvalues", line=-1.2, adj=.1) + } + add.scatter(inset(), posi=posi.pca, ratio=ratio.pca, bg.col=bg.inset, inset=inset.pca) + } + + + return(invisible(match.call())) +} # end scatter.dapc + + + + + + +############ +## assignplot +############ +assignplot <- function(x, only.grp=NULL, subset=NULL, new.pred=NULL, cex.lab=.75, pch=3){ + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + if(!inherits(x, "dapc")) stop("x is not a dapc object") + + ## handle data from predict.dapc ## + if(!is.null(new.pred)){ + n.new <- length(new.pred$assign) + x$grp <- c(as.character(x$grp), rep("unknown", n.new)) + x$assign <- c(as.character(x$assign), as.character(new.pred$assign)) + x$posterior <- rbind(x$posterior, new.pred$posterior) + } + + + ## treat other arguments ## + if(!is.null(only.grp)){ + only.grp <- as.character(only.grp) + ori.grp <- as.character(x$grp) + x$grp <- x$grp[only.grp==ori.grp] + x$assign <- x$assign[only.grp==ori.grp] + x$posterior <- x$posterior[only.grp==ori.grp, , drop=FALSE] + } else if(!is.null(subset)){ + x$grp <- x$grp[subset] + x$assign <- x$assign[subset] + x$posterior <- x$posterior[subset, , drop=FALSE] + } + + + ##table.paint(x$posterior, col.lab=ori.grp, ...) + ## symbols(x$posterior) + + + ## FIND PLOT PARAMETERS + n.grp <- ncol(x$posterior) + n.ind <- nrow(x$posterior) + Z <- t(x$posterior) + Z <- Z[,ncol(Z):1,drop=FALSE ] + + image(x=1:n.grp, y=seq(.5, by=1, le=n.ind), Z, col=rev(heat.colors(100)), yaxt="n", ylab="", xaxt="n", xlab="Clusters") + axis(side=1, at=1:n.grp,tick=FALSE, labels=colnames(x$posterior)) + axis(side=2, at=seq(.5, by=1, le=n.ind), labels=rev(rownames(x$posterior)), las=1, cex.axis=cex.lab) + abline(h=1:n.ind, col="lightgrey") + abline(v=seq(0.5, by=1, le=n.grp)) + box() + + newGrp <- colnames(x$posterior) + x.real.coord <- rev(match(x$grp, newGrp)) + y.real.coord <- seq(.5, by=1, le=n.ind) + + points(x.real.coord, y.real.coord, col="deepskyblue2", pch=pch) + + return(invisible(match.call())) +} # end assignplot + + + + + +############ +## compoplot +############ +compoplot <- function(x, only.grp=NULL, subset=NULL, new.pred=NULL, col=NULL, lab=NULL, + legend=TRUE, txt.leg=NULL, ncol=4, posi=NULL, cleg=.8, bg=transp("white"), ...){ + if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") + if(!inherits(x, "dapc")) stop("x is not a dapc object") + + + ## HANDLE ARGUMENTS ## + ngrp <- length(levels(x$grp)) + + ## col + if(is.null(col)){ + col <- rainbow(ngrp) + } + + ## lab + if(is.null(lab)){ + lab <- rownames(x$tab) + } else { + ## recycle labels + lab <- rep(lab, le=nrow(x$tab)) + } + + ## posi + if(is.null(posi)){ + posi <- list(x=0, y=-.01) + } + + ## txt.leg + if(is.null(txt.leg)){ + txt.leg <- levels(x$grp) + } + + ## HANDLE DATA FROM PREDICT.DAPC ## + if(!is.null(new.pred)){ + n.new <- length(new.pred$assign) + x$grp <- c(as.character(x$grp), rep("unknown", n.new)) + x$assign <- c(as.character(x$assign), as.character(new.pred$assign)) + x$posterior <- rbind(x$posterior, new.pred$posterior) + lab <- c(lab, rownames(new.pred$posterior)) + } + + + ## TREAT OTHER ARGUMENTS ## + if(!is.null(only.grp)){ + only.grp <- as.character(only.grp) + ori.grp <- as.character(x$grp) + x$grp <- x$grp[only.grp==ori.grp] + x$assign <- x$assign[only.grp==ori.grp] + x$posterior <- x$posterior[only.grp==ori.grp, , drop=FALSE] + lab <- lab[only.grp==ori.grp] + } else if(!is.null(subset)){ + x$grp <- x$grp[subset] + x$assign <- x$assign[subset] + x$posterior <- x$posterior[subset, , drop=FALSE] + lab <- lab[subset] + } + + + ## MAKE THE PLOT ## + Z <- t(x$posterior) + barplot(Z, border=NA, col=col, ylab="membership probability", names=lab, las=3, ...) + + if(legend){ + oxpd <- par("xpd") + par(xpd=TRUE) + legend(posi, fill=col, leg=txt.leg, cex=cleg, ncol=ncol, bg=bg) + on.exit(par(xpd=oxpd)) + } + + return(invisible(match.call())) +} # end compoplot + + + + + +############### +## a.score +############### +a.score <- function(x, n.sim=10, ...){ + if(!inherits(x,"dapc")) stop("x is not a dapc object") + + ## perform DAPC based on permuted groups + lsim <- lapply(1:n.sim, function(i) summary(dapc(x$tab, sample(x$grp), n.pca=x$n.pca, n.da=x$n.da))$assign.per.pop) + sumry <- summary(x) + + ## get the a-scores + f1 <- function(Pt, Pf){ + tol <- 1e-7 + ##res <- (Pt-Pf) / (1-Pf) + ##res[Pf > (1-tol)] <- 0 + res <- Pt-Pf + return(res) + } + + lscores <- lapply(lsim, function(e) f1(sumry$assign.per.pop, e)) + + ## make a table of a-scores + tab <- data.frame(lscores) + colnames(tab) <- paste("sim", 1:n.sim, sep=".") + rownames(tab) <- names(sumry$assign.per.pop) + tab <- t(as.matrix(tab)) + + ## make result + res <- list() + res$tab <- tab + res$pop.score <- apply(tab, 2, mean) + res$mean <- mean(tab) + + return(res) + +} # end a.score + + + + + + + +############## +## optim.a.score +############## +optim.a.score <- function(x, n.pca=1:ncol(x$tab), smart=TRUE, n=10, plot=TRUE, + n.sim=10, n.da=length(levels(x$grp)), ...){ + ## A FEW CHECKS ## + if(!inherits(x,"dapc")) stop("x is not a dapc object") + if(max(n.pca)>ncol(x$tab)) { + n.pca <- min(n.pca):ncol(x$tab) + } + if(n.da>length(levels(x$grp))){ + n.da <- min(n.da):length(levels(x$grp)) + } + pred <- NULL + if(length(n.pca)==1){ + n.pca <- 1:n.pca + } + if(length(n.da)==1){ + n.da <- 1:n.da + } + + + ## AUXILIARY FUNCTION ## + f1 <- function(ndim){ + temp <- dapc(x$tab[,1:ndim,drop=FALSE], x$grp, n.pca=ndim, n.da=x$n.da) + a.score(temp, n.sim=n.sim)$pop.score + } + + + ## SMART: COMPUTE A FEW VALUES, PREDICT THE BEST PICK ## + if(smart){ + if(!require(stats)) stop("the package stats is required for 'smart' option") + o.min <- min(n.pca) + o.max <- max(n.pca) + n.pca <- pretty(n.pca, n) # get evenly spaced nb of retained PCs + n.pca <- n.pca[n.pca>0 & n.pca<=ncol(x$tab)] + if(!any(o.min==n.pca)) n.pca <- c(o.min, n.pca) # make sure range is OK + if(!any(o.max==n.pca)) n.pca <- c(o.max, n.pca) # make sure range is OK + lres <- lapply(n.pca, f1) + names(lres) <- n.pca + means <- sapply(lres, mean) + sp1 <- smooth.spline(n.pca, means) # spline smoothing + pred <- predict(sp1, x=1:max(n.pca)) + best <- pred$x[which.max(pred$y)] + } else { ## DO NOT TRY TO BE SMART ## + lres <- lapply(n.pca, f1) + names(lres) <- n.pca + best <- which.max(sapply(lres, mean)) + means <- sapply(lres, mean) + } + + + ## MAKE FINAL OUTPUT ## + res <- list() + res$pop.score <- lres + res$mean <- means + if(!is.null(pred)) res$pred <- pred + res$best <- best + + ## PLOTTING (OPTIONAL) ## + if(plot){ + if(smart){ + boxplot(lres, at=n.pca, col="gold", xlab="Number of retained PCs", ylab="a-score", xlim=range(n.pca)+c(-1,1), ylim=c(-.1,1.1)) + lines(pred, lwd=3) + points(pred$x[best], pred$y[best], col="red", lwd=3) + title("a-score optimisation - spline interpolation") + mtext(paste("Optimal number of PCs:", res$best), side=3) + } else { + myCol <- rep("gold", length(lres)) + myCol[best] <- "red" + boxplot(lres, at=n.pca, col=myCol, xlab="Number of retained PCs", ylab="a-score", xlim=range(n.pca)+c(-1,1), ylim=c(-.1,1.1)) + lines(n.pca, sapply(lres, mean), lwd=3, type="b") + myCol <- rep("black", length(lres)) + myCol[best] <- "red" + points(n.pca, res$mean, lwd=3, col=myCol) + title("a-score optimisation - basic search") + mtext(paste("Optimal number of PCs:", res$best), side=3) + } + } + + return(res) +} # end optim.a.score + + + + + + +############# +## as.lda.dapc +############# +as.lda <- function(...){ + UseMethod("as.lda") +} + +as.lda.dapc <- function(x, ...){ + if(!inherits(x,"dapc")) stop("x is not a dapc object") + res <- list() + + res$N <- nrow(res$ind.coord) + res$call <- match.call() + res$counts <- as.integer(table(x$grp)) + res$lev <- names(res$counts) <- levels(x$grp) + res$means <- x$means + res$prior <- x$prior + res$scaling <- x$loadings + res$svd <- sqrt(x$eig) + + class(res) <- "lda" + + return(res) +} # end as.lda.dapc + + + + + + +############## +## predict.dapc +############## +predict.dapc <- function(object, newdata, prior = object$prior, dimen, + method = c("plug-in", "predictive", "debiased"), ...){ + + if(!inherits(object,"dapc")) stop("x is not a dapc object") + method <- match.arg(method) + + x <- as.lda(object) + + + ## HANDLE NEW DATA ## + if(!missing(newdata)){ + ## make a few checks + if(is.null(object$pca.loadings)) stop("DAPC object does not contain loadings of original variables. \nPlease re-run DAPC using 'pca.loadings=TRUE'.") + newdata <- as.matrix(newdata) # to force conversion, notably from genlight objects + if(ncol(newdata) != nrow(object$pca.loadings)) stop("Number of variables in newdata does not match original data.") + + ## centre/scale data + for(i in 1:nrow(newdata)){ # this is faster for large, flat matrices) + newdata[i,] <- (newdata[i,] - object$pca.cent) / object$pca.norm + } + newdata[is.na(newdata)] <- 0 + + ## project as supplementary individuals + XU <- newdata %*% as.matrix(object$pca.loadings) + } else { + XU <- object$tab + } + + ## FORCE IDENTICAL VARIABLE NAMES ## + colnames(XU) <- colnames(object$tab) + + + ## HANDLE DIMEN ## + if(!missing(dimen)){ + if(dimen > object$n.da) stop(paste("Too many dimensions requested. \nOnly", object$n.da, "discriminant functions were saved in DAPC.")) + } else { + dimen <- object$n.da + } + + ## CALL PREDICT.LDA ## + temp <- predict(x, XU, prior, dimen, method, ...) + + + ## FORMAT OUTPUT ## + res <- list() + res$assign <- temp$class + res$posterior <- temp$posterior + res$ind.scores <- temp$x + + return(res) + +} # end predict.dapc + + + + + + + +## ############ +## ## crossval +## ############ +## crossval <- function (x, ...) UseMethod("crossval") + +## crossval.dapc <- function(){ + +## } + + + +## ############### +## ## randtest.dapc +## ############### +## ##randtest.dapc <- function(x, nperm = 999, ...){ + +## ##} # end randtest.dapc + + + + +######## TESTS IN R ####### + +## TEST PREDICT.DAPC ## +## data(sim2pop) +## temp <- seppop(sim2pop) +## temp <- lapply(temp, function(e) hybridize(e,e,n=30)) # force equal pop sizes +## hyb <- hybridize(temp[[1]], temp[[2]], n=30) +## newdat <- repool(temp[[1]], temp[[2]], hyb) +## pop(newdat) <- rep(c("pop A", "popB", "hyb AB"), c(30,30,30)) + + +## ##dapc1 <- dapc(newdat[1:61],n.pca=10,n.da=1) +## dapc1 <- dapc(newdat[1:60],n.pca=2,n.da=1) +## scatter(dapc1) +## hyb.pred <- predict(dapc1, newdat[61:90]) + +## scatter(dapc1) +## points(hyb.pred$ind.scores, rep(.1, 30)) + +## assignplot(dapc1, new.pred=hyb.pred) +## title("30 indiv popA, 30 indiv pop B, 30 hybrids") Modified: pkg/R/import.R [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/adegenet -r 1103 From noreply at r-forge.r-project.org Fri Apr 5 14:48:02 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Apr 2013 14:48:02 +0200 (CEST) Subject: [adegenet-commits] r1104 - in pkg: . R man Message-ID: <20130405124802.3B065184C19@r-forge.r-project.org> Author: jombart Date: 2013-04-05 14:48:01 +0200 (Fri, 05 Apr 2013) New Revision: 1104 Modified: pkg/DESCRIPTION pkg/R/sequences.R pkg/man/sequences.Rd Log: Brand new version of DNAbin2genind, orders of magnitude faster, and much more memory-efficient Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-04-05 10:25:24 UTC (rev 1103) +++ pkg/DESCRIPTION 2013-04-05 12:48:01 UTC (rev 1104) @@ -7,6 +7,6 @@ Suggests: genetics, spdep, tripack, pegas, seqinr, adehabitat, multicore, akima, maps, splancs, hierfstat Depends: R (>= 2.10), methods, MASS, ade4, igraph, ape Description: Classes and functions for genetic data analysis within the multivariate framework. -Collate: classes.R basicMethods.R handling.R auxil.R setAs.R SNPbin.R glHandle.R glFunctions.R glSim.R find.clust.R hybridize.R scale.R fstat.R import.R seqTrack.R chooseCN.R genind2genpop.R loadingplot.R sequences.R gstat.randtest.R makefreq.R colorplot.R monmonier.R spca.R coords.monmonier.R haploGen.R old2new.R spca.rtests.R dapc.R haploPop.R PCtest.R dist.genpop.R Hs.R propShared.R export.R HWE.R propTyped.R inbreeding.R glPlot.R gengraph.R simOutbreak.R mutations.R zzz.R +Collate: classes.R basicMethods.R handling.R auxil.R setAs.R SNPbin.R glHandle.R glFunctions.R glSim.R find.clust.R hybridize.R scale.R fstat.R import.R seqTrack.R chooseCN.R genind2genpop.R loadingplot.R sequences.R gstat.randtest.R makefreq.R colorplot.R monmonier.R spca.R coords.monmonier.R haploGen.R old2new.R spca.rtests.R dapc.R dapcXval.R haploPop.R PCtest.R dist.genpop.R Hs.R propShared.R export.R HWE.R propTyped.R inbreeding.R glPlot.R gengraph.R simOutbreak.R mutations.R zzz.R License: GPL (>=2) LazyLoad: yes Modified: pkg/R/sequences.R =================================================================== --- pkg/R/sequences.R 2013-04-05 10:25:24 UTC (rev 1103) +++ pkg/R/sequences.R 2013-04-05 12:48:01 UTC (rev 1104) @@ -10,61 +10,61 @@ ################ # DNAbin2genind ################ -DNAbin2genind <- function(x, pop=NULL, exp.char=c("a","t","g","c"), na.char=NULL, polyThres=1/100){ +DNAbin2genind <- function(x, pop=NULL, exp.char=c("a","t","g","c"), polyThres=1/100){ - ## misc checks + ## MISC CHECKS ## if(!inherits(x,"DNAbin")) stop("x is not a DNAbin object") if(!require(ape)) stop("The package ape is required.") - - ## DNA bin to matrix of characters - x <- as.character(x) # should output a matrix - - if(is.list(x)) { # if this is a list - temp <- unique(sapply(x,length)) # check lengths of sequences - if(length(temp)>1) stop("Sequences have different length - please use alignements only.") - else{ # if sequences have same length, build the matrix - temp <- names(x) - x <- t(as.data.frame(x)) - rownames(x) <- temp - } + if(is.list(x)) { + x <- as.matrix(x) } if(is.null(colnames(x))) { colnames(x) <- 1:ncol(x) } - ## replace NAs - if(is.null(na.char)){ - if(is.null(exp.char)) stop("both exp.char and na.char are NULL") - temp <- paste(exp.char, collapse="", sep="") - if(any(exp.char=="-")) { - temp <- paste("-",temp, sep="") # string '-' must begin the regexp - } - temp <- paste("[^", temp, "]", sep="") # anything but the expected is NA - x <- gsub(temp,NA,x) - } else { - temp <- paste(na.char, collapse="", sep="") - if(any(na.char=="-")) { - temp <- paste("-",temp, sep="") # string '-' must start the regexp - } - temp <- paste("[", temp, "]", sep="") - x <- gsub(temp,NA,x) - } - ## keep only columns with polymorphism (i.e., SNPs) - isPoly <- function(vec){ + ## FUNCTION TO PROCESS ONE LOCUS ## + ## INPUTS: + ## locus is a column of a DNAbin matrix + ## posi is the index of this column + ## OUTPUTS: + ## returns NULL if no polymorphism + ## returns a disjonctive table with named columns otherwise + ## column names are given as [position.allele] + processLocus <- function(locus, posi){ + vec <- as.character(locus) + vec[!vec %in% exp.char] <- NA N <- sum(!is.na(vec)) # N: number of sequences - temp <- table(vec)/N - if(sum(temp > polyThres) >= 2) return(TRUE) - return(FALSE) + if(N==0) return(NULL) # escape if untyped locus + alleles <- names(which(table(vec)/N >= polyThres )) + if(length(alleles)<2) return(NULL) # escape if no polymorphism + vec[!vec %in% alleles] <- NA + out <- sapply(alleles, function(e) 1*(vec==e)) + colnames(out) <- paste(posi, alleles, sep=".") + return(out) } - toKeep <- apply(x, 2, isPoly) - if(sum(toKeep)==0) stop("No polymorphic site detected") - x <- x[,toKeep] - ## build output - res <- df2genind(x, pop=pop, ploidy=1, ncode=1, type="codom") + ## PROCESS ALL LOCI ## + ## get disjonctive matrix ## + ## system.time(res at tab <- Reduce(cbind, lapply(1:ncol(x), function(i) processLocus(x[,i], i)))) # works, but Reduce is real slow + temp <- lapply(1:ncol(x), function(i) processLocus(x[,i], i)) # process all loci, return a list + col.names <- unlist(sapply(temp, colnames)) + temp <- as.matrix(data.frame(temp[!sapply(temp, is.null)])) # remove NULL slots, list -> matrix + if(is.null(temp) || ncol(temp)==0){ + cat("\nNo polymorphism detected - returning NULL.\n") + return(NULL) + } + + ## sort out col/row names ## + colnames(temp) <- col.names # restore correct names + rownames(temp) <- rownames(x) + + ## create genind output ## + res <- genind(temp, ploidy=1, type="codom") + rm(temp) # remove temp + gc() # collect garbage res$call <- match.call() return(res) Modified: pkg/man/sequences.Rd =================================================================== --- pkg/man/sequences.Rd 2013-04-05 10:25:24 UTC (rev 1103) +++ pkg/man/sequences.Rd 2013-04-05 12:48:01 UTC (rev 1104) @@ -13,8 +13,7 @@ - alignment (seqinr package): function alignment2genind\cr } \usage{ -DNAbin2genind(x, pop=NULL, exp.char=c("a","t","g","c"), na.char=NULL, - polyThres=1/100) +DNAbin2genind(x, pop=NULL, exp.char=c("a","t","g","c"), polyThres=1/100) alignment2genind(x, pop=NULL, exp.char=c("a","t","g","c"), na.char="-", polyThres=1/100) From noreply at r-forge.r-project.org Fri Apr 5 15:03:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Apr 2013 15:03:25 +0200 (CEST) Subject: [adegenet-commits] r1105 - pkg/R Message-ID: <20130405130326.12F0A18487E@r-forge.r-project.org> Author: jombart Date: 2013-04-05 15:03:25 +0200 (Fri, 05 Apr 2013) New Revision: 1105 Modified: pkg/R/sequences.R Log: Adjusted behaviour for rare alleles Modified: pkg/R/sequences.R =================================================================== --- pkg/R/sequences.R 2013-04-05 12:48:01 UTC (rev 1104) +++ pkg/R/sequences.R 2013-04-05 13:03:25 UTC (rev 1105) @@ -36,10 +36,9 @@ vec <- as.character(locus) vec[!vec %in% exp.char] <- NA N <- sum(!is.na(vec)) # N: number of sequences - if(N==0) return(NULL) # escape if untyped locus - alleles <- names(which(table(vec)/N >= polyThres )) - if(length(alleles)<2) return(NULL) # escape if no polymorphism - vec[!vec %in% alleles] <- NA + if(N==0 || sum(table(vec)/N >= polyThres )<2) return(NULL) # escape if untyped locus or no SNPs + alleles <- unique(na.omit(vec)) + ## vec[!vec %in% alleles] <- NA # this would replace rare alleles by NAs out <- sapply(alleles, function(e) 1*(vec==e)) colnames(out) <- paste(posi, alleles, sep=".") return(out) From noreply at r-forge.r-project.org Fri Apr 5 19:11:32 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Apr 2013 19:11:32 +0200 (CEST) Subject: [adegenet-commits] r1106 - pkg pkg/man www www/files Message-ID: <20130405171132.370CE1810A3@r-forge.r-project.org> Author: jombart Date: 2013-04-05 19:11:31 +0200 (Fri, 05 Apr 2013) New Revision: 1106 Added: www/files/outbreakPractical.1.2.pdf Modified: pkg/ChangeLog pkg/DESCRIPTION pkg/NAMESPACE pkg/man/adegenet.package.Rd pkg/man/export.Rd www/documentation.html Log: Added new tutorial for GenEpi day Modified: pkg/ChangeLog =================================================================== --- pkg/ChangeLog 2013-04-05 13:03:25 UTC (rev 1105) +++ pkg/ChangeLog 2013-04-05 17:11:31 UTC (rev 1106) @@ -1,3 +1,12 @@ + CHANGES IN ADEGENET VERSION 1.3-7 + +NEW FEATURES + + o entirely new version of DNAbin2genind, much faster than before + and suitable for large alignments + + + CHANGES IN ADEGENET VERSION 1.3-6 NEW FEATURES Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-04-05 13:03:25 UTC (rev 1105) +++ pkg/DESCRIPTION 2013-04-05 17:11:31 UTC (rev 1106) @@ -1,6 +1,6 @@ Package: adegenet Version: 1.3-7 -Date: 2013/01/30 +Date: 2013/04/05 Title: adegenet: an R package for the exploratory analysis of genetic and genomic data. Author: Thibaut Jombart, Ismail Ahmed, Anne Cori, Tobias Erik Reiners, Peter Solymos Maintainer: Thibaut Jombart Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-04-05 13:03:25 UTC (rev 1105) +++ pkg/NAMESPACE 2013-04-05 17:11:31 UTC (rev 1106) @@ -6,10 +6,11 @@ # Import all packages listed as Imports or Depends import( - methods, - MASS, - ade4, - igraph + utils, + methods, + MASS, + ade4, + igraph ) # Load DLL Modified: pkg/man/adegenet.package.Rd =================================================================== --- pkg/man/adegenet.package.Rd 2013-04-05 13:03:25 UTC (rev 1105) +++ pkg/man/adegenet.package.Rd 2013-04-05 17:11:31 UTC (rev 1106) @@ -190,8 +190,8 @@ \tabular{ll}{ Package: \tab adegenet\cr Type: \tab Package\cr - Version: \tab 1.3-6\cr - Date: \tab 2013-01-30 \cr + Version: \tab 1.3-7\cr + Date: \tab 2013-04-05 \cr License: \tab GPL (>=2) } } Modified: pkg/man/export.Rd =================================================================== --- pkg/man/export.Rd 2013-04-05 13:03:25 UTC (rev 1105) +++ pkg/man/export.Rd 2013-04-05 17:11:31 UTC (rev 1106) @@ -49,19 +49,4 @@ } \seealso{\code{\link{import2genind}}} \author{Thibaut Jombart \email{t.jombart at imperial.ac.uk} } -\examples{ -\dontrun{ -if(require(hierfstat) & require(genetics)){ - -obj <- read.fstat(system.file("data/diploid.dat",package="hierfstat")) - -X <- genind2hierfstat(obj) -X - -read.fstat.data(paste(.path.package("hierfstat"),"/data/diploid.dat",sep="",collapse=""),nloc=5) - -genind2genotype(obj) -} -} -} \keyword{manip} \ No newline at end of file Modified: www/documentation.html =================================================================== --- www/documentation.html 2013-04-05 13:03:25 UTC (rev 1105) +++ www/documentation.html 2013-04-05 17:11:31 UTC (rev 1106) @@ -41,6 +41,8 @@ + + engine.


@@ -101,6 +103,8 @@ + + 1 [version with all commands]
    > practical @@ -111,6 +115,8 @@ + + 2 [version with all commands]
    > practical @@ -121,6 +127,8 @@ + + 3

- MRC methodological session: Introduction to phylogenetics:
@@ -128,12 +136,11 @@     > practical
    > data (DNA sequences, annotations)
+
- RAPID-NGS workshop, M?nster (March 2013) - Outbreak analysis using adegenet and ape new
+ style="font-style: italic;">ape and adegenet
    > practical
    > data ( / Public Health: Introduction to phylogenetics.new / Public Health: Introduction to multivariate analysis / bacterial GWAS.simGWAS.RData)

+ - GenEpi workshop, London (April 2013) - Outbreak analysis using ape, adegenet, and + + outbreaker new
+     > practical
+     > data (cases.csv, alignment.fa, update.csv)

+
+
Dirty hacks useful for teaching
- a small hack for installing R packages on computers without @@ -181,6 +205,8 @@ + + README new
Added: www/files/outbreakPractical.1.2.pdf =================================================================== --- www/files/outbreakPractical.1.2.pdf (rev 0) +++ www/files/outbreakPractical.1.2.pdf 2013-04-05 17:11:31 UTC (rev 1106) @@ -0,0 +1,8115 @@ +%PDF-1.4 +%???? +1 0 obj +<< /S /GoTo /D (section.1) >> +endobj +4 0 obj +(Introduction) +endobj +5 0 obj +<< /S /GoTo /D (subsection.1.1) >> +endobj +8 0 obj +(An emerging pathogen outbreak) +endobj +9 0 obj +<< /S /GoTo /D (subsection.1.2) >> +endobj +12 0 obj +(Your objective) +endobj +13 0 obj +<< /S /GoTo /D (section.2) >> +endobj +16 0 obj +(First look at the data) +endobj +17 0 obj +<< /S /GoTo /D (section.3) >> +endobj +20 0 obj +(Phylogenetic analysis) +endobj +21 0 obj +<< /S /GoTo /D (section.4) >> +endobj +24 0 obj +(Identifying clusters of cases) +endobj +25 0 obj +<< /S /GoTo /D (section.5) >> +endobj +28 0 obj +(Analysis using SeqTrack) +endobj +29 0 obj +<< /S /GoTo /D (section.6) >> +endobj +32 0 obj +(Detailed outbreak reconstruction using outbreaker) +endobj +33 0 obj +<< /S /GoTo /D (subsection.6.1) >> +endobj +36 0 obj +(outbreaker analysis) +endobj +37 0 obj +<< /S /GoTo /D (subsection.6.2) >> +endobj +40 0 obj +(Inference from the reconstructed ancestries) +endobj +41 0 obj +<< /S /GoTo /D (section.7) >> +endobj +44 0 obj +(Update from detailed case investigations) +endobj +45 0 obj +<< /S /GoTo /D [46 0 R /Fit ] >> +endobj +55 0 obj << +/Length 1495 +/Filter /FlateDecode +>> +stream +x??WKo?6??W?(1??(????S??a??l?N??Z????w^???? ?R?!g??o8??6??/3??Z??lH?W??,7??se?Ir?????N>????&???>???n?p6K?0i/?@????!?y'??m?5*?????.??~^? X??8??+?C?????V?????xL?QS^???7??v?;???E?u1????.??S???????H_?6'?Od???a? +?f??0????,?W??Y??????HeP?N> ??R;?\??I?$e???????????d???1??^??zc?W??????g6? ??y??`Fu??u'??Am?*?????P?:?e?(???BSr??7???2.???r??H??m??nV?????????1@??:?? >??+f?tC\: ?'????????(?R???j?Jj??????R??CmG?e%y?6$*???pP;??a?'??pe9?OTn??>f??p????????>Kh:?Un)x^gi??v?F> endobj +47 0 obj << +/Type /XObject +/Subtype /Form +/FormType 1 +/PTEX.FileName (/home/thibaut/latex/configPerso/figs/Rlogo.pdf) +/PTEX.PageNumber 1 +/PTEX.InfoDict 64 0 R +/BBox [0 0 101 77] +/Resources << +/Font << /F0 65 0 R>> +/XObject << +/Im0 66 0 R +>>/ProcSet [ /PDF /Text /ImageC ] +>> +/Length 30 +>> +stream +q +101 0 0 77 0 0 cm +/Im0 Do +Q +endstream +endobj +64 0 obj +<< +/CreationDate (D:20040610181518) +/ModDate (D:20040610181518) +/Producer (ImageMagick 6.0.0 04/30/04 Q16 http://www.imagemagick.org) +>> +endobj +65 0 obj +<< +/Type /Font +/Subtype /Type1 +/Name /F0 +/BaseFont /Helvetica +/Encoding /MacRomanEncoding +>> +endobj +66 0 obj +<< +/Type /XObject +/Subtype /Image +/Name /Im0 +/Filter [/FlateDecode] +/Width 101 +/Height 77 +/ColorSpace 67 0 R +/BitsPerComponent 8 +/Length 68 0 R +>> +stream +x??|Xi?6??n????6???b??"(E????{OB?J????{GT?!B2?? ???????????u??&C???s????#+6==:++6P??????Q?[jjd|?1,? 6h~$2??????X?22w}??g~!z_h??"????????*? ??(?SwO?????:D?i?+.?? ?B?8??4??**<(4?/$?7???O????xw7?????B??,???Y?????s?L^tf??i????!??E?????q'&X .?9???5?????M + at T^?UZ?VU? VZ?p?}[????????]3?)==6!6"&2?1"??L:5?N ????????`?kLD(XtxXTXhd(|302, :??????????????x0??c??!????I&y??????x??'????????X1??^.?Y?l?%????????or? +4{???NDP???H???_????+????o(j~Y??TR[W???<$g +??B%???????x???O^^?nn?????????????????????`??j??a??????? +?DG?cc?cc?11?11AT* +??????rwwrsstr?us?y??gf?0F??4??? #????A??.?3rf??L?0d0?>|h}????9????^U?'64?K?0>~?o/*N?R]?????????M??qk???F ???GS?b?#??A!>T?????`j?h`f??g????TQ???????#)???H<?????D??c?{???SR?T??30R??6 ?ZSin!a? h?A!?4_ +??J!?o???[Y???Y::???^y?YC?}?|Mr???z?)???u7??E??$?d?f89??????????????J?????????????????-??1?@kk}++ccM =??@???? +???????0??????????????????b?o \?z??????w:????????8xd?????{??????>????C'?=}????'?? ]yx???U5%#Cg';_??G + ???x??lm,?m--??t?-?M#CC?Z_s&gri68?L ??????u??????OC??rX??????ji??-ki???|??????~x???*???bl????h`???D??L????Lv??????6H ??nNx]cM%)?;W?_N??P??????????nn?}??nr????;H?A???T?Q`????!?n?;? +^0p??0????????l?m=???E ????>???8?????]?j??-;/??0??pp????????u???kd????M=\l\?6jj +V?&j????M?u??????0?L?9;q?R?)??NL??*??@?Z[??~p at Pl##-Q?;w?\??y???II?<??? ?v???????$)!v???-?7?????,Y0?g?x???9:8?b??#P???LL??]???66?yyJ=??(x????.?9u?h???Gn?x&)???hkehi?oj???"???;{?????c@???3D?a???W??????|@|??A????????+?8`%"rCB?\/?i?E9?z:?2?3o?????QWS?$x~??M??AQ???9??,????????^u??P? ?tCI??@??xy??L=Mx6??[O??????'??h]3g??`q>3G?l ???????[?n +?;w?????7?^????31=mggk} +0u +?'??F??\@3P?/??Y. ?6 A??u-?ySS???g????F??wED????3??????????(?l/?P?????V.?~?????????C??????H????N???@Xld???f??x??????^0?$:???`????y????x?????= ??:"?? ? +tg?D?}y????999???.??u??????? >???"cmcbna??? ????71?omk?%g+??|? ??i???^?V?_VO? _?$%?[X??????X??Lb?Yi????.?o??`?O??av??????G??q???? ?#?G?Q62?F:??????82?=??hh????i:?25????|S?P +?????nFUQ??p??3??????Z[??? p?A?HJ?54?9~????k1R??7??~?j???4??H???y???o?!?m?????e]i???{3??? +?? +?2K>fw????(??^??Z????1??'??7??+)????PK/??Z???%?Y??????????????QM???????R?|'?????Az?ch,x???BUIFV"????????? y))?G?4??8?`?,??M[mum?P? |(-????}????k??????#S?P??~?r??XiI????????kVaX?Z?j???eee?FFF?\?.?O? )?7??? +?~i??t?"??.?Q???|b ? > ncH?Gz?????g???0?~??~??N??q5???6v ?5??????:?????????eKH?rN?pL0???6 ?4 +V7 +???}???H?LB?[?8??1??F |i?????T7????w??f"???#6???CGW??D??4???|?l???5u?E%??????`???bb?n??h???????????? +??`ff&?k:??????-??-kll@ ?U???=??c-???-?\?5??B9m??!Y????(??a??Q??M?'5?&?)??c{R??]Z7RR?(??-??)??S:?^????9?t??f????q?"??Q??~???;??;r??%IY{#?Pr at ep|kH?;RP=?\?J?t??q?*???o"????//?R??.X?t????2?*?2?U??^?KKJ??>|".????g !?x?????G:y^t?????????V.???9f?tk?{?J'??;8?jOJ??o? -??U9?G?.?dgM?fJg?%A?"?B PZ?????UT??????,5-.)%2-#??N'A????76???)UU??????.NODwl?????}????????-_?e?V?? ??zx?:~???3????/?????S??s??[ ?E?o??5y?H?z&?B????}??eo/??1\o k??(+/ ??? @- ?LH?NH +OM??+H?R???"??d??,M????)??????N?6????+???0,.?????!?????8#x??????)?U]] VQQ???fog)p? ? ???g??????????????ei???E +y????P????CB{?;u?26??b???r?Wl+6???# +eF?^(???????0?@)??,???sl\+H???-?- ???m??U?-?g.Mu#.:????????8?S?h~$???]?PdIi~Tthx?l|Pn~R`??????*??WhHVZ????jkc~????~??r???k??z???9?W??tJ?s-t?6???K?6?@?D????7_??????;???c???cs????????F\????q?"?-?fQ???V1???????6?&??Vr?;zDGhl??}??UE????4??S???DzF??????R^?Vh?3FD?}B????????O???x??\???eeyE?9?E??FW?l????????????tL}?????h????UM??????}???C??n?s&?.?7?09::??Mr???It???Ap?i.?b{???L??d??t??-p%?ohgx\wdb??u?9??[?????????o???eO??fef?????T???=????_w?@/???YIu5e{+pF? ?U????????~?????Vm??r????-???????????[?B????p?p ?g?b?]*;?m?t?????(??zS????}?,?\??????*c??A????t,S?=+I??????????N}???g?7n>?g?y 3??1?5?????l??;?y?.G'] +???X????P?O?s`??_?Gff????????????Qdd at nnr~~:`?????hy???m??vl??tpC}-69?d2x??S???"c?p??M???in`g????????????m????8u??]?8Z?????rMb9 ??9??`Ou??B?l~? ?k1?E4??E??i??EZ??w?%???????Vr?6"a /???o?~q???[????a:?= <AF!%??? ??N??5???K%?Z;?-?T??Htt4????j?Bq???? -%9?E!{A?*(p???}????to?8???S_?dLw??+g?B??r?|J??;HAm???DZ? +????=$tGD??3 1???????\^^15????3????5?????C?G+\????Gw?rjxcRAoi#??????t???e???\?c???o^w\??c?7?A??P??;??Y`??\=?nN???f???D__7???L???,(???????R???3?? \<{I?|Lt?LS??D?????N?Qg4qNv?-^???W??r-? Eu?:$5=??????????S?:???g???$7??|??,?????6=?M^I{iUgO?:w??jRM?GB?^??b?M?-?oe?!?}??w?9??+??]??????P?A\????????}d???4+&6TO_??0?96<(XdT????????????3?? n???88XP(??? ?? ?`^?.?U?\?zE???c?Zj3?Q??,??????).G.w??9zV????^EN9?????(U?????#?A??[Bb??;???Rr:cS[Sr???b?? ?q??.?4??Sq?1%??G??s?QB?????k7????????.Y{????]?3?N??]???? x?? UE?0Yc?"`?imtqu06?13???3? ????b^^??H:WzZbLtX`?'???yE???{woFG?a?X366???????5?????G?v?(????)??5O???+'7D?M/??H/??U??V??W?]?2????W~??}??a?d???? +}??-U4 ^??????c??8J??????UZ? ??9?l????C??rF-?s:??????????^p?????M\?????y????????Be??l???J$;7Wgz?/hWvVjx="<(?????$"| J???? ?}?????v???kv"p??58?j?K???_??;X??i??k???q?@$w?|??) ?????S>||?k???\f?I ???A2?[IQ@ST????p?Too?? ??????????X?HD??? ???????U?Hd????????Q??7??J?M?c?h?K?.?.`??_?_???????????~&*;??HE#7?x4?p8?h?g ???>AMN? + ?|k|??c??S1??.!k??ilGL??v?2?&?9???]????||????p??????78??? +}nkm?? ???06?? g??1???Q^ ??x????\EY@SV?SV?uv?g???4 +?dLLHTT`X0??`?????*????H??????'t????_?L??,?J??v?yz4??w??"=#hg??d4E8?DC?3??trO!??Bk???%? +D???G?????|?Z???)"?/?????????]??????5g?????y??w?????]X???p^???????l(?u?4??2f?F?1?fT?b2??m.RQVnbl(.?@NVZZ?1???ky??f?????????11Aq?A?/?c!?UV???D??cK+'g[?A?Tu??(?Q{`fd????2vJ?S*?!??R>5?"?M??=.??s???:???}?7??s?????.?]???cF????E????E?v???? +J??????bp?????W???????!xE8$<?g?7?c?3Y?<?`???GD????k< +?c +$???? BxS]?? ??\RT???%"|???{*??????w P??tX'%???????P??;X???w?1??HEeqtL????t ???^??$?? ?????? @?d210 +?tt???>???/)?HK????1$c~~^aa??t???(?)TOGKE??&??Z?? + 5??u???+1?? 1? ?3p?Y??]PQ??$???3??vH??.Y?$???|?h???K?Bn?x?o?6??u??'^????Gs$????H5.????O??7N?R1?C????S?0p??'?5?9S?Jp??L?:Z?????J8PC#??????^???QdV???1v????? ??#????J?rw???x" +)??#pL??\]?P???????S""??^x@?????XCS[ ?C#????4?1?n[8??Q??g????\??I?????VSW?????F???=G?@???v???p??????p??G???g%?77}?j?4m3?????K at BZ?p???????_(?dc???GOM??qf"????a7o^?T???????rE???;????3????Fn_w?XP??m?? +o\??m????????$??#??-??)???D |?j?g?U?v?:y????l`???c??<.????>5 ????&??4MC???$d?{?Y?f?Z??[':K?1H?q????e,_??U????;?,K\?%>??!C?,A?"??nM??E????????????f0Gy?=?Y????|?????`9`?ut????1??cG?yF03? 7?/+'=1%6+7%-;???<61???9*!GM?????is +O???bb?_?'UZ??:??:f??Vx?j?=zj~?????Azn%db\C???Z??I?????=? ??y? ???L?????YZ?????y????????q??????????%r??C?{?rR?T??:Qi??P?_?_x8? +!?????/?$?????r6\g?\w??y??%@&>1.!9&1%:?0-'?-#7??????>????,?hr????8-S?D?|?????????????5"?? +??3?????tlX???????????P?[?f??-3R?M3??)????zccC??O?p??????};wm=rt????+?^?{???SIU-# ?o??h???Fm???o??j:&???+2???/]MNO?????I??I?/JO?J,?,**)??%???Xe ++Eu????????d?????#UC>f??c?Z??^?T???}??h???'???l??????>(?? ??????v~h RT??p??????k??;???? 6??m???C???U???5a + 9c%53?iFF?????46??"??w}????4???WRZ??C|?L????????g??????????????\?m?)JP>H? +??]k?Q +y??]??S??_ +9?54?SH?/Z??;?w?????Sg???>?r???BW?^?$tV??????<{???3?6m?{(??????? +?H+B?Rf??a?R?'?:?1{??6?i2/\n=?z?DWN?xp????@M????jU?W?_Yf7??Ptpp????N????  +m????%a(?.+\?w?+HS?]?V???T`??A??b:?]?????o?s???u?m???}??U?6??? +x?a??m? +?,??S?2>v????????????cE{ +k?4{?c? {? +?*gJ-??K??k6?\?k?@???}????h?? ??L?kZ?9??e????i#?????/zK7P??? +???56?d?U??rm ???g?K^;?TsB?G@???%t[e?!?'?\???????lfaRS[14?????e8?1?&TH??~"k ??$?????????{????+b??r3\&?R?@??? ,?#)m ?D???1d??????????D+w,?????S??b??c?'0??9???????@???B??l=???M1?a ]???n???????u??+7??&S???)??!??,?? +}??(??G4?????????T??{???*umS?]??*j?[bh?-???y8r????=Q?'?w?B?fZ?x59= ?o????L3g???Kp??Z sca G??x?u??$??>?'uF(U??????2?? j??U???O^~????m?uv?????M?z??L?9lP`t?*I?*?Q?W?y?? +3rH?h??y???V1??A???????I????j>SUR???????????;?pf^??-3?????%?????eb?Hj???h?%?tW???@????^??q" ?J??"???[w??rwE?Yl?>??????s9???0???^&?(??<}n/??$&?`??i????R????C>? ????ZF\?{jh??%MDLKTL]??rXh???M?Nl???????L???????V???N)??j0jqplcny^??????????V|?5????????]q6?Bx??W^?5???F2??H?J?I?93??a??S?~??????8??O?5%?_y???2\?6???????4??=?H  ????D??!?? _:??$? +F + + +??F??C?D?H????=> ???H??}?#??BQ ?????AAa?$Z)?N?FD????????\?8kr??G?????1@???{???9??6&??:q9 ?`??l0??alsf +~.??A?_a????F??0???[??I}Q???4:0}???p?W+? +??N?????/? ?-??t +endstream +endobj +67 0 obj +/DeviceRGB +endobj +68 0 obj +15973 +endobj +48 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [260.916 500.94 268.363 509.958] +/A << /S /GoTo /D (cite.np145) >> +>> endobj +49 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [325.498 487.391 332.945 496.408] +/A << /S /GoTo /D (cite.tjart20) >> +>> endobj +50 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [414.193 487.391 421.64 496.408] +/A << /S /GoTo /D (cite.outbreaker) >> +>> endobj +51 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [333.158 460.292 340.605 469.31] +/A << /S /GoTo /D (cite.tj527) >> +>> endobj +52 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [131.01 446.743 138.457 455.761] +/A << /S /GoTo /D (cite.tjart05) >> +>> endobj +53 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [233.562 433.194 241.009 442.212] +/A << /S /GoTo /D (cite.outbreaker) >> +>> endobj +56 0 obj << +/D [46 0 R /XYZ 69.866 808.885 null] +>> endobj +57 0 obj << +/D [46 0 R /XYZ 70.866 771.024 null] +>> endobj +54 0 obj << +/Font << /F26 58 0 R /F53 59 0 R /F8 60 0 R /F60 61 0 R /F70 62 0 R >> +/XObject << /Im1 47 0 R >> +/ProcSet [ /PDF /Text ] +>> endobj +88 0 obj << +/Length 863 +/Filter /FlateDecode +>> +stream +x??VMS?0??W?(,?iYGZJN??: ?8!??? ???ww%'???t?[?W??O?O?l?$?8R??L1/EY??VX?X?=???.?!z ???kk/??xr????}???]d?r+?1?q}#?,?L +J??|V?:#?50^?+?-?? ^>??n<:9W>{???l????*>?_?+?}??????}D?-?cN???E??~?rR???=?????\y?#9OVy??(???2?R??????bH??L?@Y??d?f?^???h??????c??#]X!?-? ?.wE???@??U???k?k??VP?F?[?????i&.????'LX?T??d????c? +-??6h?`d??{?|?:o??w}???}k?z?ZqC??m?aL??u??5???????r..w1??`? +Ey?a???t??.? ?r?^?????,?G]?UM??]??n??I01-??z????\6????vO?K???? ,??Y?????L?qB9??miA?n(?E?KTY/???D???MQ??}?(?j????? ?? 8?????!hz??=*????s????Wx??????7??* +u??^?/??)???u????)?UTl:??8&??]?=J?W?????*??$s7O-?}??J?????[{? ???]?m??i?zl??????t*:? ??c??????V???? .;???????????X?D9' +??:f?p????R"8?????3~w? !????QB +endstream +endobj +87 0 obj << +/Type /Page +/Contents 88 0 R +/Resources 86 0 R +/MediaBox [0 0 595.276 841.89] +/Parent 63 0 R +/Annots [ 74 0 R 75 0 R 76 0 R 77 0 R 78 0 R 79 0 R 80 0 R 81 0 R 82 0 R 83 0 R 84 0 R ] +>> endobj +85 0 obj << +/Type /XObject +/Subtype /Image +/Width 300 +/Height 115 +/BitsPerComponent 8 +/ColorSpace /DeviceRGB +/Length 103641 +/Filter/FlateDecode +/DecodeParms<> +>> +stream [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/adegenet -r 1106 From noreply at r-forge.r-project.org Fri Apr 5 19:24:26 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Apr 2013 19:24:26 +0200 (CEST) Subject: [adegenet-commits] r1107 - pkg/vignettes Message-ID: <20130405172426.631FD1810A3@r-forge.r-project.org> Author: jombart Date: 2013-04-05 19:24:26 +0200 (Fri, 05 Apr 2013) New Revision: 1107 Modified: pkg/vignettes/adegenet-basics.Rnw Log: removed useless instructions on graph and RBGL Modified: pkg/vignettes/adegenet-basics.Rnw =================================================================== --- pkg/vignettes/adegenet-basics.Rnw 2013-04-05 17:11:31 UTC (rev 1106) +++ pkg/vignettes/adegenet-basics.Rnw 2013-04-05 17:24:26 UTC (rev 1107) @@ -125,14 +125,6 @@ <>= install.packages("adegenet", dep=TRUE) @ -This only installs packages on CRAN. -However, some functions in \textit{adegenet} also use \textit{graph}, developed on Bioconductor, an -alternative package repository. -To install \textit{graph}, type: -<>= -source("http://bioconductor.org/biocLite.R") -biocLite("graph") -@ We can now load the package using: <>= From noreply at r-forge.r-project.org Sat Apr 6 19:24:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 6 Apr 2013 19:24:55 +0200 (CEST) Subject: [adegenet-commits] r1108 - in www: . files Message-ID: <20130406172455.70350184CAD@r-forge.r-project.org> Author: jombart Date: 2013-04-06 19:24:55 +0200 (Sat, 06 Apr 2013) New Revision: 1108 Added: www/files/GenEpiTalk.1.0.pdf Modified: www/documentation.html Log: adding slides talk GenEpi Modified: www/documentation.html =================================================================== --- www/documentation.html 2013-04-05 17:24:26 UTC (rev 1107) +++ www/documentation.html 2013-04-06 17:24:55 UTC (rev 1108) @@ -43,6 +43,7 @@ + engine.


@@ -105,6 +106,7 @@ + 1 [version with all commands]
    > practical @@ -117,6 +119,7 @@ + 2 [version with all commands]
    > practical @@ -129,6 +132,7 @@ + 3

- MRC methodological session: Introduction to phylogenetics:
@@ -156,6 +160,7 @@ + Epidemiology / Public Health: Introduction to phylogenetics.new / Public Health: Introduction to multivariate analysis / bacterial GWAS.Outbreak analysis using ape, adegenet, and + outbreaker new
+     > talk
    > practical
    > data (cases.csv, README new
Added: www/files/GenEpiTalk.1.0.pdf =================================================================== (Binary files differ) Property changes on: www/files/GenEpiTalk.1.0.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From noreply at r-forge.r-project.org Tue Apr 9 14:07:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 9 Apr 2013 14:07:34 +0200 (CEST) Subject: [adegenet-commits] r1109 - www Message-ID: <20130409120734.4D44C184E3B@r-forge.r-project.org> Author: jombart Date: 2013-04-09 14:07:33 +0200 (Tue, 09 Apr 2013) New Revision: 1109 Modified: www/literature.html Log: +3 ref Modified: www/literature.html =================================================================== --- www/literature.html 2013-04-06 17:24:55 UTC (rev 1108) +++ www/literature.html 2013-04-09 12:07:33 UTC (rev 1109) @@ -60,6 +60,7 @@ + the bublisher's website]

@@ -89,6 +90,7 @@ + abstract]

- the paper presenting the spatial @@ -103,6 +105,7 @@ + principal component analysis (sPCA, function spca), global and @@ -120,6 +123,7 @@ + cryptic spatial patterns in genetic variability by a new multivariate method.  Heredity 101: 92-103. doi: @@ -138,6 +142,7 @@ + abstract]

@@ -158,6 +163,7 @@ + simulations of genealoies of haplotypes (haploGen):
Jombart T, Eggo RM, Dodd PJ, Balloux F (2010) @@ -178,6 +184,7 @@ + of Principal Components (DAPC, functions find.clusters @@ -206,6 +213,7 @@ + Behaviour
76: 87-95.

@@ -223,6 +231,7 @@ + Genomics9: 256.
@@ -255,6 +264,7 @@ + marmota.Molecular @@ -266,6 +276,7 @@ + Ecology 18: 1491-1503.

@@ -316,6 +327,7 @@ + australis in North America. Biological Invasions. doi: 10.1007/s10530-010-9699-6.
@@ -470,6 +482,7 @@ + Oct 6. [Epub ahead of print]

[24] SANTOS, H., BURBAN, C., ROUSSELET, J., @@ -485,6 +498,7 @@ + pityocampa, Lepidoptera, Notodontidae). Journal of Evolutionary Biology, no. doi: 10.1111/j.1420-9101.2010.02147.x
@@ -505,6 +519,7 @@ + Vol. Sci. Pap. ICCAT, 65(3): 988-995

[26] Vandewoestijne @@ -518,6 +533,7 @@ + S, Van Dyck H, 2010 Population Genetic @@ -534,6 +550,7 @@ + ONE5(11): e13810. doi:10.1371/journal.pone.0013810
@@ -561,6 +578,7 @@ +
DOI: 10.1007/s10329-010-0232-4

@@ -625,6 +643,7 @@ + tetradactylum: Polynemidae). Molecular Ecology, 20: no. doi: 10.1111/j.1365-294X.2011.05097.x

@@ -647,6 +666,7 @@ + neoformans Variety grubii Multilocus Sequence Types from Thailand Are Consistent with an Ancestral African Origin.
PLoS @@ -901,6 +921,7 @@ + 10.1007/s10709-012-9640-2

[76] Samantha Baldwin, Meeghan Pither-Joyce, Kathryn Wright, @@ -1501,8 +1522,24 @@ with implications for future breeding programmes. Heredity. doi: 10.1038/hdy.2013.9

+ [178] Moreno et al (2013) Genetic characterization of sunflower + breeding resources from Argentina: assessing diversity in key + open-pollinated and composite populations. Plant Genetic + Resources: 1?12 doi:10.1017/S1479262113000075

+ [179] Furlan et al (2013) Dispersal patterns and population + structuring among platypuses, Ornithorhynchus anatinus, + throughout south-eastern Australia. Conservation Genetics. Doi: + 10.1007/s10592-013-0478-7

+ [180] Ord??ez et al (2013) Mixed but not admixed: a spatial + analysis of genetic variation of an invasive ascidian on natural + and artificial substrates. Marine Biology. Doi: + 10.1007/s00227-013-2217-5
+
+
+
+

* adegenet not or wrongly cited, but actually used in the paper.
From noreply at r-forge.r-project.org Wed Apr 10 11:16:28 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 10 Apr 2013 11:16:28 +0200 (CEST) Subject: [adegenet-commits] r1110 - in www: . files Message-ID: <20130410091628.D5FB01851CB@r-forge.r-project.org> Author: jombart Date: 2013-04-10 11:16:28 +0200 (Wed, 10 Apr 2013) New Revision: 1110 Added: www/files/outbreakPractical.1.3.pdf Modified: www/documentation.html Log: last minute update to the tutorial Modified: www/documentation.html =================================================================== --- www/documentation.html 2013-04-09 12:07:33 UTC (rev 1109) +++ www/documentation.html 2013-04-10 09:16:28 UTC (rev 1110) @@ -198,7 +198,7 @@ outbreaker new
    > talk
-     > practical
+     > practical
    > data (cases.csv, alignment.fa, > +endobj +4 0 obj +(Introduction) +endobj +5 0 obj +<< /S /GoTo /D (subsection.1.1) >> +endobj +8 0 obj +(An emerging pathogen outbreak) +endobj +9 0 obj +<< /S /GoTo /D (subsection.1.2) >> +endobj +12 0 obj +(Your objective) +endobj +13 0 obj +<< /S /GoTo /D (section.2) >> +endobj +16 0 obj +(First look at the data) +endobj +17 0 obj +<< /S /GoTo /D (section.3) >> +endobj +20 0 obj +(Phylogenetic analysis) +endobj +21 0 obj +<< /S /GoTo /D (section.4) >> +endobj +24 0 obj +(Identifying clusters of cases) +endobj +25 0 obj +<< /S /GoTo /D (section.5) >> +endobj +28 0 obj +(Analysis using SeqTrack) +endobj +29 0 obj +<< /S /GoTo /D (section.6) >> +endobj +32 0 obj +(Detailed outbreak reconstruction using outbreaker) +endobj +33 0 obj +<< /S /GoTo /D (subsection.6.1) >> +endobj +36 0 obj +(outbreaker analysis) +endobj +37 0 obj +<< /S /GoTo /D (subsection.6.2) >> +endobj +40 0 obj +(Inference from the reconstructed ancestries) +endobj +41 0 obj +<< /S /GoTo /D (section.7) >> +endobj +44 0 obj +(Update from detailed case investigations) +endobj +45 0 obj +<< /S /GoTo /D [46 0 R /Fit ] >> +endobj +55 0 obj << +/Length 1495 +/Filter /FlateDecode +>> +stream +x??WKo?6??W?(1??(????S??a??l?N??Z????w^???? ?R?!g??o8??6??/3??Z??lH?W??,7??se?Ir?????N>????&???>???n?p6K?0i/?@????!?y'??m?5*?????.??~^? X??8??+?C?????V?????xL?QS^???7??v?;???E?u1????.??S???????H_?6'?Od???a? +?f??0????,?W??Y??????HeP?N> ??R;?\??I?$e???????????d???1??^??zc?W??????g6? ??y??`Fu??u'??Am?*?????P?:?e?(???BSr??7???2.???r??H??m??nV?????????1@??:?? >??+f?tC\: ?'????????(?R???j?Jj??????R??CmG?e%y?6$*???pP;??a?'??pe9?OTn??>f??p????????>Kh:?Un)x^gi??v?F> endobj +47 0 obj << +/Type /XObject +/Subtype /Form +/FormType 1 +/PTEX.FileName (/home/thibaut/latex/configPerso/figs/Rlogo.pdf) +/PTEX.PageNumber 1 +/PTEX.InfoDict 64 0 R +/BBox [0 0 101 77] +/Resources << +/Font << /F0 65 0 R>> +/XObject << +/Im0 66 0 R +>>/ProcSet [ /PDF /Text /ImageC ] +>> +/Length 30 +>> +stream +q +101 0 0 77 0 0 cm +/Im0 Do +Q +endstream +endobj +64 0 obj +<< +/CreationDate (D:20040610181518) +/ModDate (D:20040610181518) +/Producer (ImageMagick 6.0.0 04/30/04 Q16 http://www.imagemagick.org) +>> +endobj +65 0 obj +<< +/Type /Font +/Subtype /Type1 +/Name /F0 +/BaseFont /Helvetica +/Encoding /MacRomanEncoding +>> +endobj +66 0 obj +<< +/Type /XObject +/Subtype /Image +/Name /Im0 +/Filter [/FlateDecode] +/Width 101 +/Height 77 +/ColorSpace 67 0 R +/BitsPerComponent 8 +/Length 68 0 R +>> +stream +x??|Xi?6??n????6???b??"(E????{OB?J????{GT?!B2?? ???????????u??&C???s????#+6==:++6P??????Q?[jjd|?1,? 6h~$2??????X?22w}??g~!z_h??"????????*? ??(?SwO?????:D?i?+.?? ?B?8??4??**<(4?/$?7???O????xw7?????B??,???Y?????s?L^tf??i????!??E?????q'&X .?9???5?????M + at T^?UZ?VU? VZ?p?}[????????]3?)==6!6"&2?1"??L:5?N ????????`?kLD(XtxXTXhd(|302, :??????????????x0??c??!????I&y??????x??'????????X1??^.?Y?l?%????????or? +4{???NDP???H???_????+????o(j~Y??TR[W???<$g +??B%???????x???O^^?nn?????????????????????`??j??a??????? +?DG?cc?cc?11?11AT* +??????rwwrsstr?us?y??gf?0F??4??? #????A??.?3rf??L?0d0?>|h}????9????^U?'64?K?0>~?o/*N?R]?????????M??qk???F ???GS?b?#??A!>T?????`j?h`f??g????TQ???????#)???H<?????D??c?{???SR?T??30R??6 ?ZSin!a? h?A!?4_ +??J!?o???[Y???Y::???^y?YC?}?|Mr???z?)???u7??E??$?d?f89??????????????J?????????????????-??1?@kk}++ccM =??@???? +???????0??????????????????b?o \?z??????w:????????8xd?????{??????>????C'?=}????'?? ]yx???U5%#Cg';_??G + ???x??lm,?m--??t?-?M#CC?Z_s&gri68?L ??????u??????OC??rX??????ji??-ki???|??????~x???*???bl????h`???D??L????Lv??????6H ??nNx]cM%)?;W?_N??P??????????nn?}??nr????;H?A???T?Q`????!?n?;? +^0p??0????????l?m=???E ????>???8?????]?j??-;/??0??pp????????u???kd????M=\l\?6jj +V?&j????M?u??????0?L?9;q?R?)??NL??*??@?Z[??~p at Pl##-Q?;w?\??y???II?<??? ?v???????$)!v???-?7?????,Y0?g?x???9:8?b??#P???LL??]???66?yyJ=??(x????.?9u?h???Gn?x&)???hkehi?oj???"???;{?????c@???3D?a???W??????|@|??A????????+?8`%"rCB?\/?i?E9?z:?2?3o?????QWS?$x~??M??AQ???9??,????????^u??P? ?tCI??@??xy??L=Mx6??[O??????'??h]3g??`q>3G?l ???????[?n +?;w?????7?^????31=mggk} +0u +?'??F??\@3P?/??Y. ?6 A??u-?ySS???g????F??wED????3??????????(?l/?P?????V.?~?????????C??????H????N???@Xld???f??x??????^0?$:???`????y????x?????= ??:"?? ? +tg?D?}y????999???.??u??????? >???"cmcbna??? ????71?omk?%g+??|? ??i???^?V?_VO? _?$%?[X??????X??Lb?Yi????.?o??`?O??av??????G??q???? ?#?G?Q62?F:??????82?=??hh????i:?25????|S?P +?????nFUQ??p??3??????Z[??? p?A?HJ?54?9~????k1R??7??~?j???4??H???y???o?!?m?????e]i???{3??? +?? +?2K>fw????(??^??Z????1??'??7??+)????PK/??Z???%?Y??????????????QM???????R?|'?????Az?ch,x???BUIFV"????????? y))?G?4??8?`?,??M[mum?P? |(-????}????k??????#S?P??~?r??XiI????????kVaX?Z?j???eee?FFF?\?.?O? )?7??? +?~i??t?"??.?Q???|b ? > ncH?Gz?????g???0?~??~??N??q5???6v ?5??????:?????????eKH?rN?pL0???6 ?4 +V7 +???}???H?LB?[?8??1??F |i?????T7????w??f"???#6???CGW??D??4???|?l???5u?E%??????`???bb?n??h???????????? +??`ff&?k:??????-??-kll@ ?U???=??c-???-?\?5??B9m??!Y????(??a??Q??M?'5?&?)??c{R??]Z7RR?(??-??)??S:?^????9?t??f????q?"??Q??~???;??;r??%IY{#?Pr at ep|kH?;RP=?\?J?t??q?*???o"????//?R??.X?t????2?*?2?U??^?KKJ??>|".????g !?x?????G:y^t?????????V.???9f?tk?{?J'??;8?jOJ??o? -??U9?G?.?dgM?fJg?%A?"?B PZ?????UT??????,5-.)%2-#??N'A????76???)UU??????.NODwl?????}????????-_?e?V?? ??zx?:~???3????/?????S??s??[ ?E?o??5y?H?z&?B????}??eo/??1\o k??(+/ ??? @- ?LH?NH +OM??+H?R???"??d??,M????)??????N?6????+???0,.?????!?????8#x??????)?U]] VQQ???fog)p? ? ???g??????????????ei???E +y????P????CB{?;u?26??b???r?Wl+6???# +eF?^(???????0?@)??,???sl\+H???-?- ???m??U?-?g.Mu#.:????????8?S?h~$???]?PdIi~Tthx?l|Pn~R`??????*??WhHVZ????jkc~????~??r???k??z???9?W??tJ?s-t?6???K?6?@?D????7_??????;???c???cs????????F\????q?"?-?fQ???V1???????6?&??Vr?;zDGhl??}??UE????4??S???DzF??????R^?Vh?3FD?}B????????O???x??\???eeyE?9?E??FW?l????????????tL}?????h????UM??????}???C??n?s&?.?7?09::??Mr???It???Ap?i.?b{???L??d??t??-p%?ohgx\wdb??u?9??[?????????o???eO??fef?????T???=????_w?@/???YIu5e{+pF? ?U????????~?????Vm??r????-???????????[?B????p?p ?g?b?]*;?m?t?????(??zS????}?,?\??????*c??A????t,S?=+I??????????N}???g?7n>?g?y 3??1?5?????l??;?y?.G'] +???X????P?O?s`??_?Gff????????????Qdd at nnr~~:`?????hy???m??vl??tpC}-69?d2x??S???"c?p??M???in`g????????????m????8u??]?8Z?????rMb9 ??9??`Ou??B?l~? ?k1?E4??E??i??EZ??w?%???????Vr?6"a /???o?~q???[????a:?= <AF!%??? ??N??5???K%?Z;?-?T??Htt4????j?Bq???? -%9?E!{A?*(p???}????to?8???S_?dLw??+g?B??r?|J??;HAm???DZ? +????=$tGD??3 1???????\^^15????3????5?????C?G+\????Gw?rjxcRAoi#??????t???e???\?c???o^w\??c?7?A??P??;??Y`??\=?nN???f???D__7???L???,(???????R???3?? \<{I?|Lt?LS??D?????N?Qg4qNv?-^???W??r-? Eu?:$5=??????????S?:???g???$7??|??,?????6=?M^I{iUgO?:w??jRM?GB?^??b?M?-?oe?!?}??w?9??+??]??????P?A\????????}d???4+&6TO_??0?96<(XdT????????????3?? n???88XP(??? ?? ?`^?.?U?\?zE???c?Zj3?Q??,??????).G.w??9zV????^EN9?????(U?????#?A??[Bb??;???Rr:cS[Sr???b?? ?q??.?4??Sq?1%??G??s?QB?????k7????????.Y{????]?3?N??]???? x?? UE?0Yc?"`?imtqu06?13???3? ????b^^??H:WzZbLtX`?'???yE???{woFG?a?X366???????5?????G?v?(????)??5O???+'7D?M/??H/??U??V??W?]?2????W~??}??a?d???? +}??-U4 ^??????c??8J??????UZ? ??9?l????C??rF-?s:??????????^p?????M\?????y????????Be??l???J$;7Wgz?/hWvVjx="<(?????$"| J???? ?}?????v???kv"p??58?j?K???_??;X??i??k???q?@$w?|??) ?????S>||?k???\f?I ???A2?[IQ@ST????p?Too?? ??????????X?HD??? ???????U?Hd????????Q??7??J?M?c?h?K?.?.`??_?_???????????~&*;??HE#7?x4?p8?h?g ???>AMN? + ?|k|??c??S1??.!k??ilGL??v?2?&?9???]????||????p??????78??? +}nkm?? ???06?? g??1???Q^ ??x????\EY@SV?SV?uv?g???4 +?dLLHTT`X0??`?????*????H??????'t????_?L??,?J??v?yz4??w??"=#hg??d4E8?DC?3??trO!??Bk???%? +D???G?????|?Z???)"?/?????????]??????5g?????y??w?????]X???p^???????l(?u?4??2f?F?1?fT?b2??m.RQVnbl(.?@NVZZ?1???ky??f?????????11Aq?A?/?c!?UV???D??cK+'g[?A?Tu??(?Q{`fd????2vJ?S*?!??R>5?"?M??=.??s???:???}?7??s?????.?]???cF????E????E?v???? +J??????bp?????W???????!xE8$<?g?7?c?3Y?<?`???GD????k< +?c +$???? BxS]?? ??\RT???%"|???{*??????w P??tX'%???????P??;X???w?1??HEeqtL????t ???^??$?? ?????? @?d210 +?tt???>???/)?HK????1$c~~^aa??t???(?)TOGKE??&??Z?? + 5??u???+1?? 1? ?3p?Y??]PQ??$???3??vH??.Y?$???|?h???K?Bn?x?o?6??u??'^????Gs$????H5.????O??7N?R1?C????S?0p??'?5?9S?Jp??L?:Z?????J8PC#??????^???QdV???1v????? ??#????J?rw???x" +)??#pL??\]?P???????S""??^x@?????XCS[ ?C#????4?1?n[8??Q??g????\??I?????VSW?????F???=G?@???v???p??????p??G???g%?77}?j?4m3?????K at BZ?p???????_(?dc???GOM??qf"????a7o^?T???????rE???;????3????Fn_w?XP??m?? +o\??m????????$??#??-??)???D |?j?g?U?v?:y????l`???c??<.????>5 ????&??4MC???$d?{?Y?f?Z??[':K?1H?q????e,_??U????;?,K\?%>??!C?,A?"??nM??E????????????f0Gy?=?Y????|?????`9`?ut????1??cG?yF03? 7?/+'=1%6+7%-;???<61???9*!GM?????is +O???bb?_?'UZ??:??:f??Vx?j?=zj~?????Azn%db\C???Z??I?????=? ??y? ???L?????YZ?????y????????q??????????%r??C?{?rR?T??:Qi??P?_?_x8? +!?????/?$?????r6\g?\w??y??%@&>1.!9&1%:?0-'?-#7??????>????,?hr????8-S?D?|?????????????5"?? +??3?????tlX???????????P?[?f??-3R?M3??)????zccC??O?p??????};wm=rt????+?^?{???SIU-# ?o??h???Fm???o??j:&???+2???/]MNO?????I??I?/JO?J,?,**)??%???Xe ++Eu????????d?????#UC>f??c?Z??^?T???}??h???'???l??????>(?? ??????v~h RT??p??????k??;???? 6??m???C???U???5a + 9c%53?iFF?????46??"??w}????4???WRZ??C|?L????????g??????????????\?m?)JP>H? +??]k?Q +y??]??S??_ +9?54?SH?/Z??;?w?????Sg???>?r???BW?^?$tV??????<{???3?6m?{(??????? +?H+B?Rf??a?R?'?:?1{??6?i2/\n=?z?DWN?xp????@M????jU?W?_Yf7??Ptpp????N????  +m????%a(?.+\?w?+HS?]?V???T`??A??b:?]?????o?s???u?m???}??U?6??? +x?a??m? +?,??S?2>v????????????cE{ +k?4{?c? {? +?*gJ-??K??k6?\?k?@???}????h?? ??L?kZ?9??e????i#?????/zK7P??? +???56?d?U??rm ???g?K^;?TsB?G@???%t[e?!?'?\???????lfaRS[14?????e8?1?&TH??~"k ??$?????????{????+b??r3\&?R?@??? ,?#)m ?D???1d??????????D+w,?????S??b??c?'0??9???????@???B??l=???M1?a ]???n???????u??+7??&S???)??!??,?? +}??(??G4?????????T??{???*umS?]??*j?[bh?-???y8r????=Q?'?w?B?fZ?x59= ?o????L3g???Kp??Z sca G??x?u??$??>?'uF(U??????2?? j??U???O^~????m?uv?????M?z??L?9lP`t?*I?*?Q?W?y?? +3rH?h??y???V1??A???????I????j>SUR???????????;?pf^??-3?????%?????eb?Hj???h?%?tW???@????^??q" ?J??"???[w??rwE?Yl?>??????s9???0???^&?(??<}n/??$&?`??i????R????C>? ????ZF\?{jh??%MDLKTL]??rXh???M?Nl???????L???????V???N)??j0jqplcny^??????????V|?5????????]q6?Bx??W^?5???F2??H?J?I?93??a??S?~??????8??O?5%?_y???2\?6???????4??=?H  ????D??!?? _:??$? +F + + +??F??C?D?H????=> ???H??}?#??BQ ?????AAa?$Z)?N?FD????????\?8kr??G?????1@???{???9??6&??:q9 ?`??l0??alsf +~.??A?_a????F??0???[??I}Q???4:0}???p?W+? +??N?????/? ?-??t +endstream +endobj +67 0 obj +/DeviceRGB +endobj +68 0 obj +15973 +endobj +48 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [260.916 500.94 268.363 509.958] +/A << /S /GoTo /D (cite.np145) >> +>> endobj +49 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [325.498 487.391 332.945 496.408] +/A << /S /GoTo /D (cite.tjart20) >> +>> endobj +50 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [414.193 487.391 421.64 496.408] +/A << /S /GoTo /D (cite.outbreaker) >> +>> endobj +51 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [333.158 460.292 340.605 469.31] +/A << /S /GoTo /D (cite.tj527) >> +>> endobj +52 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [131.01 446.743 138.457 455.761] +/A << /S /GoTo /D (cite.tjart05) >> +>> endobj +53 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[0 1 0] +/Rect [233.562 433.194 241.009 442.212] +/A << /S /GoTo /D (cite.outbreaker) >> +>> endobj +56 0 obj << +/D [46 0 R /XYZ 69.866 808.885 null] +>> endobj +57 0 obj << +/D [46 0 R /XYZ 70.866 771.024 null] +>> endobj +54 0 obj << +/Font << /F26 58 0 R /F53 59 0 R /F8 60 0 R /F60 61 0 R /F70 62 0 R >> +/XObject << /Im1 47 0 R >> +/ProcSet [ /PDF /Text ] +>> endobj +88 0 obj << +/Length 863 +/Filter /FlateDecode +>> +stream +x??VMS?0??W?(,?iYGZJN??: ?8!??? ???ww%'???t?[?W??O?O?l?$?8R??L1/EY??VX?X?=???.?!z ???kk/??xr????}???]d?r+?1?q}#?,?L +J??|V?:#?50^?+?-?? ^>??n<:9W>{???l????*>?_?+?}??????}D?-?cN???E??~?rR???=?????\y?#9OVy??(???2?R??????bH??L?@Y??d?f?^???h??????c??#]X!?-? ?.wE???@??U???k?k??VP?F?[?????i&.????'LX?T??d????c? +-??6h?`d??{?|?:o??w}???}k?z?ZqC??m?aL??u??5???????r..w1??`? +Ey?a???t??.? ?r?^?????,?G]?UM??]??n??I01-??z????\6????vO?K???? ,??Y?????L?qB9??miA?n(?E?KTY/???D???MQ??}?(?j????? ?? 8?????!hz??=*????s????Wx??????7??* +u??^?/??)???u????)?UTl:??8&??]?=J?W?????*??$s7O-?}??J?????[{? ???]?m??i?zl??????t*:? ??c??????V???? .;???????????X?D9' +??:f?p????R"8?????3~w? !????QB +endstream +endobj +87 0 obj << +/Type /Page +/Contents 88 0 R +/Resources 86 0 R +/MediaBox [0 0 595.276 841.89] +/Parent 63 0 R +/Annots [ 74 0 R 75 0 R 76 0 R 77 0 R 78 0 R 79 0 R 80 0 R 81 0 R 82 0 R 83 0 R 84 0 R ] +>> endobj +85 0 obj << +/Type /XObject +/Subtype /Image +/Width 300 +/Height 115 +/BitsPerComponent 8 +/ColorSpace /DeviceRGB +/Length 103641 +/Filter/FlateDecode +/DecodeParms<> +>> +stream [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/adegenet -r 1110 From noreply at r-forge.r-project.org Fri Apr 12 16:17:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 12 Apr 2013 16:17:53 +0200 (CEST) Subject: [adegenet-commits] r1111 - pkg/R Message-ID: <20130412141753.D573F183FDE@r-forge.r-project.org> Author: jombart Date: 2013-04-12 16:17:53 +0200 (Fri, 12 Apr 2013) New Revision: 1111 Modified: pkg/R/haploGen.R Log: Fixed haploGen bug -- see below: Dear Haiyin, sorry for the late reply, but I was in various meetings / workshop over the past days. This is a bug, thanks for reporting it. Please find attached a patch fixing it. It will be in adegenet's next release (1.3-8). Best Thibaut -- ###################################### Dr Thibaut JOMBART MRC Centre for Outbreak Analysis and Modelling Department of Infectious Disease Epidemiology Imperial College - School of Public Health St Mary?\226?\128?\153s Campus Norfolk Place London W2 1PG United Kingdom Tel. : 0044 (0)20 7594 3658 t.jombart at imperial.ac.uk http://sites.google.com/site/thibautjombart/ http://adegenet.r-forge.r-project.org/ ________________________________________ From: Chen, Haiyin [chen63 at llnl.gov] Sent: 09 April 2013 06:22 To: Jombart, Thibaut Subject: question on haploGen Hi Dr. Jombart, I am trying to use haploGen by following the example on seqTrack here: http://www.inside-r.org/packages/cran/adegenet/docs/plotSeqTrack But when I specified seq.length=1e4, I am getting a result with length 1e8. When I specified seq.length=1e3, I am getting sequences of length 1e6. It appears that the function is generating sequences that are squares of the specified length: dat=haploGen(seq.length=56,mu.transi=1e-3,mu.transv=5e-4,repro=function( {sample(1:4,1)},gen.time=1,t.max=3) > dim(dat$seq) [1] 20 3136 > 56*56 [1] 3136 Furthermore, it appears dat$seq is 56 identical copies of a 56-bp sequence. Is this expected behavior? Thanks for your help. Haiyin Modified: pkg/R/haploGen.R =================================================================== --- pkg/R/haploGen.R 2013-04-10 09:16:28 UTC (rev 1110) +++ pkg/R/haploGen.R 2013-04-12 14:17:53 UTC (rev 1111) @@ -233,8 +233,7 @@ ## PERFORM SIMULATIONS - NON SPATIAL CASE ## if(!geo.sim){ ## initialization - res$seq <- as.matrix(seq.gen()) - res$seq <- matrix(rep(res$seq, ini.n), byrow=TRUE, nrow=ini.n) + res$seq <- matrix(rep(seq.gen(), ini.n), byrow=TRUE, nrow=ini.n) class(res$seq) <- "DNAbin" rownames(res$seq) <- 1:ini.n res$dates[1:ini.n] <- rep(0,ini.n) @@ -270,8 +269,7 @@ } ## initialization - res$seq <- as.matrix(seq.gen()) - res$seq <- matrix(rep(res$seq, ini.n), byrow=TRUE, nrow=ini.n) + res$seq <- matrix(rep(seq.gen(), ini.n), byrow=TRUE, nrow=ini.n) class(res$seq) <- "DNAbin" rownames(res$seq) <- 1:ini.n res$dates[1:ini.n] <- rep(0,ini.n) From noreply at r-forge.r-project.org Wed Apr 17 13:23:48 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Apr 2013 13:23:48 +0200 (CEST) Subject: [adegenet-commits] r1112 - www Message-ID: <20130417112348.CC217183D75@r-forge.r-project.org> Author: jombart Date: 2013-04-17 13:23:48 +0200 (Wed, 17 Apr 2013) New Revision: 1112 Modified: www/literature.html Log: +4 ref Modified: www/literature.html =================================================================== --- www/literature.html 2013-04-12 14:17:53 UTC (rev 1111) +++ www/literature.html 2013-04-17 11:23:48 UTC (rev 1112) @@ -61,6 +61,7 @@ + the bublisher's website]

@@ -91,6 +92,7 @@ + abstract]

- the paper presenting the spatial @@ -106,6 +108,7 @@ + principal component analysis (sPCA, function spca), global and @@ -124,6 +127,7 @@ + cryptic spatial patterns in genetic variability by a new multivariate method.  Heredity 101: 92-103. doi: @@ -143,6 +147,7 @@ + abstract]

@@ -164,6 +169,7 @@ + simulations of genealoies of haplotypes (haploGen):
Jombart T, Eggo RM, Dodd PJ, Balloux F (2010) @@ -185,6 +191,7 @@ + of Principal Components (DAPC, functions find.clusters @@ -214,6 +221,7 @@ + Behaviour
76: 87-95.

@@ -232,6 +240,7 @@ + Genomics9: 256.
@@ -265,6 +274,7 @@ + marmota.Molecular @@ -277,6 +287,7 @@ + Ecology 18: 1491-1503.

@@ -328,6 +339,7 @@ + australis in North America. Biological Invasions. doi: 10.1007/s10530-010-9699-6.
@@ -483,6 +495,7 @@ + Oct 6. [Epub ahead of print]

[24] SANTOS, H., BURBAN, C., ROUSSELET, J., @@ -499,6 +512,7 @@ + pityocampa, Lepidoptera, Notodontidae). Journal of Evolutionary Biology, no. doi: 10.1111/j.1420-9101.2010.02147.x
@@ -520,6 +534,7 @@ + Vol. Sci. Pap. ICCAT, 65(3): 988-995

[26] Vandewoestijne @@ -534,6 +549,7 @@ + S, Van Dyck H, 2010 Population Genetic @@ -551,6 +567,7 @@ + ONE5(11): e13810. doi:10.1371/journal.pone.0013810
@@ -579,6 +596,7 @@ +
DOI: 10.1007/s10329-010-0232-4

@@ -644,6 +662,7 @@ + tetradactylum: Polynemidae). Molecular Ecology, 20: no. doi: 10.1111/j.1365-294X.2011.05097.x

@@ -667,6 +686,7 @@ + neoformans Variety grubii Multilocus Sequence Types from Thailand Are Consistent with an Ancestral African Origin.
PLoS @@ -922,6 +942,7 @@ + 10.1007/s10709-012-9640-2

[76] Samantha Baldwin, Meeghan Pither-Joyce, Kathryn Wright, @@ -1537,9 +1558,30 @@ and artificial substrates. Marine Biology. Doi: 10.1007/s00227-013-2217-5

+ [181] Hagell, S., Whipple, A. V. and Chambers, C. L. (2013), + Population genetic patterns among social groups of the + endangered Central American spider monkey (Ateles geoffroyi) in + a human-dominated landscape. Ecology and Evolution. doi: + 10.1002/ece3.547

+ [182] Vignaud T, Clua E, Mourier J, Maynard J, Planes S (2013) + Microsatellite Analyses of Blacktip Reef Sharks (Carcharhinus + melanopterus) in a Fragmented Environment Show Structured + Clusters. PLoS ONE 8(4): e61067. + doi:10.1371/journal.pone.0061067

+ [183] Horne et al. (2013) Observations of Migrant Exchange and + Mixing in a Coral Reef Fish Metapopulation Link Scales of Marine + Population Connectivity. Journal of Heredity. doi: + 10.1093/jhered/est021

+ [184] Garroway et al. (2013) FINE-SCALE GENETIC STRUCTURE IN A + WILD BIRD POPULATION: THE ROLE OF LIMITED DISPERSAL AND + ENVIRONMENTALLY-BASED SELECTION AS CAUSAL FACTORS. Evolution. + DOI: 10.1111/evo.12121
+
+
+

* adegenet not or wrongly cited, but actually used in the paper.
From noreply at r-forge.r-project.org Wed Apr 24 19:08:08 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 24 Apr 2013 19:08:08 +0200 (CEST) Subject: [adegenet-commits] r1113 - in pkg: . R man Message-ID: <20130424170808.D227D184C54@r-forge.r-project.org> Author: greatsage Date: 2013-04-24 19:08:08 +0200 (Wed, 24 Apr 2013) New Revision: 1113 Modified: pkg/DESCRIPTION pkg/R/dapc.R pkg/man/adegenet.package.Rd pkg/man/dapc.Rd Log: Package: adegenet Version: 1.3-8 Date: 2013/04/24 Title: adegenet: an R package for the exploratory analysis of genetic and genomic data. Author: Thibaut Jombart, Ismail Ahmed, Federico Calboli, Anne Cori, Tobias Erik Reiners, Peter Solymos Maintainer: Thibaut Jombart Suggests: genetics, spdep, tripack, pegas, seqinr, adehabitat, multicore, akima, maps, splancs, hierfstat Depends: R (>= 2.10), methods, MASS, ade4, igraph, ape Description: Classes and functions for genetic data analysis within the multivariate framework. Collate: classes.R basicMethods.R handling.R auxil.R setAs.R SNPbin.R glHandle.R glFunctions.R glSim.R find.clust.R hybridize.R scale.R fstat.R import.R seqTrack.R chooseCN.R genind2genpop.R loadingplot.R sequences.R gstat.randtest.R makefreq.R colorplot.R monmonier.R spca.R coords.monmonier.R haploGen.R old2new.R spca.rtests.R dapc.R haploPop.R PCtest.R dist.genpop.R Hs.R propShared.R export.R HWE.R propTyped.R inbreeding.R glPlot.R gengraph.R simOutbreak.R mutations.R zzz.R License: GPL (>=2) LazyLoad: yes Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-04-17 11:23:48 UTC (rev 1112) +++ pkg/DESCRIPTION 2013-04-24 17:08:08 UTC (rev 1113) @@ -1,12 +1,12 @@ Package: adegenet -Version: 1.3-7 -Date: 2013/04/05 +Version: 1.3-8 +Date: 2013/04/24 Title: adegenet: an R package for the exploratory analysis of genetic and genomic data. -Author: Thibaut Jombart, Ismail Ahmed, Anne Cori, Tobias Erik Reiners, Peter Solymos +Author: Thibaut Jombart, Ismail Ahmed, Federico Calboli, Anne Cori, Tobias Erik Reiners, Peter Solymos Maintainer: Thibaut Jombart Suggests: genetics, spdep, tripack, pegas, seqinr, adehabitat, multicore, akima, maps, splancs, hierfstat Depends: R (>= 2.10), methods, MASS, ade4, igraph, ape Description: Classes and functions for genetic data analysis within the multivariate framework. -Collate: classes.R basicMethods.R handling.R auxil.R setAs.R SNPbin.R glHandle.R glFunctions.R glSim.R find.clust.R hybridize.R scale.R fstat.R import.R seqTrack.R chooseCN.R genind2genpop.R loadingplot.R sequences.R gstat.randtest.R makefreq.R colorplot.R monmonier.R spca.R coords.monmonier.R haploGen.R old2new.R spca.rtests.R dapc.R dapcXval.R haploPop.R PCtest.R dist.genpop.R Hs.R propShared.R export.R HWE.R propTyped.R inbreeding.R glPlot.R gengraph.R simOutbreak.R mutations.R zzz.R +Collate: classes.R basicMethods.R handling.R auxil.R setAs.R SNPbin.R glHandle.R glFunctions.R glSim.R find.clust.R hybridize.R scale.R fstat.R import.R seqTrack.R chooseCN.R genind2genpop.R loadingplot.R sequences.R gstat.randtest.R makefreq.R colorplot.R monmonier.R spca.R coords.monmonier.R haploGen.R old2new.R spca.rtests.R dapc.R haploPop.R PCtest.R dist.genpop.R Hs.R propShared.R export.R HWE.R propTyped.R inbreeding.R glPlot.R gengraph.R simOutbreak.R mutations.R zzz.R License: GPL (>=2) LazyLoad: yes Modified: pkg/R/dapc.R =================================================================== --- pkg/R/dapc.R 2013-04-17 11:23:48 UTC (rev 1112) +++ pkg/R/dapc.R 2013-04-24 17:08:08 UTC (rev 1113) @@ -986,14 +986,30 @@ ## ############ ## ## crossval ## ############ -## crossval <- function (x, ...) UseMethod("crossval") +#xval <- function (x, ...) UseMethod("xval") -## crossval.dapc <- function(){ +xval.dapc <- function(object, n.pca, n.da, training.set = 90){ + training.set = training.set/100 + kept.id <- unlist(tapply(1:nInd(object), pop(object), function(e) {pop.size = length(e); pop.size.train = round(pop.size * training.set); sample(e, pop.size.train, replace=FALSE)})) + training <- object[kept.id] + validating <- object[-kept.id] + post = vector(mode = 'list', length = n.pca) + asgn = vector(mode = 'list', length = n.pca) + ind = vector(mode = 'list', length = n.pca) + mtch = vector(mode = 'list', length = n.pca) + for(i in 1:n.pca){ + dapc.base = dapc(training, n.pca = i, n.da = 15) + dapc.p = predict.dapc(dapc.base, newdata = validating) + match.prp = mean(as.character(dapc.p$assign)==as.character(pop(validating))) + post[[i]] = dapc.p$posterior + asgn[[i]] = dapc.p$assign + ind[[i]] = dapc.p$ind.score + mtch[[i]] = match.prp + } + res = list(assign = asgn, posterior = post, ind.score = ind, match.prp = mtch) + return(res) +} # end of xval.dapc -## } - - - ## ############### ## ## randtest.dapc ## ############### Modified: pkg/man/adegenet.package.Rd =================================================================== --- pkg/man/adegenet.package.Rd 2013-04-17 11:23:48 UTC (rev 1112) +++ pkg/man/adegenet.package.Rd 2013-04-24 17:08:08 UTC (rev 1113) @@ -190,14 +190,14 @@ \tabular{ll}{ Package: \tab adegenet\cr Type: \tab Package\cr - Version: \tab 1.3-7\cr - Date: \tab 2013-04-05 \cr + Version: \tab 1.3-8\cr + Date: \tab 2013-04-24 \cr License: \tab GPL (>=2) } } \author{ Thibaut Jombart \cr - Developpers: Ismail Ahmed , Tobias Erik Reiners, Peter Solymos, Anne Cori\cr + Developpers: Ismail Ahmed , Federico Calboli ,Tobias Erik Reiners, Peter Solymos, Anne Cori\cr and contributed datasets from: Katayoun Moazami-Goudarzi, Denis Lalo?, Dominique Pontier, Daniel Maillard, Francois Balloux. } Modified: pkg/man/dapc.Rd =================================================================== --- pkg/man/dapc.Rd 2013-04-17 11:23:48 UTC (rev 1112) +++ pkg/man/dapc.Rd 2013-04-24 17:08:08 UTC (rev 1113) @@ -9,6 +9,7 @@ \alias{print.dapc} \alias{summary.dapc} \alias{predict.dapc} +\alias{xval.dapc} \alias{as.lda} \alias{as.lda.dapc} \title{Discriminant Analysis of Principal Components (DAPC)} @@ -36,7 +37,8 @@ - \code{print.dapc}: prints the content of a \code{dapc} object.\cr - \code{summary.dapc}: extracts useful information from a \code{dapc} object.\cr - - \code{predict.dapc}: predicts group memberships based on DAPC results. + - \code{predict.dapc}: predicts group memberships based on DAPC results.\cr + - \code{xval.dapc}: performs cross-validation of DAPC function varying the number of PCs and keeping the number of DAs fixed. DAPC implementation calls upon \code{\link[ade4]{dudi.pca}} from the @@ -73,6 +75,8 @@ \method{predict}{dapc}(object, newdata, prior = object$prior, dimen, method = c("plug-in", "predictive", "debiased"), ...) + +\method{xval}{dapc}(object, n.pca, n.da, training.set = 90) } \arguments{ \item{x}{\code{a data.frame}, \code{matrix}, or \code{\linkS4class{genind}} @@ -132,6 +136,10 @@ original ('training') data. In particular, variables must be exactly the same as in the original data. For \linkS4class{genind} objects, see \code{\link{repool}} to ensure matching of alleles.} + \item{training.set}{the percentage of individuals randomly chosen in each population + as the training set used for cross-validation. This value is applied to all groups/pops + defined in the object. The default is set to 90\%. + For meaningful cross-validation it is recommended not to go below 80\%} \item{prior,dimen,method}{see \code{?predict.lda}.} } \details{ @@ -172,6 +180,8 @@ \item{var.contr}{(optional) a data.frame giving the contributions of original variables (alleles in the case of genetic data) to the principal components of DAPC.} + \item{match.prp}{a list, where each item is the proportion of individuals + correctly matched to their original population in cross-validation.} === other outputs ===\cr @@ -181,7 +191,11 @@ \code{assign.prop} (proportion of overall correct assignment), \code{assign.per.pop} (proportion of correct assignment per group), \code{prior.grp.size} (prior group sizes), and \code{post.grp.size} (posterior - group sizes). + group sizes), \code{xval.dapc} (returns a list of four lists, each one with as + many items as cross-validation runs. The first item is a list of \code{assign} components, + the secon is a list of \code{posterior} components, the thirs is a list of \code{ind.score} + components and the fourth is a list of \code{match.prp} items, i.e. the prortion of the validation + set correctly matched to its original population) } \references{ Jombart T, Devillard S and Balloux F (2010) Discriminant analysis of @@ -291,8 +305,28 @@ ## image using compoplot compoplot(dapc1, new.pred=hyb.pred, ncol=2) title("30 indiv popA, 30 indiv pop B, 30 hybrids") + +## CROSS-VALIDATION ## +# select dataset +data(microbov) +summary(microbov) # the dataset contains 15 populations of different sizes + +# we take a fixed number of disriminant functions (15 in this case) +# and we test how the cross-validation does varying the number of PCs +# we specify the *maximum* number of PCs, and we will test how +# the cross-validation performs by going from 1 PC to the maximum +# we specified in the fucntion call + +crossval.test <- xval.dapc(microbov, n.pca = 40, n.da = 15, training.set = 90) + +attributes(crossval.test) # we get four lists of lists +# namely "assign" "posterior" "ind.score" "match.prp" +# a quick visual inspection of the cross-validation + +plot(unlist(crossval.test$match.prp)) + } } -\keyword{multivariate} \ No newline at end of file +\keyword{multivariate} From noreply at r-forge.r-project.org Wed Apr 24 20:44:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 24 Apr 2013 20:44:43 +0200 (CEST) Subject: [adegenet-commits] r1114 - pkg/R Message-ID: <20130424184443.95C8B184B5F@r-forge.r-project.org> Author: greatsage Date: 2013-04-24 20:44:43 +0200 (Wed, 24 Apr 2013) New Revision: 1114 Removed: pkg/R/dapcXval.R Log: deleted file ... Deleted: pkg/R/dapcXval.R =================================================================== --- pkg/R/dapcXval.R 2013-04-24 17:08:08 UTC (rev 1113) +++ pkg/R/dapcXval.R 2013-04-24 18:44:43 UTC (rev 1114) @@ -1,1027 +0,0 @@ -####### -## dapc -######## -dapc <- function (x, ...) UseMethod("dapc") - -################### -## dapc.data.frame -################### -dapc.data.frame <- function(x, grp, n.pca=NULL, n.da=NULL, - center=TRUE, scale=FALSE, var.contrib=TRUE, pca.info=TRUE, - pca.select=c("nbEig","percVar"), perc.pca=NULL, ..., dudi=NULL){ - - ## FIRST CHECKS - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") - grp <- as.factor(grp) - if(length(grp) != nrow(x)) stop("Inconsistent length for grp") - pca.select <- match.arg(pca.select) - if(!is.null(perc.pca) & is.null(n.pca)) pca.select <- "percVar" - if(is.null(perc.pca) & !is.null(n.pca)) pca.select <- "nbEig" - if(!is.null(dudi) && !inherits(dudi, "dudi")) stop("dudi provided, but not of class 'dudi'") - - - ## SOME GENERAL VARIABLES - N <- nrow(x) - REDUCEDIM <- is.null(dudi) - - if(REDUCEDIM){ # if no dudi provided - ## PERFORM PCA ## - maxRank <- min(dim(x)) - pcaX <- dudi.pca(x, center = center, scale = scale, scannf = FALSE, nf=maxRank) - } else { # else use the provided dudi - pcaX <- dudi - } - cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig) - - if(!REDUCEDIM){ - myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$li),length(pcaX$eig))) - } else { - myCol <- "black" - } - - ## select the number of retained PC for PCA - if(is.null(n.pca) & pca.select=="nbEig"){ - plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) - cat("Choose the number PCs to retain (>=1): ") - n.pca <- as.integer(readLines(n = 1)) - } - - if(is.null(perc.pca) & pca.select=="percVar"){ - plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) - cat("Choose the percentage of variance to retain (0-100): ") - nperc.pca <- as.numeric(readLines(n = 1)) - } - - ## get n.pca from the % of variance to conserve - if(!is.null(perc.pca)){ - n.pca <- min(which(cumVar >= perc.pca)) - if(perc.pca > 99.999) n.pca <- length(pcaX$eig) - if(n.pca<1) n.pca <- 1 - } - - - ## keep relevant PCs - stored in XU - X.rank <- sum(pcaX$eig > 1e-14) - n.pca <- min(X.rank, n.pca) - if(n.pca >= N) stop("number of retained PCs of PCA is greater than N") - if(n.pca > N/3) warning("number of retained PCs of PCA may be too large (> N /3)\n results may be unstable ") - n.pca <- round(n.pca) - - U <- pcaX$c1[, 1:n.pca, drop=FALSE] # principal axes - rownames(U) <- colnames(x) # force to restore names - XU <- pcaX$li[, 1:n.pca, drop=FALSE] # principal components - XU.lambda <- sum(pcaX$eig[1:n.pca])/sum(pcaX$eig) # sum of retained eigenvalues - names(U) <- paste("PCA-pa", 1:ncol(U), sep=".") - names(XU) <- paste("PCA-pc", 1:ncol(XU), sep=".") - - - ## PERFORM DA ## - ldaX <- lda(XU, grp, tol=1e-30) # tol=1e-30 is a kludge, but a safe (?) one to avoid fancy rescaling by lda.default - lda.dim <- sum(ldaX$svd^2 > 1e-10) - ldaX$svd <- ldaX$svd[1:lda.dim] - ldaX$scaling <- ldaX$scaling[,1:lda.dim,drop=FALSE] - - if(is.null(n.da)){ - barplot(ldaX$svd^2, xlab="Linear Discriminants", ylab="F-statistic", main="Discriminant analysis eigenvalues", col=heat.colors(length(levels(grp))) ) - cat("Choose the number discriminant functions to retain (>=1): ") - n.da <- as.integer(readLines(n = 1)) - } - - n.da <- min(n.da, length(levels(grp))-1, n.pca) # can't be more than K-1 disc. func., or more than n.pca - n.da <- round(n.da) - predX <- predict(ldaX, dimen=n.da) - - - ## BUILD RESULT - res <- list() - res$n.pca <- n.pca - res$n.da <- n.da - res$tab <- XU - res$grp <- grp - res$var <- XU.lambda - res$eig <- ldaX$svd^2 - res$loadings <- ldaX$scaling[, 1:n.da, drop=FALSE] - res$means <- ldaX$means - res$ind.coord <-predX$x - res$grp.coord <- apply(res$ind.coord, 2, tapply, grp, mean) - res$prior <- ldaX$prior - res$posterior <- predX$posterior - res$assign <- predX$class - res$call <- match.call() - - - ## optional: store loadings of variables - if(pca.info){ - res$pca.loadings <- as.matrix(U) - res$pca.cent <- pcaX$cent - res$pca.norm <- pcaX$norm - res$pca.eig <- pcaX$eig - } - - ## optional: get loadings of variables - if(var.contrib){ - res$var.contr <- as.matrix(U) %*% as.matrix(ldaX$scaling[,1:n.da,drop=FALSE]) - f1 <- function(x){ - temp <- sum(x*x) - if(temp < 1e-12) return(rep(0, length(x))) - return(x*x / temp) - } - res$var.contr <- apply(res$var.contr, 2, f1) - } - - class(res) <- "dapc" - return(res) -} # end dapc.data.frame - - - - - -############# -## dapc.matrix -############# -dapc.matrix <- function(x, ...){ - return(dapc(as.data.frame(x), ...)) -} - - - - -############# -## dapc.genind -############# -dapc.genind <- function(x, pop=NULL, n.pca=NULL, n.da=NULL, - scale=FALSE, scale.method=c("sigma", "binom"), truenames=TRUE, var.contrib=TRUE, pca.info=TRUE, - pca.select=c("nbEig","percVar"), perc.pca=NULL, ...){ - - ## FIRST CHECKS - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") - - if(!is.genind(x)) stop("x must be a genind object.") - - if(is.null(pop)) { - pop.fac <- pop(x) - } else { - pop.fac <- pop - } - - if(is.null(pop.fac)) stop("x does not include pre-defined populations, and `pop' is not provided") - - - ## SOME GENERAL VARIABLES - N <- nrow(x at tab) - - ## PERFORM PCA ## - maxRank <- min(dim(x at tab)) - - X <- scaleGen(x, center = TRUE, scale = scale, method = scale.method, - missing = "mean", truenames = truenames) - - ## CALL DATA.FRAME METHOD ## - res <- dapc(X, grp=pop.fac, n.pca=n.pca, n.da=n.da, - center=FALSE, scale=FALSE, var.contrib=var.contrib, - pca.select=pca.select, perc.pca=perc.pca) - - res$call <- match.call() - - ## restore centring/scaling - res$pca.cent <- attr(X, "scaled:center") - - if(scale) { - res$pca.norm <- attr(X, "scaled:scale") - } - - return(res) -} # end dapc.genind - - - - - - -###################### -## Function dapc.dudi -###################### -dapc.dudi <- function(x, grp, ...){ - return(dapc.data.frame(x$li, grp, dudi=x, ...)) -} - - - - - -################# -## dapc.genlight -################# -dapc.genlight <- function(x, pop=NULL, n.pca=NULL, n.da=NULL, - scale=FALSE, var.contrib=TRUE, pca.info=TRUE, - pca.select=c("nbEig","percVar"), perc.pca=NULL, glPca=NULL, ...){ - ## FIRST CHECKS ## - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") - if(!inherits(x, "genlight")) stop("x must be a genlight object.") - - pca.select <- match.arg(pca.select) - - if(is.null(pop)) { - pop.fac <- pop(x) - } else { - pop.fac <- pop - } - - if(is.null(pop.fac)) stop("x does not include pre-defined populations, and `pop' is not provided") - - - - ## PERFORM PCA ## - REDUCEDIM <- is.null(glPca) - - if(REDUCEDIM){ # if no glPca provided - maxRank <- min(c(nInd(x), nLoc(x))) - pcaX <- glPca(x, center = TRUE, scale = scale, nf=maxRank, loadings=FALSE, returnDotProd = TRUE, ...) - } - - if(!REDUCEDIM){ # else use the provided glPca object - if(is.null(glPca$loadings) & var.contrib) { - warning("Contribution of variables requested but glPca object provided without loadings.") - var.contrib <- FALSE - } - pcaX <- glPca - } - - if(is.null(n.pca)){ - cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig) - } - - - ## select the number of retained PC for PCA - if(!REDUCEDIM){ - myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$scores),length(pcaX$eig))) - } else { - myCol <- "black" - } - - if(is.null(n.pca) & pca.select=="nbEig"){ - plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) - cat("Choose the number PCs to retain (>=1): ") - n.pca <- as.integer(readLines(n = 1)) - } - - if(is.null(perc.pca) & pca.select=="percVar"){ - plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) - cat("Choose the percentage of variance to retain (0-100): ") - nperc.pca <- as.numeric(readLines(n = 1)) - } - - ## get n.pca from the % of variance to conserve - if(!is.null(perc.pca)){ - n.pca <- min(which(cumVar >= perc.pca)) - if(perc.pca > 99.999) n.pca <- length(pcaX$eig) - if(n.pca<1) n.pca <- 1 - } - - if(!REDUCEDIM){ - if(n.pca > ncol(pcaX$scores)) { - n.pca <- ncol(pcaX$scores) - } - } - - - ## recompute PCA with loadings if needed - if(REDUCEDIM){ - pcaX <- glPca(x, center = TRUE, scale = scale, nf=n.pca, loadings=var.contrib, matDotProd = pcaX$dotProd) - } - - - ## keep relevant PCs - stored in XU - N <- nInd(x) - X.rank <- sum(pcaX$eig > 1e-14) - n.pca <- min(X.rank, n.pca) - if(n.pca >= N) stop("number of retained PCs of PCA is greater than N") - if(n.pca > N/3) warning("number of retained PCs of PCA may be too large (> N /3)\n results may be unstable ") - - U <- pcaX$loadings[, 1:n.pca, drop=FALSE] # principal axes - XU <- pcaX$scores[, 1:n.pca, drop=FALSE] # principal components - XU.lambda <- sum(pcaX$eig[1:n.pca])/sum(pcaX$eig) # sum of retained eigenvalues - names(U) <- paste("PCA-pa", 1:ncol(U), sep=".") - names(XU) <- paste("PCA-pc", 1:ncol(XU), sep=".") - - - ## PERFORM DA ## - ldaX <- lda(XU, pop.fac, tol=1e-30) # tol=1e-30 is a kludge, but a safe (?) one to avoid fancy rescaling by lda.default - lda.dim <- sum(ldaX$svd^2 > 1e-10) - ldaX$svd <- ldaX$svd[1:lda.dim] - ldaX$scaling <- ldaX$scaling[,1:lda.dim,drop=FALSE] - - if(is.null(n.da)){ - barplot(ldaX$svd^2, xlab="Linear Discriminants", ylab="F-statistic", main="Discriminant analysis eigenvalues", col=heat.colors(length(levels(pop.fac))) ) - cat("Choose the number discriminant functions to retain (>=1): ") - n.da <- as.integer(readLines(n = 1)) - } - - n.da <- min(n.da, length(levels(pop.fac))-1, n.pca, sum(ldaX$svd>1e-10)) # can't be more than K-1 disc. func., or more than n.pca - n.da <- round(n.da) - predX <- predict(ldaX, dimen=n.da) - - - ## BUILD RESULT - res <- list() - res$n.pca <- n.pca - res$n.da <- n.da - res$tab <- XU - res$grp <- pop.fac - res$var <- XU.lambda - res$eig <- ldaX$svd^2 - res$loadings <- ldaX$scaling[, 1:n.da, drop=FALSE] - res$means <- ldaX$means - res$ind.coord <-predX$x - res$grp.coord <- apply(res$ind.coord, 2, tapply, pop.fac, mean) - res$prior <- ldaX$prior - res$posterior <- predX$posterior - res$assign <- predX$class - res$call <- match.call() - - - ## optional: store loadings of variables - if(pca.info){ - res$pca.loadings <- as.matrix(U) - res$pca.cent <- glMean(x,alleleAsUnit=FALSE) - if(scale) { - res$pca.norm <- sqrt(glVar(x,alleleAsUnit=FALSE)) - } else { - res$pca.norm <- rep(1, nLoc(x)) - } - res$pca.eig <- pcaX$eig - } - - ## optional: get loadings of variables - if(var.contrib){ - res$var.contr <- as.matrix(U) %*% as.matrix(ldaX$scaling[,1:n.da,drop=FALSE]) - f1 <- function(x){ - temp <- sum(x*x) - if(temp < 1e-12) return(rep(0, length(x))) - return(x*x / temp) - } - res$var.contr <- apply(res$var.contr, 2, f1) - } - - class(res) <- "dapc" - return(res) -} # end dapc.genlight - - - - - - -###################### -# Function print.dapc -###################### -print.dapc <- function(x, ...){ - cat("\t#################################################\n") - cat("\t# Discriminant Analysis of Principal Components #\n") - cat("\t#################################################\n") - cat("class: ") - cat(class(x)) - cat("\n$call: ") - print(x$call) - cat("\n$n.pca:", x$n.pca, "first PCs of PCA used") - cat("\n$n.da:", x$n.da, "discriminant functions saved") - cat("\n$var (proportion of conserved variance):", round(x$var,3)) - cat("\n\n$eig (eigenvalues): ") - l0 <- sum(x$eig >= 0) - cat(signif(x$eig, 4)[1:(min(5, l0))]) - if (l0 > 5) - cat(" ...\n\n") - - ## vectors - TABDIM <- 4 - if(!is.null(x$pca.loadings)){ - TABDIM <- TABDIM + 3 - } - sumry <- array("", c(TABDIM, 3), list(1:TABDIM, c("vector", "length", "content"))) - sumry[1, ] <- c('$eig', length(x$eig), 'eigenvalues') - sumry[2, ] <- c('$grp', length(x$grp), 'prior group assignment') - sumry[3, ] <- c('$prior', length(x$prior), 'prior group probabilities') - sumry[4, ] <- c('$assign', length(x$assign), 'posterior group assignment') - if(!is.null(x$pca.loadings)){ - sumry[5, ] <- c('$pca.cent', length(x$pca.cent), 'centring vector of PCA') - sumry[6, ] <- c('$pca.norm', length(x$pca.norm), 'scaling vector of PCA') - sumry[7, ] <- c('$pca.eig', length(x$pca.eig), 'eigenvalues of PCA') - } - class(sumry) <- "table" - print(sumry) - - ## data.frames - cat("\n") - TABDIM <- 6 - if(!is.null(x$pca.loadings)){ - TABDIM <- TABDIM + 1 - } - if(!is.null(x$var.contr)){ - TABDIM <- TABDIM + 1 - } - - sumry <- array("", c(TABDIM, 4), list(1:TABDIM, c("data.frame", "nrow", "ncol", "content"))) - - sumry[1, ] <- c("$tab", nrow(x$tab), ncol(x$tab), "retained PCs of PCA") - sumry[2, ] <- c("$means", nrow(x$means), ncol(x$means), "group means") - sumry[3, ] <- c("$loadings", nrow(x$loadings), ncol(x$loadings), "loadings of variables") - sumry[4, ] <- c("$ind.coord", nrow(x$ind.coord), ncol(x$ind.coord), "coordinates of individuals (principal components)") - sumry[5, ] <- c("$grp.coord", nrow(x$grp.coord), ncol(x$grp.coord), "coordinates of groups") - sumry[6, ] <- c("$posterior", nrow(x$posterior), ncol(x$posterior), "posterior membership probabilities") - if(!is.null(x$pca.loadings)){ - sumry[7, ] <- c("$pca.loadings", nrow(x$pca.loadings), ncol(x$pca.loadings), "PCA loadings of original variables") - } - if(!is.null(x$var.contr)){ - sumry[TABDIM, ] <- c("$var.contr", nrow(x$var.contr), ncol(x$var.contr), "contribution of original variables") - } - class(sumry) <- "table" - print(sumry) - - ## cat("\nother elements: ") - ## if (length(names(x)) > 15) - ## cat(names(x)[15:(length(names(x)))], "\n") - ## else cat("NULL\n") - cat("\n") -} # end print.dapc - - - - - - -############## -## summary.dapc -############## -summary.dapc <- function(object, ...){ - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - - x <- object - res <- list() - - ## number of dimensions - res$n.dim <- ncol(x$loadings) - res$n.pop <- length(levels(x$grp)) - - ## assignment success - temp <- as.character(x$grp)==as.character(x$assign) - res$assign.prop <- mean(temp) - res$assign.per.pop <- tapply(temp, x$grp, mean) - - ## group sizes - res$prior.grp.size <- table(x$grp) - res$post.grp.size <- table(x$assign) - - return(res) -} # end summary.dapc - - - - - - -############## -## scatter.dapc -############## -scatter.dapc <- function(x, xax=1, yax=2, grp=x$grp, col=rainbow(length(levels(grp))), pch=20, bg="lightgrey", solid=.7, - scree.da=TRUE, scree.pca=FALSE, posi.da="bottomright", posi.pca="bottomleft", bg.inset="white", - ratio.da=.25, ratio.pca=.25, inset.da=0.02, inset.pca=0.02, inset.solid=.5, - onedim.filled=TRUE, mstree=FALSE, lwd=1, lty=1, segcol="black", - legend=FALSE, posi.leg="topright", cleg=1, txt.leg=levels(grp), - cstar = 1, cellipse = 1.5, axesell = FALSE, label = levels(grp), clabel = 1, xlim = NULL, ylim = NULL, - grid = FALSE, addaxes = TRUE, origin = c(0,0), include.origin = TRUE, sub = "", csub = 1, possub = "bottomleft", - cgrid = 1, pixmap = NULL, contour = NULL, area = NULL, ...){ - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - ONEDIM <- xax==yax | ncol(x$ind.coord)==1 - - ## recycle color and pch - col <- rep(col, length(levels(grp))) - pch <- rep(pch, length(levels(grp))) - col <- transp(col, solid) - bg.inset <- transp(bg.inset, inset.solid) - - ## handle grp - if(is.null(grp)){ - grp <- x$grp - } - - if(!ONEDIM){ - ## set par - opar <- par(mar = par("mar")) - par(mar = c(0.1, 0.1, 0.1, 0.1), bg=bg) - on.exit(par(opar)) - axes <- c(xax,yax) - ## basic empty plot - ## s.label(x$ind.coord[,axes], clab=0, cpoint=0, grid=FALSE, addaxes = FALSE, cgrid = 1, include.origin = FALSE, ...) - s.class(x$ind.coord[,axes], fac=grp, col=col, cpoint=0, cstar = cstar, cellipse = cellipse, axesell = axesell, label = label, - clabel = clabel, xlim = xlim, ylim = ylim, grid = grid, addaxes = addaxes, origin = origin, include.origin = include.origin, - sub = sub, csub = csub, possub = possub, cgrid = cgrid, pixmap = pixmap, contour = contour, area = area) - - ## add points - colfac <- pchfac <- grp - levels(colfac) <- col - levels(pchfac) <- pch - colfac <- as.character(colfac) - pchfac <- as.character(pchfac) - if(is.numeric(col)) colfac <- as.numeric(colfac) - if(is.numeric(pch)) pchfac <- as.numeric(pchfac) - - points(x$ind.coord[,xax], x$ind.coord[,yax], col=colfac, pch=pchfac, ...) - s.class(x$ind.coord[,axes], fac=grp, col=col, cpoint=0, add.plot=TRUE, cstar = cstar, cellipse = cellipse, axesell = axesell, label = label, - clabel = clabel, xlim = xlim, ylim = ylim, grid = grid, addaxes = addaxes, origin = origin, include.origin = include.origin, - sub = sub, csub = csub, possub = possub, cgrid = cgrid, pixmap = pixmap, contour = contour, area = area) - - ## add minimum spanning tree if needed - if(mstree && require(ade4)){ - meanposi <- apply(x$tab,2, tapply, grp, mean) - D <- dist(meanposi)^2 - tre <- ade4::mstree(D) - x0 <- x$grp.coord[tre[,1], axes[1]] - y0 <- x$grp.coord[tre[,1], axes[2]] - x1 <- x$grp.coord[tre[,2], axes[1]] - y1 <- x$grp.coord[tre[,2], axes[2]] - segments(x0, y0, x1, y1, lwd=lwd, lty=lty, col=segcol) - } - - } else { - - ## get plotted axis - if(ncol(x$ind.coord)==1) { - pcLab <- 1 - } else{ - pcLab <- xax - } - ## get densities - ldens <- tapply(x$ind.coord[,pcLab], grp, density) - allx <- unlist(lapply(ldens, function(e) e$x)) - ally <- unlist(lapply(ldens, function(e) e$y)) - par(bg=bg) - plot(allx, ally, type="n", xlab=paste("Discriminant function", pcLab), ylab="Density") - for(i in 1:length(ldens)){ - if(!onedim.filled) { - lines(ldens[[i]]$x,ldens[[i]]$y, col=col[i], lwd=2) # add lines - } else { - polygon(c(ldens[[i]]$x,rev(ldens[[i]]$x)),c(ldens[[i]]$y,rep(0,length(ldens[[i]]$x))), col=col[i], lwd=2, border=col[i]) # add lines - } - points(x=x$ind.coord[grp==levels(grp)[i],pcLab], y=rep(0, sum(grp==levels(grp)[i])), pch="|", col=col[i]) # add points for indiv - } - } - - ## ADD INSETS ## - ## group legend - if(legend){ - ## add a legend - temp <- list(...)$cex - if(is.null(temp)) temp <- 1 - if(ONEDIM | temp<0.5 | all(pch=="")) { - legend(posi.leg, fill=col, legend=txt.leg, cex=cleg, bg=bg.inset) - } else { - legend(posi.leg, col=col, legend=txt.leg, cex=cleg, bg=bg.inset, pch=pch, pt.cex=temp) - } - } - - ## eigenvalues discriminant analysis - if(scree.da && ratio.da>.01) { - inset <- function(){ - myCol <- rep("white", length(x$eig)) - myCol[1:x$n.da] <- "grey" - myCol[c(xax, yax)] <- "black" - myCol <- transp(myCol, inset.solid) - barplot(x$eig, col=myCol, xaxt="n", yaxt="n", ylim=c(0, x$eig[1]*1.1)) - mtext(side=3, "DA eigenvalues", line=-1.2, adj=.8) - box() - } - - add.scatter(inset(), posi=posi.da, ratio=ratio.da, bg.col=bg.inset, inset=inset.da) - ##add.scatter.eig(x$eig, ncol(x$loadings), axes[1], axes[2], posi=posi, ratio=ratio, csub=csub) # does not allow for bg - } - - ## eigenvalues PCA - if(scree.pca && !is.null(x$pca.eig) && ratio.pca>.01) { - inset <- function(){ - temp <- 100* cumsum(x$pca.eig) / sum(x$pca.eig) - myCol <- rep(c("black","grey"), c(x$n.pca, length(x$pca.eig))) - myCol <- transp(myCol, inset.solid) - plot(temp, col=myCol, ylim=c(0,115), - type="h", xaxt="n", yaxt="n", xlab="", ylab="", lwd=2) - mtext(side=3, "PCA eigenvalues", line=-1.2, adj=.1) - } - add.scatter(inset(), posi=posi.pca, ratio=ratio.pca, bg.col=bg.inset, inset=inset.pca) - } - - - return(invisible(match.call())) -} # end scatter.dapc - - - - - - -############ -## assignplot -############ -assignplot <- function(x, only.grp=NULL, subset=NULL, new.pred=NULL, cex.lab=.75, pch=3){ - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - if(!inherits(x, "dapc")) stop("x is not a dapc object") - - ## handle data from predict.dapc ## - if(!is.null(new.pred)){ - n.new <- length(new.pred$assign) - x$grp <- c(as.character(x$grp), rep("unknown", n.new)) - x$assign <- c(as.character(x$assign), as.character(new.pred$assign)) - x$posterior <- rbind(x$posterior, new.pred$posterior) - } - - - ## treat other arguments ## - if(!is.null(only.grp)){ - only.grp <- as.character(only.grp) - ori.grp <- as.character(x$grp) - x$grp <- x$grp[only.grp==ori.grp] - x$assign <- x$assign[only.grp==ori.grp] - x$posterior <- x$posterior[only.grp==ori.grp, , drop=FALSE] - } else if(!is.null(subset)){ - x$grp <- x$grp[subset] - x$assign <- x$assign[subset] - x$posterior <- x$posterior[subset, , drop=FALSE] - } - - - ##table.paint(x$posterior, col.lab=ori.grp, ...) - ## symbols(x$posterior) - - - ## FIND PLOT PARAMETERS - n.grp <- ncol(x$posterior) - n.ind <- nrow(x$posterior) - Z <- t(x$posterior) - Z <- Z[,ncol(Z):1,drop=FALSE ] - - image(x=1:n.grp, y=seq(.5, by=1, le=n.ind), Z, col=rev(heat.colors(100)), yaxt="n", ylab="", xaxt="n", xlab="Clusters") - axis(side=1, at=1:n.grp,tick=FALSE, labels=colnames(x$posterior)) - axis(side=2, at=seq(.5, by=1, le=n.ind), labels=rev(rownames(x$posterior)), las=1, cex.axis=cex.lab) - abline(h=1:n.ind, col="lightgrey") - abline(v=seq(0.5, by=1, le=n.grp)) - box() - - newGrp <- colnames(x$posterior) - x.real.coord <- rev(match(x$grp, newGrp)) - y.real.coord <- seq(.5, by=1, le=n.ind) - - points(x.real.coord, y.real.coord, col="deepskyblue2", pch=pch) - - return(invisible(match.call())) -} # end assignplot - - - - - -############ -## compoplot -############ -compoplot <- function(x, only.grp=NULL, subset=NULL, new.pred=NULL, col=NULL, lab=NULL, - legend=TRUE, txt.leg=NULL, ncol=4, posi=NULL, cleg=.8, bg=transp("white"), ...){ - if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") - if(!inherits(x, "dapc")) stop("x is not a dapc object") - - - ## HANDLE ARGUMENTS ## - ngrp <- length(levels(x$grp)) - - ## col - if(is.null(col)){ - col <- rainbow(ngrp) - } - - ## lab - if(is.null(lab)){ - lab <- rownames(x$tab) - } else { - ## recycle labels - lab <- rep(lab, le=nrow(x$tab)) - } - - ## posi - if(is.null(posi)){ - posi <- list(x=0, y=-.01) - } - - ## txt.leg - if(is.null(txt.leg)){ - txt.leg <- levels(x$grp) - } - - ## HANDLE DATA FROM PREDICT.DAPC ## - if(!is.null(new.pred)){ - n.new <- length(new.pred$assign) - x$grp <- c(as.character(x$grp), rep("unknown", n.new)) - x$assign <- c(as.character(x$assign), as.character(new.pred$assign)) - x$posterior <- rbind(x$posterior, new.pred$posterior) - lab <- c(lab, rownames(new.pred$posterior)) - } - - - ## TREAT OTHER ARGUMENTS ## - if(!is.null(only.grp)){ - only.grp <- as.character(only.grp) - ori.grp <- as.character(x$grp) - x$grp <- x$grp[only.grp==ori.grp] - x$assign <- x$assign[only.grp==ori.grp] - x$posterior <- x$posterior[only.grp==ori.grp, , drop=FALSE] - lab <- lab[only.grp==ori.grp] - } else if(!is.null(subset)){ - x$grp <- x$grp[subset] - x$assign <- x$assign[subset] - x$posterior <- x$posterior[subset, , drop=FALSE] - lab <- lab[subset] - } - - - ## MAKE THE PLOT ## - Z <- t(x$posterior) - barplot(Z, border=NA, col=col, ylab="membership probability", names=lab, las=3, ...) - - if(legend){ - oxpd <- par("xpd") - par(xpd=TRUE) - legend(posi, fill=col, leg=txt.leg, cex=cleg, ncol=ncol, bg=bg) - on.exit(par(xpd=oxpd)) - } - - return(invisible(match.call())) -} # end compoplot - - - - - -############### -## a.score -############### -a.score <- function(x, n.sim=10, ...){ - if(!inherits(x,"dapc")) stop("x is not a dapc object") - - ## perform DAPC based on permuted groups - lsim <- lapply(1:n.sim, function(i) summary(dapc(x$tab, sample(x$grp), n.pca=x$n.pca, n.da=x$n.da))$assign.per.pop) - sumry <- summary(x) - - ## get the a-scores - f1 <- function(Pt, Pf){ - tol <- 1e-7 - ##res <- (Pt-Pf) / (1-Pf) - ##res[Pf > (1-tol)] <- 0 - res <- Pt-Pf - return(res) - } - - lscores <- lapply(lsim, function(e) f1(sumry$assign.per.pop, e)) - - ## make a table of a-scores - tab <- data.frame(lscores) - colnames(tab) <- paste("sim", 1:n.sim, sep=".") - rownames(tab) <- names(sumry$assign.per.pop) - tab <- t(as.matrix(tab)) - - ## make result - res <- list() - res$tab <- tab - res$pop.score <- apply(tab, 2, mean) - res$mean <- mean(tab) - - return(res) - -} # end a.score - - - - - - - -############## -## optim.a.score -############## -optim.a.score <- function(x, n.pca=1:ncol(x$tab), smart=TRUE, n=10, plot=TRUE, - n.sim=10, n.da=length(levels(x$grp)), ...){ - ## A FEW CHECKS ## - if(!inherits(x,"dapc")) stop("x is not a dapc object") - if(max(n.pca)>ncol(x$tab)) { - n.pca <- min(n.pca):ncol(x$tab) - } - if(n.da>length(levels(x$grp))){ - n.da <- min(n.da):length(levels(x$grp)) - } - pred <- NULL - if(length(n.pca)==1){ - n.pca <- 1:n.pca - } - if(length(n.da)==1){ - n.da <- 1:n.da - } - - - ## AUXILIARY FUNCTION ## - f1 <- function(ndim){ - temp <- dapc(x$tab[,1:ndim,drop=FALSE], x$grp, n.pca=ndim, n.da=x$n.da) - a.score(temp, n.sim=n.sim)$pop.score - } - - - ## SMART: COMPUTE A FEW VALUES, PREDICT THE BEST PICK ## - if(smart){ - if(!require(stats)) stop("the package stats is required for 'smart' option") - o.min <- min(n.pca) - o.max <- max(n.pca) - n.pca <- pretty(n.pca, n) # get evenly spaced nb of retained PCs - n.pca <- n.pca[n.pca>0 & n.pca<=ncol(x$tab)] - if(!any(o.min==n.pca)) n.pca <- c(o.min, n.pca) # make sure range is OK - if(!any(o.max==n.pca)) n.pca <- c(o.max, n.pca) # make sure range is OK - lres <- lapply(n.pca, f1) - names(lres) <- n.pca - means <- sapply(lres, mean) - sp1 <- smooth.spline(n.pca, means) # spline smoothing - pred <- predict(sp1, x=1:max(n.pca)) - best <- pred$x[which.max(pred$y)] - } else { ## DO NOT TRY TO BE SMART ## - lres <- lapply(n.pca, f1) - names(lres) <- n.pca - best <- which.max(sapply(lres, mean)) - means <- sapply(lres, mean) - } - - - ## MAKE FINAL OUTPUT ## - res <- list() - res$pop.score <- lres - res$mean <- means - if(!is.null(pred)) res$pred <- pred - res$best <- best - - ## PLOTTING (OPTIONAL) ## - if(plot){ - if(smart){ - boxplot(lres, at=n.pca, col="gold", xlab="Number of retained PCs", ylab="a-score", xlim=range(n.pca)+c(-1,1), ylim=c(-.1,1.1)) - lines(pred, lwd=3) - points(pred$x[best], pred$y[best], col="red", lwd=3) - title("a-score optimisation - spline interpolation") - mtext(paste("Optimal number of PCs:", res$best), side=3) - } else { - myCol <- rep("gold", length(lres)) - myCol[best] <- "red" - boxplot(lres, at=n.pca, col=myCol, xlab="Number of retained PCs", ylab="a-score", xlim=range(n.pca)+c(-1,1), ylim=c(-.1,1.1)) - lines(n.pca, sapply(lres, mean), lwd=3, type="b") - myCol <- rep("black", length(lres)) - myCol[best] <- "red" - points(n.pca, res$mean, lwd=3, col=myCol) - title("a-score optimisation - basic search") - mtext(paste("Optimal number of PCs:", res$best), side=3) - } - } - - return(res) -} # end optim.a.score - - - - - - -############# -## as.lda.dapc -############# -as.lda <- function(...){ - UseMethod("as.lda") -} - -as.lda.dapc <- function(x, ...){ - if(!inherits(x,"dapc")) stop("x is not a dapc object") - res <- list() - - res$N <- nrow(res$ind.coord) - res$call <- match.call() - res$counts <- as.integer(table(x$grp)) - res$lev <- names(res$counts) <- levels(x$grp) - res$means <- x$means - res$prior <- x$prior - res$scaling <- x$loadings - res$svd <- sqrt(x$eig) - - class(res) <- "lda" - - return(res) -} # end as.lda.dapc - - - - - - -############## -## predict.dapc -############## -predict.dapc <- function(object, newdata, prior = object$prior, dimen, - method = c("plug-in", "predictive", "debiased"), ...){ - - if(!inherits(object,"dapc")) stop("x is not a dapc object") - method <- match.arg(method) - - x <- as.lda(object) - - - ## HANDLE NEW DATA ## - if(!missing(newdata)){ - ## make a few checks - if(is.null(object$pca.loadings)) stop("DAPC object does not contain loadings of original variables. \nPlease re-run DAPC using 'pca.loadings=TRUE'.") - newdata <- as.matrix(newdata) # to force conversion, notably from genlight objects - if(ncol(newdata) != nrow(object$pca.loadings)) stop("Number of variables in newdata does not match original data.") - - ## centre/scale data - for(i in 1:nrow(newdata)){ # this is faster for large, flat matrices) - newdata[i,] <- (newdata[i,] - object$pca.cent) / object$pca.norm - } - newdata[is.na(newdata)] <- 0 - - ## project as supplementary individuals - XU <- newdata %*% as.matrix(object$pca.loadings) - } else { - XU <- object$tab - } - - ## FORCE IDENTICAL VARIABLE NAMES ## - colnames(XU) <- colnames(object$tab) - - - ## HANDLE DIMEN ## - if(!missing(dimen)){ - if(dimen > object$n.da) stop(paste("Too many dimensions requested. \nOnly", object$n.da, "discriminant functions were saved in DAPC.")) - } else { - dimen <- object$n.da - } - - ## CALL PREDICT.LDA ## - temp <- predict(x, XU, prior, dimen, method, ...) - - - ## FORMAT OUTPUT ## - res <- list() - res$assign <- temp$class - res$posterior <- temp$posterior - res$ind.scores <- temp$x - - return(res) - -} # end predict.dapc - - - - - - - -## ############ -## ## crossval -## ############ -## crossval <- function (x, ...) UseMethod("crossval") - -## crossval.dapc <- function(){ - -## } - - - -## ############### -## ## randtest.dapc -## ############### -## ##randtest.dapc <- function(x, nperm = 999, ...){ - -## ##} # end randtest.dapc - - - - -######## TESTS IN R ####### - -## TEST PREDICT.DAPC ## -## data(sim2pop) -## temp <- seppop(sim2pop) -## temp <- lapply(temp, function(e) hybridize(e,e,n=30)) # force equal pop sizes -## hyb <- hybridize(temp[[1]], temp[[2]], n=30) -## newdat <- repool(temp[[1]], temp[[2]], hyb) -## pop(newdat) <- rep(c("pop A", "popB", "hyb AB"), c(30,30,30)) - - -## ##dapc1 <- dapc(newdat[1:61],n.pca=10,n.da=1) -## dapc1 <- dapc(newdat[1:60],n.pca=2,n.da=1) -## scatter(dapc1) -## hyb.pred <- predict(dapc1, newdat[61:90]) - -## scatter(dapc1) -## points(hyb.pred$ind.scores, rep(.1, 30)) - -## assignplot(dapc1, new.pred=hyb.pred) -## title("30 indiv popA, 30 indiv pop B, 30 hybrids") From noreply at r-forge.r-project.org Thu Apr 25 12:09:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 25 Apr 2013 12:09:54 +0200 (CEST) Subject: [adegenet-commits] r1115 - pkg/man Message-ID: <20130425100954.95EC6180936@r-forge.r-project.org> Author: greatsage Date: 2013-04-25 12:09:54 +0200 (Thu, 25 Apr 2013) New Revision: 1115 Modified: pkg/man/adegenet.package.Rd Log: \encoding{UTF-8} \name{adegenet-package} \alias{adegenet-package} \alias{adegenet} \docType{package} \title{The adegenet package} \description{ This package is devoted to the multivariate analysis of genetic markers data. These data can be codominant markers (e.g. microsatellites) or presence/absence data (e.g. AFLP), and have any level of ploidy. 'adegenet' defines three formal (S4) classes:\cr - \linkS4class{genind}: a class for data of individuals ("genind" stands for genotypes-individuals).\cr - \linkS4class{genpop}: a class for data of groups of individuals ("genpop" stands for genotypes-populations)\cr - \linkS4class{genlight}: a class for genome-wide SNP data\cr For more information about these classes, type "class ? genind", "class ? genpop", or "?genlight".\cr Essential functionalities of the package are presented througout 4 tutorial vignettes, accessible using \code{vignette("name-below", package="adegenet")}:\cr - adegenet-basics: introduction to the package.\cr - adegenet-spca: multivariate analysis of spatial genetic patterns.\cr - adegenet-dapc: population structure and group assignment using DAPC.\cr - adegenet-genomics: introduction to the class \linkS4class{genlight} for the handling and analysis of genome-wide SNP data.\cr Important functions are also summarized below.\cr === IMPORTING DATA ===\cr = TO GENIND OBJECTS = \cr \code{adegenet} imports data to \linkS4class{genind} object from the following softwares:\cr - STRUCTURE: see \code{\link{read.structure}}\cr - GENETIX: see \code{\link{read.genetix}}\cr - FSTAT: see \code{\link{read.fstat}}\cr - Genepop: see \code{\link{read.genepop}}\cr To import data from any of these formats, you can also use the general function \code{\link{import2genind}}.\cr In addition, it can extract polymorphic sites from nucleotide and amino-acid alignments:\cr - DNA files: use \code{\link[ape]{read.dna}} from the ape package, and then extract SNPs from DNA alignments using \code{\link{DNAbin2genind}}. \cr - protein sequences alignments: polymorphic sites can be extracted from protein sequences alignments in \code{alignment} format (package \code{seqinr}, see \code{\link[seqinr]{as.alignment}}) using the function \code{\link{alignment2genind}}. \cr It is also possible to read genotypes coded by character strings from a data.frame in which genotypes are in rows, markers in columns. For this, use \code{\link{df2genind}}. Note that \code{\link{df2genind}} can be used for any level of ploidy.\cr = TO GENLIGHT OBJECTS = \cr SNP data can be read from the following formats:\cr - PLINK: see function \code{\link{read.PLINK}}\cr - .snp (adegenet's own format): see function \code{\link{read.snp}}\cr SNP can also be extracted from aligned DNA sequences with the fasta format, using \code{\link{fasta2genlight}}\cr === EXPORTING DATA ===\cr \code{adegenet} exports data from \linkS4class{genind} object to formats recognized by other R packages:\cr - the genetics package: see \code{\link{genind2genotype}}\cr - the hierfstat package: see \code{\link{genind2hierfstat}}\cr Genotypes can also be recoded from a \linkS4class{genind} object into a data.frame of character strings, using any separator between alleles. This covers formats from many softwares like GENETIX or STRUCTURE. For this, see \code{\link{genind2df}}.\cr Also note that the \code{pegas} package imports \linkS4class{genind} objects using the function \code{as.loci}. === MANIPULATING DATA ===\cr Several functions allow one to manipulate \linkS4class{genind} or \linkS4class{genpop} objects\cr - \code{\link{genind2genpop}}: convert a \linkS4class{genind} object to a \linkS4class{genpop} \cr - \code{\link{seploc}}: creates one object per marker; for \linkS4class{genlight} objects, creates blocks of SNPs.\cr - \code{\link{seppop}}: creates one object per population \cr - \code{\link{na.replace}}: replaces missing data (NA) in an approriate way \cr - \code{\link{truenames}}: restores true names of an object (\linkS4class{genind} and \linkS4class{genpop} use generic labels) \cr - x[i,j]: create a new object keeping only genotypes (or populations) indexed by 'i' and the alleles indexed by 'j'.\cr - \code{\link{makefreq}}: returns a table of allelic frequencies from a \linkS4class{genpop} object.\cr - \code{\link{repool}} merges genoptypes from different gene pools into one single \linkS4class{genind} object.\cr - \code{\link{propTyped}} returns the proportion of available (typed) data, by individual, population, and/or locus.\cr - \code{\link{selPopSize}} subsets data, retaining only genotypes from a population whose sample size is above a given level.\cr - \code{\link{pop}} sets the population of a set of genotypes.\cr === ANALYZING DATA ===\cr Several functions allow to use usual, and less usual analyses:\cr - \code{\link{HWE.test.genind}}: performs HWE test for all populations and loci combinations \cr - \code{\link{pairwise.fst}}: computes simple pairwise Fst between populations\cr - \code{\link{dist.genpop}}: computes 5 genetic distances among populations. \cr - \code{\link{monmonier}}: implementation of the Monmonier algorithm, used to seek genetic boundaries among individuals or populations. Optimized boundaries can be obtained using \code{\link{optimize.monmonier}}. Object of the class \code{monmonier} can be plotted and printed using the corresponding methods. \cr - \code{\link{spca}}: implements Jombart et al. (2008) spatial Principal Component Analysis \cr - \code{\link{global.rtest}}: implements Jombart et al. (2008) test for global spatial structures \cr - \code{\link{local.rtest}}: implements Jombart et al. (2008) test for local spatial structures \cr - \code{\link{propShared}}: computes the proportion of shared alleles in a set of genotypes (i.e. from a genind object)\cr - \code{\link{propTyped}}: function to investigate missing data in several ways \cr - \code{\link{scaleGen}}: generic method to scale \linkS4class{genind} or \linkS4class{genpop} before a principal component analysis \cr - \code{\link{Hs}}: computes the average expected heterozygosity by population in a \linkS4class{genpop}. Classically Used as a measure of genetic diversity.\cr - \code{\link{find.clusters}} and \code{\link{dapc}}: implement the Discriminant Analysis of Principal Component (DAPC, Jombart et al., 2010).\cr - \code{\link{seqTrack}}: implements the SeqTrack algorithm for recontructing transmission trees of pathogens (Jombart et al., 2010) .\cr \code{\link{glPca}}: implements PCA for \linkS4class{genlight} objects.\cr === GRAPHICS ===\cr - \code{\link{colorplot}}: plots points with associated values for up to three variables represented by colors using the RGB system; useful for spatial mapping of principal components.\cr - \code{\link{loadingplot}}: plots loadings of variables. Useful for representing the contribution of alleles to a given principal component in a multivariate method. \cr - \code{\link{scatter.dapc}}: scatterplots for DAPC results.\cr - \code{\link{compoplot}}: plots membership probabilities from a DAPC object. \cr === SIMULATING DATA ===\cr - \code{\link{hybridize}}: implements hybridization between two populations. \cr - \code{\link{haploGen}}: simulates genealogies of haplotypes, storing full genomes. \cr % - \code{\link{haploPop}}: simulates populations of haplotypes, using % different population dynamics, storing SNPs (under development). \cr - \code{\link{glSim}}: simulates simple \linkS4class{genlight} objects.\cr === DATASETS ===\cr - \code{\link{H3N2}}: Seasonal influenza (H3N2) HA segment data. \cr - \code{\link{dapcIllus}}: Simulated data illustrating the DAPC. \cr - \code{\link{eHGDP}}: Extended HGDP-CEPH dataset. \cr - \code{\link{microbov}}: Microsatellites genotypes of 15 cattle breeds. \cr - \code{\link{nancycats}}: Microsatellites genotypes of 237 cats from 17 colonies of Nancy (France). \cr - \code{\link{rupica}}: Microsatellites genotypes of 335 chamois (Rupicapra rupicapra) from the Bauges mountains (France).\cr - \code{\link{sim2pop}}: Simulated genotypes of two georeferenced populations.\cr - \code{\link{spcaIllus}}: Simulated data illustrating the sPCA. \cr For more information, visit the adegenet website by typing \code{adegenetWeb()}.\cr To cite adegenet, please use the reference given by \code{citation("adegenet")} (or see reference below). } \details{ \tabular{ll}{ Package: \tab adegenet\cr Type: \tab Package\cr Version: \tab 1.3-8\cr Date: \tab 2013-04-24 \cr License: \tab GPL (>=2) } } \author{ Thibaut Jombart \cr Developers: Ismail Ahmed , Federico Calboli ,Tobias Erik Reiners, Peter Solymos, Anne Cori\cr and contributed datasets from: Katayoun Moazami-Goudarzi, Denis Lalo?\195?\171, Dominique Pontier, Daniel Maillard, Francois Balloux. } \references{ Jombart T. (2008) adegenet: a R package for the multivariate analysis of genetic markers \emph{Bioinformatics} 24: 1403-1405. doi: 10.1093/bioinformatics/btn129\cr Jombart T, Devillard S and Balloux F (2010) Discriminant analysis of principal components: a new method for the analysis of genetically structured populations. BMC Genetics 11:94. doi:10.1186/1471-2156-11-94\cr Jombart T, Eggo R, Dodd P, Balloux F (2010) Reconstructing disease outbreaks from genetic data: a graph approach. \emph{Heredity}. doi: 10.1038/hdy.2010.78.\cr Jombart, T., Devillard, S., Dufour, A.-B. and Pontier, D. (2008) Revealing cryptic spatial patterns in genetic variability by a new multivariate method. \emph{Heredity}, \bold{101}, 92--103.\cr See adegenet website: \url{http://adegenet.r-forge.r-project.org/}\cr Please post your questions on 'the adegenet forum': adegenet-forum at lists.r-forge.r-project.org } \keyword{manip} \keyword{multivariate} \seealso{ adegenet is related to several packages, in particular:\cr - \code{ade4} for multivariate analysis\cr - \code{pegas} for population genetics tools\cr - \code{ape} for phylogenetics and DNA data handling\cr - \code{seqinr} for handling nucleic and proteic sequences\cr } Modified: pkg/man/adegenet.package.Rd =================================================================== --- pkg/man/adegenet.package.Rd 2013-04-24 18:44:43 UTC (rev 1114) +++ pkg/man/adegenet.package.Rd 2013-04-25 10:09:54 UTC (rev 1115) @@ -197,7 +197,7 @@ } \author{ Thibaut Jombart \cr - Developpers: Ismail Ahmed , Federico Calboli ,Tobias Erik Reiners, Peter Solymos, Anne Cori\cr + Developers: Ismail Ahmed , Federico Calboli ,Tobias Erik Reiners, Peter Solymos, Anne Cori\cr and contributed datasets from: Katayoun Moazami-Goudarzi, Denis Lalo?, Dominique Pontier, Daniel Maillard, Francois Balloux. } From noreply at r-forge.r-project.org Thu Apr 25 16:56:57 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 25 Apr 2013 16:56:57 +0200 (CEST) Subject: [adegenet-commits] r1116 - in pkg: R man Message-ID: <20130425145657.17ABE18493A@r-forge.r-project.org> Author: greatsage Date: 2013-04-25 16:56:56 +0200 (Thu, 25 Apr 2013) New Revision: 1116 Modified: pkg/R/dapc.R pkg/man/dapc.Rd Log: ####### ## dapc ######## dapc <- function (x, ...) UseMethod("dapc") ################### ## dapc.data.frame ################### dapc.data.frame <- function(x, grp, n.pca=NULL, n.da=NULL, center=TRUE, scale=FALSE, var.contrib=TRUE, pca.info=TRUE, pca.select=c("nbEig","percVar"), perc.pca=NULL, ..., dudi=NULL){ ## FIRST CHECKS if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") grp <- as.factor(grp) if(length(grp) != nrow(x)) stop("Inconsistent length for grp") pca.select <- match.arg(pca.select) if(!is.null(perc.pca) & is.null(n.pca)) pca.select <- "percVar" if(is.null(perc.pca) & !is.null(n.pca)) pca.select <- "nbEig" if(!is.null(dudi) && !inherits(dudi, "dudi")) stop("dudi provided, but not of class 'dudi'") ## SOME GENERAL VARIABLES N <- nrow(x) REDUCEDIM <- is.null(dudi) if(REDUCEDIM){ # if no dudi provided ## PERFORM PCA ## maxRank <- min(dim(x)) pcaX <- dudi.pca(x, center = center, scale = scale, scannf = FALSE, nf=maxRank) } else { # else use the provided dudi pcaX <- dudi } cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig) if(!REDUCEDIM){ myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$li),length(pcaX$eig))) } else { myCol <- "black" } ## select the number of retained PC for PCA if(is.null(n.pca) & pca.select=="nbEig"){ plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) cat("Choose the number PCs to retain (>=1): ") n.pca <- as.integer(readLines(n = 1)) } if(is.null(perc.pca) & pca.select=="percVar"){ plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) cat("Choose the percentage of variance to retain (0-100): ") nperc.pca <- as.numeric(readLines(n = 1)) } ## get n.pca from the % of variance to conserve if(!is.null(perc.pca)){ n.pca <- min(which(cumVar >= perc.pca)) if(perc.pca > 99.999) n.pca <- length(pcaX$eig) if(n.pca<1) n.pca <- 1 } ## keep relevant PCs - stored in XU X.rank <- sum(pcaX$eig > 1e-14) n.pca <- min(X.rank, n.pca) if(n.pca >= N) stop("number of retained PCs of PCA is greater than N") if(n.pca > N/3) warning("number of retained PCs of PCA may be too large (> N /3)\n results may be unstable ") n.pca <- round(n.pca) U <- pcaX$c1[, 1:n.pca, drop=FALSE] # principal axes rownames(U) <- colnames(x) # force to restore names XU <- pcaX$li[, 1:n.pca, drop=FALSE] # principal components XU.lambda <- sum(pcaX$eig[1:n.pca])/sum(pcaX$eig) # sum of retained eigenvalues names(U) <- paste("PCA-pa", 1:ncol(U), sep=".") names(XU) <- paste("PCA-pc", 1:ncol(XU), sep=".") ## PERFORM DA ## ldaX <- lda(XU, grp, tol=1e-30) # tol=1e-30 is a kludge, but a safe (?) one to avoid fancy rescaling by lda.default lda.dim <- sum(ldaX$svd^2 > 1e-10) ldaX$svd <- ldaX$svd[1:lda.dim] ldaX$scaling <- ldaX$scaling[,1:lda.dim,drop=FALSE] if(is.null(n.da)){ barplot(ldaX$svd^2, xlab="Linear Discriminants", ylab="F-statistic", main="Discriminant analysis eigenvalues", col=heat.colors(length(levels(grp))) ) cat("Choose the number discriminant functions to retain (>=1): ") n.da <- as.integer(readLines(n = 1)) } n.da <- min(n.da, length(levels(grp))-1, n.pca) # can't be more than K-1 disc. func., or more than n.pca n.da <- round(n.da) predX <- predict(ldaX, dimen=n.da) ## BUILD RESULT res <- list() res$n.pca <- n.pca res$n.da <- n.da res$tab <- XU res$grp <- grp res$var <- XU.lambda res$eig <- ldaX$svd^2 res$loadings <- ldaX$scaling[, 1:n.da, drop=FALSE] res$means <- ldaX$means res$ind.coord <-predX$x res$grp.coord <- apply(res$ind.coord, 2, tapply, grp, mean) res$prior <- ldaX$prior res$posterior <- predX$posterior res$assign <- predX$class res$call <- match.call() ## optional: store loadings of variables if(pca.info){ res$pca.loadings <- as.matrix(U) res$pca.cent <- pcaX$cent res$pca.norm <- pcaX$norm res$pca.eig <- pcaX$eig } ## optional: get loadings of variables if(var.contrib){ res$var.contr <- as.matrix(U) %*% as.matrix(ldaX$scaling[,1:n.da,drop=FALSE]) f1 <- function(x){ temp <- sum(x*x) if(temp < 1e-12) return(rep(0, length(x))) return(x*x / temp) } res$var.contr <- apply(res$var.contr, 2, f1) } class(res) <- "dapc" return(res) } # end dapc.data.frame ############# ## dapc.matrix ############# dapc.matrix <- function(x, ...){ return(dapc(as.data.frame(x), ...)) } ############# ## dapc.genind ############# dapc.genind <- function(x, pop=NULL, n.pca=NULL, n.da=NULL, scale=FALSE, scale.method=c("sigma", "binom"), truenames=TRUE, var.contrib=TRUE, pca.info=TRUE, pca.select=c("nbEig","percVar"), perc.pca=NULL, ...){ ## FIRST CHECKS if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") if(!is.genind(x)) stop("x must be a genind object.") if(is.null(pop)) { pop.fac <- pop(x) } else { pop.fac <- pop } if(is.null(pop.fac)) stop("x does not include pre-defined populations, and `pop' is not provided") ## SOME GENERAL VARIABLES N <- nrow(x at tab) ## PERFORM PCA ## maxRank <- min(dim(x at tab)) X <- scaleGen(x, center = TRUE, scale = scale, method = scale.method, missing = "mean", truenames = truenames) ## CALL DATA.FRAME METHOD ## res <- dapc(X, grp=pop.fac, n.pca=n.pca, n.da=n.da, center=FALSE, scale=FALSE, var.contrib=var.contrib, pca.select=pca.select, perc.pca=perc.pca) res$call <- match.call() ## restore centring/scaling res$pca.cent <- attr(X, "scaled:center") if(scale) { res$pca.norm <- attr(X, "scaled:scale") } return(res) } # end dapc.genind ###################### ## Function dapc.dudi ###################### dapc.dudi <- function(x, grp, ...){ return(dapc.data.frame(x$li, grp, dudi=x, ...)) } ################# ## dapc.genlight ################# dapc.genlight <- function(x, pop=NULL, n.pca=NULL, n.da=NULL, scale=FALSE, var.contrib=TRUE, pca.info=TRUE, pca.select=c("nbEig","percVar"), perc.pca=NULL, glPca=NULL, ...){ ## FIRST CHECKS ## if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") if(!require(MASS, quietly=TRUE)) stop("MASS library is required.") if(!inherits(x, "genlight")) stop("x must be a genlight object.") pca.select <- match.arg(pca.select) if(is.null(pop)) { pop.fac <- pop(x) } else { pop.fac <- pop } if(is.null(pop.fac)) stop("x does not include pre-defined populations, and `pop' is not provided") ## PERFORM PCA ## REDUCEDIM <- is.null(glPca) if(REDUCEDIM){ # if no glPca provided maxRank <- min(c(nInd(x), nLoc(x))) pcaX <- glPca(x, center = TRUE, scale = scale, nf=maxRank, loadings=FALSE, returnDotProd = TRUE, ...) } if(!REDUCEDIM){ # else use the provided glPca object if(is.null(glPca$loadings) & var.contrib) { warning("Contribution of variables requested but glPca object provided without loadings.") var.contrib <- FALSE } pcaX <- glPca } if(is.null(n.pca)){ cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig) } ## select the number of retained PC for PCA if(!REDUCEDIM){ myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$scores),length(pcaX$eig))) } else { myCol <- "black" } if(is.null(n.pca) & pca.select=="nbEig"){ plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) cat("Choose the number PCs to retain (>=1): ") n.pca <- as.integer(readLines(n = 1)) } if(is.null(perc.pca) & pca.select=="percVar"){ plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol) cat("Choose the percentage of variance to retain (0-100): ") nperc.pca <- as.numeric(readLines(n = 1)) } ## get n.pca from the % of variance to conserve if(!is.null(perc.pca)){ n.pca <- min(which(cumVar >= perc.pca)) if(perc.pca > 99.999) n.pca <- length(pcaX$eig) if(n.pca<1) n.pca <- 1 } if(!REDUCEDIM){ if(n.pca > ncol(pcaX$scores)) { n.pca <- ncol(pcaX$scores) } } ## recompute PCA with loadings if needed if(REDUCEDIM){ pcaX <- glPca(x, center = TRUE, scale = scale, nf=n.pca, loadings=var.contrib, matDotProd = pcaX$dotProd) } ## keep relevant PCs - stored in XU N <- nInd(x) X.rank <- sum(pcaX$eig > 1e-14) n.pca <- min(X.rank, n.pca) if(n.pca >= N) stop("number of retained PCs of PCA is greater than N") if(n.pca > N/3) warning("number of retained PCs of PCA may be too large (> N /3)\n results may be unstable ") U <- pcaX$loadings[, 1:n.pca, drop=FALSE] # principal axes XU <- pcaX$scores[, 1:n.pca, drop=FALSE] # principal components XU.lambda <- sum(pcaX$eig[1:n.pca])/sum(pcaX$eig) # sum of retained eigenvalues names(U) <- paste("PCA-pa", 1:ncol(U), sep=".") names(XU) <- paste("PCA-pc", 1:ncol(XU), sep=".") ## PERFORM DA ## ldaX <- lda(XU, pop.fac, tol=1e-30) # tol=1e-30 is a kludge, but a safe (?) one to avoid fancy rescaling by lda.default lda.dim <- sum(ldaX$svd^2 > 1e-10) ldaX$svd <- ldaX$svd[1:lda.dim] ldaX$scaling <- ldaX$scaling[,1:lda.dim,drop=FALSE] if(is.null(n.da)){ barplot(ldaX$svd^2, xlab="Linear Discriminants", ylab="F-statistic", main="Discriminant analysis eigenvalues", col=heat.colors(length(levels(pop.fac))) ) cat("Choose the number discriminant functions to retain (>=1): ") n.da <- as.integer(readLines(n = 1)) } n.da <- min(n.da, length(levels(pop.fac))-1, n.pca, sum(ldaX$svd>1e-10)) # can't be more than K-1 disc. func., or more than n.pca n.da <- round(n.da) predX <- predict(ldaX, dimen=n.da) ## BUILD RESULT res <- list() res$n.pca <- n.pca res$n.da <- n.da res$tab <- XU res$grp <- pop.fac res$var <- XU.lambda res$eig <- ldaX$svd^2 res$loadings <- ldaX$scaling[, 1:n.da, drop=FALSE] res$means <- ldaX$means res$ind.coord <-predX$x res$grp.coord <- apply(res$ind.coord, 2, tapply, pop.fac, mean) res$prior <- ldaX$prior res$posterior <- predX$posterior res$assign <- predX$class res$call <- match.call() ## optional: store loadings of variables if(pca.info){ res$pca.loadings <- as.matrix(U) res$pca.cent <- glMean(x,alleleAsUnit=FALSE) if(scale) { res$pca.norm <- sqrt(glVar(x,alleleAsUnit=FALSE)) } else { res$pca.norm <- rep(1, nLoc(x)) } res$pca.eig <- pcaX$eig } ## optional: get loadings of variables if(var.contrib){ res$var.contr <- as.matrix(U) %*% as.matrix(ldaX$scaling[,1:n.da,drop=FALSE]) f1 <- function(x){ temp <- sum(x*x) if(temp < 1e-12) return(rep(0, length(x))) return(x*x / temp) } res$var.contr <- apply(res$var.contr, 2, f1) } class(res) <- "dapc" return(res) } # end dapc.genlight ###################### # Function print.dapc ###################### print.dapc <- function(x, ...){ cat("\t#################################################\n") cat("\t# Discriminant Analysis of Principal Components #\n") cat("\t#################################################\n") cat("class: ") cat(class(x)) cat("\n$call: ") print(x$call) cat("\n$n.pca:", x$n.pca, "first PCs of PCA used") cat("\n$n.da:", x$n.da, "discriminant functions saved") cat("\n$var (proportion of conserved variance):", round(x$var,3)) cat("\n\n$eig (eigenvalues): ") l0 <- sum(x$eig >= 0) cat(signif(x$eig, 4)[1:(min(5, l0))]) if (l0 > 5) cat(" ...\n\n") ## vectors TABDIM <- 4 if(!is.null(x$pca.loadings)){ TABDIM <- TABDIM + 3 } sumry <- array("", c(TABDIM, 3), list(1:TABDIM, c("vector", "length", "content"))) sumry[1, ] <- c('$eig', length(x$eig), 'eigenvalues') sumry[2, ] <- c('$grp', length(x$grp), 'prior group assignment') sumry[3, ] <- c('$prior', length(x$prior), 'prior group probabilities') sumry[4, ] <- c('$assign', length(x$assign), 'posterior group assignment') if(!is.null(x$pca.loadings)){ sumry[5, ] <- c('$pca.cent', length(x$pca.cent), 'centring vector of PCA') sumry[6, ] <- c('$pca.norm', length(x$pca.norm), 'scaling vector of PCA') sumry[7, ] <- c('$pca.eig', length(x$pca.eig), 'eigenvalues of PCA') } class(sumry) <- "table" print(sumry) ## data.frames cat("\n") TABDIM <- 6 if(!is.null(x$pca.loadings)){ TABDIM <- TABDIM + 1 } if(!is.null(x$var.contr)){ TABDIM <- TABDIM + 1 } sumry <- array("", c(TABDIM, 4), list(1:TABDIM, c("data.frame", "nrow", "ncol", "content"))) sumry[1, ] <- c("$tab", nrow(x$tab), ncol(x$tab), "retained PCs of PCA") sumry[2, ] <- c("$means", nrow(x$means), ncol(x$means), "group means") sumry[3, ] <- c("$loadings", nrow(x$loadings), ncol(x$loadings), "loadings of variables") sumry[4, ] <- c("$ind.coord", nrow(x$ind.coord), ncol(x$ind.coord), "coordinates of individuals (principal components)") sumry[5, ] <- c("$grp.coord", nrow(x$grp.coord), ncol(x$grp.coord), "coordinates of groups") sumry[6, ] <- c("$posterior", nrow(x$posterior), ncol(x$posterior), "posterior membership probabilities") if(!is.null(x$pca.loadings)){ sumry[7, ] <- c("$pca.loadings", nrow(x$pca.loadings), ncol(x$pca.loadings), "PCA loadings of original variables") } if(!is.null(x$var.contr)){ sumry[TABDIM, ] <- c("$var.contr", nrow(x$var.contr), ncol(x$var.contr), "contribution of original variables") } class(sumry) <- "table" print(sumry) ## cat("\nother elements: ") ## if (length(names(x)) > 15) ## cat(names(x)[15:(length(names(x)))], "\n") ## else cat("NULL\n") cat("\n") } # end print.dapc ############## ## summary.dapc ############## summary.dapc <- function(object, ...){ if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") x <- object res <- list() ## number of dimensions res$n.dim <- ncol(x$loadings) res$n.pop <- length(levels(x$grp)) ## assignment success temp <- as.character(x$grp)==as.character(x$assign) res$assign.prop <- mean(temp) res$assign.per.pop <- tapply(temp, x$grp, mean) ## group sizes res$prior.grp.size <- table(x$grp) res$post.grp.size <- table(x$assign) return(res) } # end summary.dapc ############## ## scatter.dapc ############## scatter.dapc <- function(x, xax=1, yax=2, grp=x$grp, col=rainbow(length(levels(grp))), pch=20, bg="lightgrey", solid=.7, scree.da=TRUE, scree.pca=FALSE, posi.da="bottomright", posi.pca="bottomleft", bg.inset="white", ratio.da=.25, ratio.pca=.25, inset.da=0.02, inset.pca=0.02, inset.solid=.5, onedim.filled=TRUE, mstree=FALSE, lwd=1, lty=1, segcol="black", legend=FALSE, posi.leg="topright", cleg=1, txt.leg=levels(grp), cstar = 1, cellipse = 1.5, axesell = FALSE, label = levels(grp), clabel = 1, xlim = NULL, ylim = NULL, grid = FALSE, addaxes = TRUE, origin = c(0,0), include.origin = TRUE, sub = "", csub = 1, possub = "bottomleft", cgrid = 1, pixmap = NULL, contour = NULL, area = NULL, ...){ if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") ONEDIM <- xax==yax | ncol(x$ind.coord)==1 ## recycle color and pch col <- rep(col, length(levels(grp))) pch <- rep(pch, length(levels(grp))) col <- transp(col, solid) bg.inset <- transp(bg.inset, inset.solid) ## handle grp if(is.null(grp)){ grp <- x$grp } if(!ONEDIM){ ## set par opar <- par(mar = par("mar")) par(mar = c(0.1, 0.1, 0.1, 0.1), bg=bg) on.exit(par(opar)) axes <- c(xax,yax) ## basic empty plot ## s.label(x$ind.coord[,axes], clab=0, cpoint=0, grid=FALSE, addaxes = FALSE, cgrid = 1, include.origin = FALSE, ...) s.class(x$ind.coord[,axes], fac=grp, col=col, cpoint=0, cstar = cstar, cellipse = cellipse, axesell = axesell, label = label, clabel = clabel, xlim = xlim, ylim = ylim, grid = grid, addaxes = addaxes, origin = origin, include.origin = include.origin, sub = sub, csub = csub, possub = possub, cgrid = cgrid, pixmap = pixmap, contour = contour, area = area) ## add points colfac <- pchfac <- grp levels(colfac) <- col levels(pchfac) <- pch colfac <- as.character(colfac) pchfac <- as.character(pchfac) if(is.numeric(col)) colfac <- as.numeric(colfac) if(is.numeric(pch)) pchfac <- as.numeric(pchfac) points(x$ind.coord[,xax], x$ind.coord[,yax], col=colfac, pch=pchfac, ...) s.class(x$ind.coord[,axes], fac=grp, col=col, cpoint=0, add.plot=TRUE, cstar = cstar, cellipse = cellipse, axesell = axesell, label = label, clabel = clabel, xlim = xlim, ylim = ylim, grid = grid, addaxes = addaxes, origin = origin, include.origin = include.origin, sub = sub, csub = csub, possub = possub, cgrid = cgrid, pixmap = pixmap, contour = contour, area = area) ## add minimum spanning tree if needed if(mstree && require(ade4)){ meanposi <- apply(x$tab,2, tapply, grp, mean) D <- dist(meanposi)^2 tre <- ade4::mstree(D) x0 <- x$grp.coord[tre[,1], axes[1]] y0 <- x$grp.coord[tre[,1], axes[2]] x1 <- x$grp.coord[tre[,2], axes[1]] y1 <- x$grp.coord[tre[,2], axes[2]] segments(x0, y0, x1, y1, lwd=lwd, lty=lty, col=segcol) } } else { ## get plotted axis if(ncol(x$ind.coord)==1) { pcLab <- 1 } else{ pcLab <- xax } ## get densities ldens <- tapply(x$ind.coord[,pcLab], grp, density) allx <- unlist(lapply(ldens, function(e) e$x)) ally <- unlist(lapply(ldens, function(e) e$y)) par(bg=bg) plot(allx, ally, type="n", xlab=paste("Discriminant function", pcLab), ylab="Density") for(i in 1:length(ldens)){ if(!onedim.filled) { lines(ldens[[i]]$x,ldens[[i]]$y, col=col[i], lwd=2) # add lines } else { polygon(c(ldens[[i]]$x,rev(ldens[[i]]$x)),c(ldens[[i]]$y,rep(0,length(ldens[[i]]$x))), col=col[i], lwd=2, border=col[i]) # add lines } points(x=x$ind.coord[grp==levels(grp)[i],pcLab], y=rep(0, sum(grp==levels(grp)[i])), pch="|", col=col[i]) # add points for indiv } } ## ADD INSETS ## ## group legend if(legend){ ## add a legend temp <- list(...)$cex if(is.null(temp)) temp <- 1 if(ONEDIM | temp<0.5 | all(pch=="")) { legend(posi.leg, fill=col, legend=txt.leg, cex=cleg, bg=bg.inset) } else { legend(posi.leg, col=col, legend=txt.leg, cex=cleg, bg=bg.inset, pch=pch, pt.cex=temp) } } ## eigenvalues discriminant analysis if(scree.da && ratio.da>.01) { inset <- function(){ myCol <- rep("white", length(x$eig)) myCol[1:x$n.da] <- "grey" myCol[c(xax, yax)] <- "black" myCol <- transp(myCol, inset.solid) barplot(x$eig, col=myCol, xaxt="n", yaxt="n", ylim=c(0, x$eig[1]*1.1)) mtext(side=3, "DA eigenvalues", line=-1.2, adj=.8) box() } add.scatter(inset(), posi=posi.da, ratio=ratio.da, bg.col=bg.inset, inset=inset.da) ##add.scatter.eig(x$eig, ncol(x$loadings), axes[1], axes[2], posi=posi, ratio=ratio, csub=csub) # does not allow for bg } ## eigenvalues PCA if(scree.pca && !is.null(x$pca.eig) && ratio.pca>.01) { inset <- function(){ temp <- 100* cumsum(x$pca.eig) / sum(x$pca.eig) myCol <- rep(c("black","grey"), c(x$n.pca, length(x$pca.eig))) myCol <- transp(myCol, inset.solid) plot(temp, col=myCol, ylim=c(0,115), type="h", xaxt="n", yaxt="n", xlab="", ylab="", lwd=2) mtext(side=3, "PCA eigenvalues", line=-1.2, adj=.1) } add.scatter(inset(), posi=posi.pca, ratio=ratio.pca, bg.col=bg.inset, inset=inset.pca) } return(invisible(match.call())) } # end scatter.dapc ############ ## assignplot ############ assignplot <- function(x, only.grp=NULL, subset=NULL, new.pred=NULL, cex.lab=.75, pch=3){ if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") if(!inherits(x, "dapc")) stop("x is not a dapc object") ## handle data from predict.dapc ## if(!is.null(new.pred)){ n.new <- length(new.pred$assign) x$grp <- c(as.character(x$grp), rep("unknown", n.new)) x$assign <- c(as.character(x$assign), as.character(new.pred$assign)) x$posterior <- rbind(x$posterior, new.pred$posterior) } ## treat other arguments ## if(!is.null(only.grp)){ only.grp <- as.character(only.grp) ori.grp <- as.character(x$grp) x$grp <- x$grp[only.grp==ori.grp] x$assign <- x$assign[only.grp==ori.grp] x$posterior <- x$posterior[only.grp==ori.grp, , drop=FALSE] } else if(!is.null(subset)){ x$grp <- x$grp[subset] x$assign <- x$assign[subset] x$posterior <- x$posterior[subset, , drop=FALSE] } ##table.paint(x$posterior, col.lab=ori.grp, ...) ## symbols(x$posterior) ## FIND PLOT PARAMETERS n.grp <- ncol(x$posterior) n.ind <- nrow(x$posterior) Z <- t(x$posterior) Z <- Z[,ncol(Z):1,drop=FALSE ] image(x=1:n.grp, y=seq(.5, by=1, le=n.ind), Z, col=rev(heat.colors(100)), yaxt="n", ylab="", xaxt="n", xlab="Clusters") axis(side=1, at=1:n.grp,tick=FALSE, labels=colnames(x$posterior)) axis(side=2, at=seq(.5, by=1, le=n.ind), labels=rev(rownames(x$posterior)), las=1, cex.axis=cex.lab) abline(h=1:n.ind, col="lightgrey") abline(v=seq(0.5, by=1, le=n.grp)) box() newGrp <- colnames(x$posterior) x.real.coord <- rev(match(x$grp, newGrp)) y.real.coord <- seq(.5, by=1, le=n.ind) points(x.real.coord, y.real.coord, col="deepskyblue2", pch=pch) return(invisible(match.call())) } # end assignplot ############ ## compoplot ############ compoplot <- function(x, only.grp=NULL, subset=NULL, new.pred=NULL, col=NULL, lab=NULL, legend=TRUE, txt.leg=NULL, ncol=4, posi=NULL, cleg=.8, bg=transp("white"), ...){ if(!require(ade4, quietly=TRUE)) stop("ade4 library is required.") if(!inherits(x, "dapc")) stop("x is not a dapc object") ## HANDLE ARGUMENTS ## ngrp <- length(levels(x$grp)) ## col if(is.null(col)){ col <- rainbow(ngrp) } ## lab if(is.null(lab)){ lab <- rownames(x$tab) } else { ## recycle labels lab <- rep(lab, le=nrow(x$tab)) } ## posi if(is.null(posi)){ posi <- list(x=0, y=-.01) } ## txt.leg if(is.null(txt.leg)){ txt.leg <- levels(x$grp) } ## HANDLE DATA FROM PREDICT.DAPC ## if(!is.null(new.pred)){ n.new <- length(new.pred$assign) x$grp <- c(as.character(x$grp), rep("unknown", n.new)) x$assign <- c(as.character(x$assign), as.character(new.pred$assign)) x$posterior <- rbind(x$posterior, new.pred$posterior) lab <- c(lab, rownames(new.pred$posterior)) } ## TREAT OTHER ARGUMENTS ## if(!is.null(only.grp)){ only.grp <- as.character(only.grp) ori.grp <- as.character(x$grp) x$grp <- x$grp[only.grp==ori.grp] x$assign <- x$assign[only.grp==ori.grp] x$posterior <- x$posterior[only.grp==ori.grp, , drop=FALSE] lab <- lab[only.grp==ori.grp] } else if(!is.null(subset)){ x$grp <- x$grp[subset] x$assign <- x$assign[subset] x$posterior <- x$posterior[subset, , drop=FALSE] lab <- lab[subset] } ## MAKE THE PLOT ## Z <- t(x$posterior) barplot(Z, border=NA, col=col, ylab="membership probability", names=lab, las=3, ...) if(legend){ oxpd <- par("xpd") par(xpd=TRUE) legend(posi, fill=col, leg=txt.leg, cex=cleg, ncol=ncol, bg=bg) on.exit(par(xpd=oxpd)) } return(invisible(match.call())) } # end compoplot ############### ## a.score ############### a.score <- function(x, n.sim=10, ...){ if(!inherits(x,"dapc")) stop("x is not a dapc object") ## perform DAPC based on permuted groups lsim <- lapply(1:n.sim, function(i) summary(dapc(x$tab, sample(x$grp), n.pca=x$n.pca, n.da=x$n.da))$assign.per.pop) sumry <- summary(x) ## get the a-scores f1 <- function(Pt, Pf){ tol <- 1e-7 ##res <- (Pt-Pf) / (1-Pf) ##res[Pf > (1-tol)] <- 0 res <- Pt-Pf return(res) } lscores <- lapply(lsim, function(e) f1(sumry$assign.per.pop, e)) ## make a table of a-scores tab <- data.frame(lscores) colnames(tab) <- paste("sim", 1:n.sim, sep=".") rownames(tab) <- names(sumry$assign.per.pop) tab <- t(as.matrix(tab)) ## make result res <- list() res$tab <- tab res$pop.score <- apply(tab, 2, mean) res$mean <- mean(tab) return(res) } # end a.score ############## ## optim.a.score ############## optim.a.score <- function(x, n.pca=1:ncol(x$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10, n.da=length(levels(x$grp)), ...){ ## A FEW CHECKS ## if(!inherits(x,"dapc")) stop("x is not a dapc object") if(max(n.pca)>ncol(x$tab)) { n.pca <- min(n.pca):ncol(x$tab) } if(n.da>length(levels(x$grp))){ n.da <- min(n.da):length(levels(x$grp)) } pred <- NULL if(length(n.pca)==1){ n.pca <- 1:n.pca } if(length(n.da)==1){ n.da <- 1:n.da } ## AUXILIARY FUNCTION ## f1 <- function(ndim){ temp <- dapc(x$tab[,1:ndim,drop=FALSE], x$grp, n.pca=ndim, n.da=x$n.da) a.score(temp, n.sim=n.sim)$pop.score } ## SMART: COMPUTE A FEW VALUES, PREDICT THE BEST PICK ## if(smart){ if(!require(stats)) stop("the package stats is required for 'smart' option") o.min <- min(n.pca) o.max <- max(n.pca) n.pca <- pretty(n.pca, n) # get evenly spaced nb of retained PCs n.pca <- n.pca[n.pca>0 & n.pca<=ncol(x$tab)] if(!any(o.min==n.pca)) n.pca <- c(o.min, n.pca) # make sure range is OK if(!any(o.max==n.pca)) n.pca <- c(o.max, n.pca) # make sure range is OK lres <- lapply(n.pca, f1) names(lres) <- n.pca means <- sapply(lres, mean) sp1 <- smooth.spline(n.pca, means) # spline smoothing pred <- predict(sp1, x=1:max(n.pca)) best <- pred$x[which.max(pred$y)] } else { ## DO NOT TRY TO BE SMART ## lres <- lapply(n.pca, f1) names(lres) <- n.pca best <- which.max(sapply(lres, mean)) means <- sapply(lres, mean) } ## MAKE FINAL OUTPUT ## res <- list() res$pop.score <- lres res$mean <- means if(!is.null(pred)) res$pred <- pred res$best <- best ## PLOTTING (OPTIONAL) ## if(plot){ if(smart){ boxplot(lres, at=n.pca, col="gold", xlab="Number of retained PCs", ylab="a-score", xlim=range(n.pca)+c(-1,1), ylim=c(-.1,1.1)) lines(pred, lwd=3) points(pred$x[best], pred$y[best], col="red", lwd=3) title("a-score optimisation - spline interpolation") mtext(paste("Optimal number of PCs:", res$best), side=3) } else { myCol <- rep("gold", length(lres)) myCol[best] <- "red" boxplot(lres, at=n.pca, col=myCol, xlab="Number of retained PCs", ylab="a-score", xlim=range(n.pca)+c(-1,1), ylim=c(-.1,1.1)) lines(n.pca, sapply(lres, mean), lwd=3, type="b") myCol <- rep("black", length(lres)) myCol[best] <- "red" points(n.pca, res$mean, lwd=3, col=myCol) title("a-score optimisation - basic search") mtext(paste("Optimal number of PCs:", res$best), side=3) } } return(res) } # end optim.a.score ############# ## as.lda.dapc ############# as.lda <- function(...){ UseMethod("as.lda") } as.lda.dapc <- function(x, ...){ if(!inherits(x,"dapc")) stop("x is not a dapc object") res <- list() res$N <- nrow(res$ind.coord) res$call <- match.call() res$counts <- as.integer(table(x$grp)) res$lev <- names(res$counts) <- levels(x$grp) res$means <- x$means res$prior <- x$prior res$scaling <- x$loadings res$svd <- sqrt(x$eig) class(res) <- "lda" return(res) } # end as.lda.dapc ############## ## predict.dapc ############## predict.dapc <- function(object, newdata, prior = object$prior, dimen, method = c("plug-in", "predictive", "debiased"), ...){ if(!inherits(object,"dapc")) stop("x is not a dapc object") method <- match.arg(method) x <- as.lda(object) ## HANDLE NEW DATA ## if(!missing(newdata)){ ## make a few checks if(is.null(object$pca.loadings)) stop("DAPC object does not contain loadings of original variables. \nPlease re-run DAPC using 'pca.loadings=TRUE'.") newdata <- as.matrix(newdata) # to force conversion, notably from genlight objects if(ncol(newdata) != nrow(object$pca.loadings)) stop("Number of variables in newdata does not match original data.") ## centre/scale data for(i in 1:nrow(newdata)){ # this is faster for large, flat matrices) newdata[i,] <- (newdata[i,] - object$pca.cent) / object$pca.norm } newdata[is.na(newdata)] <- 0 ## project as supplementary individuals XU <- newdata %*% as.matrix(object$pca.loadings) } else { XU <- object$tab } ## FORCE IDENTICAL VARIABLE NAMES ## colnames(XU) <- colnames(object$tab) ## HANDLE DIMEN ## if(!missing(dimen)){ if(dimen > object$n.da) stop(paste("Too many dimensions requested. \nOnly", object$n.da, "discriminant functions were saved in DAPC.")) } else { dimen <- object$n.da } ## CALL PREDICT.LDA ## temp <- predict(x, XU, prior, dimen, method, ...) ## FORMAT OUTPUT ## res <- list() res$assign <- temp$class res$posterior <- temp$posterior res$ind.scores <- temp$x return(res) } # end predict.dapc ## ############ ## ## crossval ## ############ xval <- function (object, n.pca, n.da, training.set, ...) UseMethod("xval") xval.dapc <- function(object, n.pca, n.da, training.set = 90, ...){ training.set = training.set/100 kept.id <- unlist(tapply(1:nInd(object), pop(object), function(e) {pop.size = length(e); pop.size.train = round(pop.size * training.set); sample(e, pop.size.train, replace=FALSE)})) training <- object[kept.id] validating <- object[-kept.id] post = vector(mode = 'list', length = n.pca) asgn = vector(mode = 'list', length = n.pca) ind = vector(mode = 'list', length = n.pca) mtch = vector(mode = 'list', length = n.pca) for(i in 1:n.pca){ dapc.base = dapc(training, n.pca = i, n.da = 15) dapc.p = predict.dapc(dapc.base, newdata = validating) match.prp = mean(as.character(dapc.p$assign)==as.character(pop(validating))) post[[i]] = dapc.p$posterior asgn[[i]] = dapc.p$assign ind[[i]] = dapc.p$ind.score mtch[[i]] = match.prp } res = list(assign = asgn, posterior = post, ind.score = ind, match.prp = mtch) return(res) } # end of xval.dapc ## ############### ## ## randtest.dapc ## ############### ## ##randtest.dapc <- function(x, nperm = 999, ...){ ## ##} # end randtest.dapc ######## TESTS IN R ####### ## TEST PREDICT.DAPC ## ## data(sim2pop) ## temp <- seppop(sim2pop) ## temp <- lapply(temp, function(e) hybridize(e,e,n=30)) # force equal pop sizes ## hyb <- hybridize(temp[[1]], temp[[2]], n=30) ## newdat <- repool(temp[[1]], temp[[2]], hyb) ## pop(newdat) <- rep(c("pop A", "popB", "hyb AB"), c(30,30,30)) ## ##dapc1 <- dapc(newdat[1:61],n.pca=10,n.da=1) ## dapc1 <- dapc(newdat[1:60],n.pca=2,n.da=1) ## scatter(dapc1) ## hyb.pred <- predict(dapc1, newdat[61:90]) ## scatter(dapc1) ## points(hyb.pred$ind.scores, rep(.1, 30)) ## assignplot(dapc1, new.pred=hyb.pred) ## title("30 indiv popA, 30 indiv pop B, 30 hybrids") Modified: pkg/R/dapc.R =================================================================== --- pkg/R/dapc.R 2013-04-25 10:09:54 UTC (rev 1115) +++ pkg/R/dapc.R 2013-04-25 14:56:56 UTC (rev 1116) @@ -986,9 +986,9 @@ ## ############ ## ## crossval ## ############ -#xval <- function (x, ...) UseMethod("xval") +xval <- function (object, n.pca, n.da, training.set, ...) UseMethod("xval") -xval.dapc <- function(object, n.pca, n.da, training.set = 90){ +xval.dapc <- function(object, n.pca, n.da, training.set = 90, ...){ training.set = training.set/100 kept.id <- unlist(tapply(1:nInd(object), pop(object), function(e) {pop.size = length(e); pop.size.train = round(pop.size * training.set); sample(e, pop.size.train, replace=FALSE)})) training <- object[kept.id] Modified: pkg/man/dapc.Rd =================================================================== --- pkg/man/dapc.Rd 2013-04-25 10:09:54 UTC (rev 1115) +++ pkg/man/dapc.Rd 2013-04-25 14:56:56 UTC (rev 1116) @@ -9,6 +9,7 @@ \alias{print.dapc} \alias{summary.dapc} \alias{predict.dapc} +\alias{xval} \alias{xval.dapc} \alias{as.lda} \alias{as.lda.dapc} @@ -76,7 +77,7 @@ \method{predict}{dapc}(object, newdata, prior = object$prior, dimen, method = c("plug-in", "predictive", "debiased"), ...) -\method{xval}{dapc}(object, n.pca, n.da, training.set = 90) +\method{xval}{dapc}(object, n.pca, n.da, training.set = 90, \ldots) } \arguments{ \item{x}{\code{a data.frame}, \code{matrix}, or \code{\linkS4class{genind}} From noreply at r-forge.r-project.org Thu Apr 25 18:32:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 25 Apr 2013 18:32:37 +0200 (CEST) Subject: [adegenet-commits] r1117 - in pkg: R man Message-ID: <20130425163237.91D47185557@r-forge.r-project.org> Author: greatsage Date: 2013-04-25 18:32:37 +0200 (Thu, 25 Apr 2013) New Revision: 1117 Modified: pkg/R/dapc.R pkg/man/dapc.Rd Log: fixed classes Modified: pkg/R/dapc.R =================================================================== --- pkg/R/dapc.R 2013-04-25 14:56:56 UTC (rev 1116) +++ pkg/R/dapc.R 2013-04-25 16:32:37 UTC (rev 1117) @@ -986,7 +986,6 @@ ## ############ ## ## crossval ## ############ -xval <- function (object, n.pca, n.da, training.set, ...) UseMethod("xval") xval.dapc <- function(object, n.pca, n.da, training.set = 90, ...){ training.set = training.set/100 @@ -1010,6 +1009,11 @@ return(res) } # end of xval.dapc +xval <- function (object, n.pca, n.da, training.set, ...) UseMethod("xval") +xval.genind <- function(object, n.pca, n.da, training.set = 90, ...){ + res = xval.dapc(object = object, n.pca = n.pca, n.da = n.da, training.set = training.set) + return(res) +} ## ############### ## ## randtest.dapc ## ############### Modified: pkg/man/dapc.Rd =================================================================== --- pkg/man/dapc.Rd 2013-04-25 14:56:56 UTC (rev 1116) +++ pkg/man/dapc.Rd 2013-04-25 16:32:37 UTC (rev 1117) @@ -9,8 +9,9 @@ \alias{print.dapc} \alias{summary.dapc} \alias{predict.dapc} +\alias{xval.dapc} \alias{xval} -\alias{xval.dapc} +\alias{xval.genind} \alias{as.lda} \alias{as.lda.dapc} \title{Discriminant Analysis of Principal Components (DAPC)} @@ -40,8 +41,11 @@ - \code{summary.dapc}: extracts useful information from a \code{dapc} object.\cr - \code{predict.dapc}: predicts group memberships based on DAPC results.\cr - \code{xval.dapc}: performs cross-validation of DAPC function varying the number of PCs and keeping the number of DAs fixed. + - \code{xval}: performs cross-validation of DAPC function varying the number of PCs and keeping the number of DAs fixed. + - \code{xval.genind}: performs cross-validation of DAPC function varying the number of PCs and keeping the number of DAs fixed. + DAPC implementation calls upon \code{\link[ade4]{dudi.pca}} from the \code{ade4} package (except for \linkS4class{genlight} objects) and \code{\link[MASS]{lda}} from the \code{MASS} package. The @@ -78,6 +82,8 @@ method = c("plug-in", "predictive", "debiased"), ...) \method{xval}{dapc}(object, n.pca, n.da, training.set = 90, \ldots) + +\method{xval}{genind}(object, n.pca, n.da, training.set = 90, \ldots) } \arguments{ \item{x}{\code{a data.frame}, \code{matrix}, or \code{\linkS4class{genind}} @@ -192,7 +198,7 @@ \code{assign.prop} (proportion of overall correct assignment), \code{assign.per.pop} (proportion of correct assignment per group), \code{prior.grp.size} (prior group sizes), and \code{post.grp.size} (posterior - group sizes), \code{xval.dapc} (returns a list of four lists, each one with as + group sizes), \code{xval.dapc}, \code{xval.genind} and \code{xval} (all return a list of four lists, each one with as many items as cross-validation runs. The first item is a list of \code{assign} components, the secon is a list of \code{posterior} components, the thirs is a list of \code{ind.score} components and the fourth is a list of \code{match.prp} items, i.e. the prortion of the validation @@ -326,6 +332,12 @@ plot(unlist(crossval.test$match.prp)) +# the use can also just call xval: +crossval.test2 <- xval(microbov, n.pca = 40, n.da = 15, training.set = 90) +plot(unlist(crossval.test2$match.prp)) + + + } From noreply at r-forge.r-project.org Thu Apr 25 19:08:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 25 Apr 2013 19:08:20 +0200 (CEST) Subject: [adegenet-commits] r1118 - www Message-ID: <20130425170820.4187D185072@r-forge.r-project.org> Author: jombart Date: 2013-04-25 19:08:19 +0200 (Thu, 25 Apr 2013) New Revision: 1118 Modified: www/acceuil.html Log: modified the frontpage - adding contributors info Modified: www/acceuil.html =================================================================== --- www/acceuil.html 2013-04-25 16:32:37 UTC (rev 1117) +++ www/acceuil.html 2013-04-25 17:08:19 UTC (rev 1118) @@ -1,7 +1,7 @@ - adegenet on the web -

- title title



-
- adegenet is an adegenet + is an package - dedicated to the exploratory analysis of genetic data. It - implements a set of + height: 23px;"> package dedicated to the + exploratory analysis of genetic data. It implements a set of tools ranging from multivariate methods to spatial genetics and - genome-wise SNP - data analysis.
+ genome-wise SNP data analysis.

It is developed on R-Forge by Thibaut - Jombart, Ismail - Ahmed, Anne Cori, Tobias Erik Reiners, and Péter - Sólymos, and officially released on CRAN periodically.
+ Jombart, Ismail Ahmed, Federico + + Calboli, Anne + Cori, Tobias Erik Reiners, and P?ter S?lymos, + and officially released on CRAN + periodically.

adegenet is described in the following application notes:
Jombart T. (2008)adegenet: a R package for - the multivariate - analysis of genetic markers. Bioinformatics - 24: 1403-1405. doi: + style="font-weight: bold;"> adegenet: a R package for + the multivariate analysis of genetic markers. Bioinformatics 24: 1403-1405. doi: 10.1093/bioinformatics/btn129 [link to a free pdf]

Jombart T. and Ahmed I. (2011) adegenet - 1.3-1: new tools for the analysis of genome-wide SNP - data. Bioinformatics. - doi: - 10.1093/bioinformatics/btr521 [adegenet 1.3-1: new tools for the analysis of + genome-wide SNP data. Bioinformatics. + doi: 10.1093/bioinformatics/btr521 [link to + + the bublisher's website]


-
-
+


-
- sPCA, DAPC, typological coherence of markers, - Monmonier  algorithm, - ...
+
sPCA, DAPC, + typological coherence of markers, Monmonier  + algorithm, ...


Main - features of adegenet - are:
+ features of adegenet are:
- data representation (classes) suitable for multivariate analysis
- data import from - GENETIX, STRUCTURE, - Genepop, Fstat, Easypop, or any dataframe of genotypes
+ GENETIX, STRUCTURE, Genepop, Fstat, Easypop, or any dataframe of + genotypes
- data import from aligned DNA sequences to SNPs
- data import from aligned - protein - sequences to polymorphic sites -
+ protein sequences to polymorphic sites
- data export to the R - packages - genetics, hierfstat, LDheatmap
+ packages genetics, hierfstat, LDheatmap
- handling of different levels of ploidy
- handling of codominant + + markersandpresence/absence data
- basic and advanced data + + manipulation
- - basic data information - (heterozygosity, numbers of alleles, sample sizes, ...)
+ - basic data information (heterozygosity, + + numbers of alleles, sample sizes, ...)
- HWE and G-statistic tests, F statistics - implemented for adegenet - objects
+ implemented for adegenet objects
- computation of genetic distances
- computation of pairwise - Fst -
+ + + Fst
- simulation of hybridization
- methods for spatial genetics: sPCA, tests for global and local structuring, Monmonier + + algorithm
- the seqTrackalgorithm - for reconstructing genealogies of - haplotypes
+ + +
for reconstructing genealogies of haplotypes
- simulation of genealogies - of - haplotypes
+ + + of haplotypes
- Discriminant Analysis of Principal Components (DAPC)
- efficient genome-wise SNP data handling and analysis
- extraction of SNPs from genomic alignments
- graph-based clustering - of genomic - data
+ of genomic data
- identification of mutations between pairs of sequences

Maintainer
: - Thibaut Jombart - (website)
Developers: - Thibaut Jombart - (tjombart at imperial.ac.uk), - Ismaïl - Ahmed (ismail.ahmed at inserm.fr), -Anne - Cori (a.cori at imperial.ac.uk), + Thibaut Jombart (tjombart at imperial.ac.uk), + + + Isma?l Ahmed (ismail.ahmed at inserm.fr), +Federico + Calboli (f.calboli at imperial.ac.uk), + Anne Cori (a.cori at imperial.ac.uk), Tobias + + Erik Reiners (Tobias.Reiners at Senckenberg.de), - Péter Sólymos
+ + + P?ter S?lymos (solymos at ualberta.ca)
Contributors (datasets/ideas): Christophe Fraser, Katayoun - Moazami-Goudarzi, Denis Laloë, Francois Balloux, Dominique - Pontier, Daniel - Maillard
+ Moazami-Goudarzi, Denis Lalo?, Francois Balloux, Dominique + Pontier, Daniel Maillard


Suggestions, comments and contributions are most welcome!

From noreply at r-forge.r-project.org Mon Apr 29 17:54:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 29 Apr 2013 17:54:11 +0200 (CEST) Subject: [adegenet-commits] r1119 - www Message-ID: <20130429155411.2F37D184A93@r-forge.r-project.org> Author: jombart Date: 2013-04-29 17:54:10 +0200 (Mon, 29 Apr 2013) New Revision: 1119 Modified: www/acceuil.html Log: changed link for Federico Modified: www/acceuil.html =================================================================== --- www/acceuil.html 2013-04-25 17:08:19 UTC (rev 1118) +++ www/acceuil.html 2013-04-29 15:54:10 UTC (rev 1119) @@ -38,9 +38,7 @@ target="_top">R-Forge by Thibaut Jombart, Ismail Ahmed, Federico - - Calboli, Federico Calboli, Anne Cori, Tobias Erik Reiners, and P?ter S?lymos, @@ -66,6 +64,7 @@ to + the bublisher's website]


@@ -101,15 +100,18 @@
- handling of codominant + markersandpresence/absence data
- basic and advanced data + manipulation
- basic data information (heterozygosity, + numbers of alleles, sample sizes, ...)
- HWE and G-statistic - computation of pairwise + Fst
- simulation of hybridization
- methods for Monmonier + algorithm
- the seqTrackalgorithm + for reconstructing genealogies of haplotypes
- simulation of genealogies + of haplotypes
- Discriminant Analysis of Principal Components (DAPC)tjombart at imperial.ac.uk), + Isma?l Ahmed (ismail.ahmed at inserm.fr), Federico + Calboli (f.calboli at imperial.ac.uk), + Anne Cori (a.cori at imperial.ac.uk), Tobias + Erik Reiners (Tobias.Reiners at Senckenberg.de), + P?ter S?lymos (solymos at ualberta.ca)
Contributors (datasets/ideas): Christophe Fraser, Katayoun From noreply at r-forge.r-project.org Tue Apr 30 11:59:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 30 Apr 2013 11:59:19 +0200 (CEST) Subject: [adegenet-commits] r1120 - www Message-ID: <20130430095919.71771185373@r-forge.r-project.org> Author: jombart Date: 2013-04-30 11:59:19 +0200 (Tue, 30 Apr 2013) New Revision: 1120 Modified: www/literature.html Log: +1ref Modified: www/literature.html =================================================================== --- www/literature.html 2013-04-29 15:54:10 UTC (rev 1119) +++ www/literature.html 2013-04-30 09:59:19 UTC (rev 1120) @@ -62,6 +62,7 @@ + the bublisher's website]

@@ -93,6 +94,7 @@ + abstract]

- the paper presenting the spatial @@ -109,6 +111,7 @@ + principal component analysis (sPCA, function spca), global and @@ -128,6 +131,7 @@ + cryptic spatial patterns in genetic variability by a new multivariate method.  Heredity 101: 92-103. doi: @@ -148,6 +152,7 @@ + abstract]

@@ -170,6 +175,7 @@ + simulations of genealoies of haplotypes (haploGen):
Jombart T, Eggo RM, Dodd PJ, Balloux F (2010) @@ -192,6 +198,7 @@ + of Principal Components (DAPC, functions find.clusters @@ -222,6 +229,7 @@ + Behaviour76: 87-95.

@@ -241,6 +249,7 @@ + Genomics
9: 256.
@@ -275,6 +284,7 @@ + marmota.Molecular @@ -288,6 +298,7 @@ + Ecology 18: 1491-1503.

@@ -340,6 +351,7 @@ + australis in North America. Biological Invasions. doi: 10.1007/s10530-010-9699-6.
@@ -496,6 +508,7 @@ + Oct 6. [Epub ahead of print]

[24] SANTOS, H., BURBAN, C., ROUSSELET, J., @@ -513,6 +526,7 @@ + pityocampa, Lepidoptera, Notodontidae). Journal of Evolutionary Biology, no. doi: 10.1111/j.1420-9101.2010.02147.x
@@ -535,6 +549,7 @@ + Vol. Sci. Pap. ICCAT, 65(3): 988-995

[26] Vandewoestijne @@ -550,6 +565,7 @@ + S, Van Dyck H, 2010 Population Genetic @@ -568,6 +584,7 @@ + ONE5(11): e13810. doi:10.1371/journal.pone.0013810
@@ -597,6 +614,7 @@ +
DOI: 10.1007/s10329-010-0232-4

@@ -663,6 +681,7 @@ + tetradactylum: Polynemidae). Molecular Ecology, 20: no. doi: 10.1111/j.1365-294X.2011.05097.x

@@ -687,6 +706,7 @@ + neoformans Variety grubii Multilocus Sequence Types from Thailand Are Consistent with an Ancestral African Origin. PLoS @@ -943,6 +963,7 @@ + 10.1007/s10709-012-9640-2

[76] Samantha Baldwin, Meeghan Pither-Joyce, Kathryn Wright, @@ -1580,8 +1601,15 @@ ENVIRONMENTALLY-BASED SELECTION AS CAUSAL FACTORS. Evolution. DOI: 10.1111/evo.12121

+ [185] Hemmer-Hansen, J., Nielsen, E. E., Therkildsen, N. O., + Taylor, M. I., Ogden, R., Geffen, A. J., Bekkevold, D., Helyar, + S., Pampoulie, C., Johansen, T., FishPopTrace Consortium and + Carvalho, G. R. (2013), A genomic island linked to ecotype + divergence in Atlantic cod. Molecular Ecology, 22: 2653?2667. + doi: 10.1111/mec.12284


+

* adegenet not or wrongly cited, but actually used in the paper.