Hello Thibaut, <br><br>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.<br><br>Best Johannes<br><br>install.packages("adegenet",repos="<a href="http://r-forge.r-project.org">http://r-forge.r-project.org</a>")<br>
Warning message:<br>package ‘adegenet’ is not available (for R version 2.15.1) <br><br>And my <a href="http://session.info">session.info</a>()<br><br>R version 2.15.1 (2012-06-22)<br>Platform: x86_64-pc-linux-gnu (64-bit)<br>
<br>locale:<br> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C <br> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 <br> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 <br> [7] LC_PAPER=C LC_NAME=C <br>
[9] LC_ADDRESS=C LC_TELEPHONE=C <br>[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C <br><br>attached base packages:<br>[1] stats graphics grDevices utils datasets methods base <br>
<br>other attached packages:<br>[1] adegenet_1.3-4 ade4_1.5-0 MASS_7.3-18 RColorBrewer_1.0-5<br>[5] stringr_0.6 plyr_1.7.1 <br><br>loaded via a namespace (and not attached):<br>[1] tools_2.15.1<br>
<br><br><div class="gmail_quote">On Fri, Jul 13, 2012 at 6:58 PM, Jombart, Thibaut <span dir="ltr"><<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
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)?<br>
<br>
Cheers<br>
<br>
Thibaut<br>
________________________________________<br>
From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>] on behalf of Johannes Signer [<a href="mailto:j.m.signer@gmail.com">j.m.signer@gmail.com</a>]<br>
Sent: 13 July 2012 17:39<br>
To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
Subject: [adegenet-forum] propShared Alleles<br>
<div class="HOEnZb"><div class="h5"><br>
Hello List,<br>
<br>
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`?<br>
<br>
Thanks a lot for hints,<br>
<br>
Best<br>
Johannes<br>
<br>
# --------------------------------------------------------------------------------------------------------------------------- #<br>
# Example<br>
<br>
# Load packages<br>
library(adegenet)<br>
library(stringr)<br>
library(reshape2)<br>
<br>
# Own function to calculate proportion shared alleles<br>
# Following instruction from here: <a href="http://helix.biology.mcmaster.ca/brent/node8.html" target="_blank">http://helix.biology.mcmaster.ca/brent/node8.html</a><br>
psa <- function(s) {<br>
# s - each row is a genotype, first column is id<br>
<br>
# all combinations<br>
idx <- combn(1:nrow(s), 2)<br>
<br>
# calculate distances<br>
d <- 1 - apply(idx, 2, function(x) sum(apply(s[x, -1], 2, diff) == 0)) / ncol(s[,-1])<br>
<br>
# create object of class distance<br>
nams <- unique(c(as.character(idx[1, ]), as.character(idx[2, ])))<br>
dd <- structure(d, Size = length(nams), Labels = nams, Diag = FALSE, Upper = FALSE, method = "user", class = "dist")<br>
return(dd)<br>
}<br>
<br>
<br>
<br>
# Example dataset<br>
dat <- data.frame(id=as.character(1:4), x=0, y=0,<br>
l_1=c(108, 116, 122, 119),<br>
l_2=c(110, 114, 152, 122),<br>
m_1=c(110, 90, 122, 69),<br>
m_2=c(110, 111, 128, 128))<br>
<br>
<br>
# Create genind<br>
coords <- dat[, 2:3]<br>
datMelted <- melt(dat[, c(1, 4:ncol(dat))])<br>
<br>
names(datMelted) <- c("ind", "loci", "allele")<br>
<br>
# removing 1 and 2, since it is the same loci<br>
datMelted$loci <- str_sub(as.character(datMelted$loci), end=-3)<br>
<br>
# Creating a genind object for the adegenet package<br>
datCasted <- dcast(datMelted, ind ~ loci, paste, collapse="/")<br>
gi <- df2genind(datCasted[, 2:ncol(datCasted)], sep="/", missing="NA", ind=datCasted[, 1])<br>
<br>
<br>
# calcualte proportion of shared alleles<br>
propShared(gi)<br>
as.matrix(psa(dat[, -c(2,3)]))<br>
<br>
# It is my understanding that propShared does not calcualte 1 - porpShared and is the reason for a systematic difference<br>
# However, ind 3 and 4 differ by one of four alleles (= 0.25), but propShared suggests 0.5<br>
</div></div></blockquote></div><br>