[adegenet-commits] r869 - pkg/R www
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 9 11:14:05 CEST 2011
Author: jombart
Date: 2011-05-09 11:14:04 +0200 (Mon, 09 May 2011)
New Revision: 869
Modified:
pkg/R/glPlot.R
pkg/R/glSim.R
www/literature.html
Log:
Added one ref.
Modified: pkg/R/glPlot.R
===================================================================
--- pkg/R/glPlot.R 2011-05-05 17:00:19 UTC (rev 868)
+++ pkg/R/glPlot.R 2011-05-09 09:14:04 UTC (rev 869)
@@ -20,7 +20,7 @@
col=myCol, ...)
## add y axis
- axis(side=2, at=nInd(x)-ylabpos, lab=ylabpos)
+ axis(side=2, at=nInd(x)-ylabpos+1, lab=ylabpos)
## add legend
if(legend){
Modified: pkg/R/glSim.R
===================================================================
--- pkg/R/glSim.R 2011-05-05 17:00:19 UTC (rev 868)
+++ pkg/R/glSim.R 2011-05-09 09:14:04 UTC (rev 869)
@@ -3,7 +3,7 @@
## glSim
##########
glSim <- function(n.ind, n.snp.nonstruc, n.snp.struc=0, grp.size=round(n.ind/2), ploidy=1, alpha=0,
- block.size=NULL){
+ block.size=NULL, LD=FALSE){
## BASIC CHECKS ##
if( any(c(n.ind, n.snp.nonstruc+n.snp.struc) <1)) stop("null numbers of individuals and/or SNPs requested")
@@ -29,26 +29,50 @@
## AUXIL FUNCTIONS ##
- ## draw p snp for i indiv and convert into a genlight - no structure
- f1 <- function(n,p){
- temp <- sapply(1:p, function(i) rbinom(n, ploidy, runif(1)))
- if(n==1) {temp <- matrix(temp,nrow=1)}
- return(new("genlight", temp, ploidy=ploidy))
- }
+ if(LD) { # LD - use mvrnorm
+ if(!require(MASS)) stop("MASS package is missing.")
+ QUANT <- qnorm(seq(0,1, le=ploidy+2), 0,1) # quantiles needed for continuous->discrete
- ## draw p snp for i indiv and convert into a genlight - differences between 2 groups
- if(n.snp.struc > 0){
- f2 <- function(n,p){
- probA <- runif(p, min=0, max=0.5-alpha)
- probB <- 1-probA
- tempA <- sapply(probA, function(i) rbinom(grpA.size, ploidy, i) )
- if(grpA.size==1) {tempA <- matrix(tempA,nrow=1)}
- tempB <- sapply(probB, function(i) rbinom(grpB.size, ploidy, i) )
- if(grpB.size==1) {tempB <- matrix(tempB,nrow=1)}
- return(new("genlight", rbind(tempA,tempB), ploidy=ploidy))
+ f1 <- function(n,p){
+ Sig <- matrix(runif(p^2), p, p)
+ Sig <- t(Sig) %*% Sig/2 # get the covariance matrix
+ temp <- mvrnorm(n, rep(0,p), Sig) # continuous data
+ temp <- matrix(as.integer(cut(temp, breaks=QUANT))-1, nrow=n, ncol=p)
+ return(new("genlight", temp, ploidy=ploidy))
}
+
+ if(n.snp.struc > 0){
+ if(alpha>1e-10) warning("assymetry parameter alpha ignored when LD used")
+ f2 <- function(n,p){
+ temp <-rbind(f1(grpA.size,p), f1(grpB.size,p))
+ ploidy(temp) <- ploidy
+ return(temp)
+ }
+ }
+ } else { # no LD - use rbinom
+ ## draw p snp for i indiv and convert into a genlight - no structure
+ f1 <- function(n,p){
+ temp <- sapply(1:p, function(i) rbinom(n, ploidy, runif(1)))
+ if(n==1) {temp <- matrix(temp,nrow=1)}
+ return(new("genlight", temp, ploidy=ploidy))
+ }
+
+ ## draw p snp for i indiv and convert into a genlight - differences between 2 groups
+ if(n.snp.struc > 0){
+ f2 <- function(n,p){
+ probA <- runif(p, min=0, max=0.5-alpha)
+ probB <- 1-probA
+ tempA <- sapply(probA, function(i) rbinom(grpA.size, ploidy, i) )
+ if(grpA.size==1) {tempA <- matrix(tempA,nrow=1)}
+ tempB <- sapply(probB, function(i) rbinom(grpB.size, ploidy, i) )
+ if(grpB.size==1) {tempB <- matrix(tempB,nrow=1)}
+ return(new("genlight", rbind(tempA,tempB), ploidy=ploidy))
+ }
+ }
}
+
+
## NON-STRUCTURED DATA ##
## generate data
if(n.snp.nonstruc <= block.size){ # no need to use blocks
Modified: www/literature.html
===================================================================
--- www/literature.html 2011-05-05 17:00:19 UTC (rev 868)
+++ www/literature.html 2011-05-09 09:14:04 UTC (rev 869)
@@ -442,7 +442,13 @@
<span class="citation_journal_title">PLoS Pathog</span><span
class="citation_issue"> 7(4):</span>
<span class="citation_start_page">e1001343.</span>
-<span class="citation_doi">doi:10.1371/journal.ppat.1001343</span> </p>
+<span class="citation_doi">doi:10.1371/journal.ppat.1001343<br>
+</span></p>
+<p class="intro">[37] CRISCIONE, C. D., VILAS, R., PANIAGUA, E. and
+BLOUIN, M. S. (2011), More than meets the eye: detecting cryptic
+microgeographic population structure in a parasite with a complex life
+cycle. Molecular Ecology, 20: no.
+doi: 10.1111/j.1365-294X.2011.05113.x </p>
<p class="intro"></p>
<p class="auth_list"></p>
<br>
More information about the adegenet-commits
mailing list