# [R] Allelic Differentiation, sampling, unique(), duplicated()

Philip Rhoades pri at chu.com.au
Thu Sep 4 16:21:07 CEST 2003

```Hi people,

I have made some progress trying to work out how to solve this problem
but I have got a bit stuck - sorry if this turns out to be a simple
exercise . .

Allelic Differentiation (AD) in genetics measures the number of
different alleles between (say) two populations eg:

Organisms in Pop 1 have alleles: a, b, c, d, e

Organisms in Pop 2 have alleles: b, b, c, d, e

Different (unique) alleles (n) are: a

[unique() does not do what I want here for comparing these two vectors
and I can't get combinations of unique() and duplicated() to work
either.]

Total alleles = 10

Therefore AD = (2 * n) / 10 = 0.2

What I want to do is compare two populations of 200 organisms each but
sampling for only 20 at a time.

So there are 200!/((200-20)! * 20!) possible combinations of samples in
each population.

For all possible combinations of sample pop1 and sample pop2 I want to
measure AD ie (200!/((200-20)! * 20!) * 200!/((200-20)! * 20!) )
calculations.

As well as the unique allele problem, can someone suggest how I can do
the sampling loops?

Thanks,

Phil.
--

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW	2001
Australia
Mobile:  +61:0411-185-652
Fax:  +61:2:8923-5363
E-mail:  pri at chu.com.au

```