[adegenet-forum] propShared Alleles

Johannes Signer j.m.signer at gmail.com
Mon Jul 16 12:08:02 CEST 2012


Hello Thibaut,

thanks for your reply. I used version 1.3-4. I was unable to install 1.3-5
with R 2.15 and 2.15.1.

Best Johannes

install.packages("adegenet",repos="http://r-forge.r-project.org")
Warning message:
package ‘adegenet’ is not available (for R version 2.15.1)

And my session.info()

R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] adegenet_1.3-4     ade4_1.5-0         MASS_7.3-18
RColorBrewer_1.0-5
[5] stringr_0.6        plyr_1.7.1

loaded via a namespace (and not attached):
[1] tools_2.15.1


On Fri, Jul 13, 2012 at 6:58 PM, Jombart, Thibaut
<t.jombart at imperial.ac.uk>wrote:

> Hello,
>
> there was a bug in some old version of propShared. Are you using the
> latest version of adegenet (stable 1.3-4 or devel 1.3-5)?
>
> Cheers
>
> Thibaut
> ________________________________________
> From: adegenet-forum-bounces at lists.r-forge.r-project.org [
> adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Johannes
> Signer [j.m.signer at gmail.com]
> Sent: 13 July 2012 17:39
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] propShared Alleles
>
> Hello List,
>
> I am trying to calculate individual genetic distances with the function
> `adegenet::propShared`. I found that results from `propShared` did not
> correlate very well with other genetic distances such as Rousset'a. Based
> on this results, I wrote my own function to calculate proportion of shared
> alleles (see below). Results from this function do not correspond with the
> results from `propShared`, but correlates better with other Rousset's a. Am
> I missing something on the methodology of `propShared`?
>
> Thanks a lot for hints,
>
> Best
> Johannes
>
> #
> ---------------------------------------------------------------------------------------------------------------------------
> #
> # Example
>
> # Load packages
> library(adegenet)
> library(stringr)
> library(reshape2)
>
> # Own function to calculate proportion shared alleles
> # Following instruction from here:
> http://helix.biology.mcmaster.ca/brent/node8.html
> psa <- function(s) {
>     # s - each row is a genotype, first column is id
>
>     # all combinations
>     idx <- combn(1:nrow(s), 2)
>
>     # calculate distances
>     d <- 1 - apply(idx, 2, function(x) sum(apply(s[x, -1], 2, diff) == 0))
> / ncol(s[,-1])
>
>     # create object of class distance
>     nams <- unique(c(as.character(idx[1, ]), as.character(idx[2, ])))
>     dd <- structure(d, Size = length(nams), Labels = nams, Diag = FALSE,
> Upper = FALSE, method = "user", class = "dist")
>     return(dd)
> }
>
>
>
> # Example dataset
> dat <- data.frame(id=as.character(1:4), x=0, y=0,
>     l_1=c(108, 116, 122, 119),
>     l_2=c(110, 114, 152, 122),
>     m_1=c(110, 90, 122, 69),
>     m_2=c(110, 111, 128, 128))
>
>
> # Create genind
> coords <- dat[, 2:3]
> datMelted <- melt(dat[, c(1, 4:ncol(dat))])
>
> names(datMelted) <- c("ind", "loci", "allele")
>
> # removing 1 and 2, since it is the same loci
> datMelted$loci <- str_sub(as.character(datMelted$loci), end=-3)
>
> # Creating a genind object for the adegenet package
> datCasted <- dcast(datMelted, ind ~ loci, paste, collapse="/")
> gi <- df2genind(datCasted[, 2:ncol(datCasted)], sep="/", missing="NA",
> ind=datCasted[, 1])
>
>
> # calcualte proportion of shared alleles
> propShared(gi)
> as.matrix(psa(dat[, -c(2,3)]))
>
> # It is my understanding that propShared does not calcualte 1 - porpShared
> and is the reason for a systematic difference
> # However, ind 3 and 4 differ by one of four alleles (= 0.25), but
> propShared suggests 0.5
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20120716/6a57098b/attachment.html>


More information about the adegenet-forum mailing list