[adegenet-forum] Hardy-weinberg using R

Jombart, Thibaut t.jombart at imperial.ac.uk
Thu Jan 19 11:57:32 CET 2012


Hello, 

are you sure "file" contains the path to the file you try to analyse? What does 'x' look like?

Cheers

Thibaut
________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] on behalf of Vitor Aguiar [vitor.aguiar at me.com]
Sent: 19 January 2012 03:58
To: adegenet-forum at r-forge.wu-wien.ac.at
Subject: [adegenet-forum] Hardy-weinberg using R

Hello! May anyone help me? I'd like to know what's the best way to calculate Hardy-Weinberg Equilibrium using R. I tried the pegas package, but since I'm not familiar with programming I could not make it work yet... I'm analyzing multi allelic STR markers.

example file: 3rd "Raw Data as Excel File" link on the website below  (with the green tag "New"):
http://www.cstl.nist.gov/strbase/NISTpop.htm

I'm doing the steps below:
> install.packages(pegas)
> library(pegas)

#you can see that other packages are also loaded, such as adegenet.

#now, I have to take the HWE test using the function:

hw.test(x, B=1000)
where x = an object of class 'loci'
           B = the number of replicates for the Monte Carlo procedure

#So, accordingly to the manual ( http://ape.mpl.ird.fr/pegas/pegas-manual.pdf ) I have to do the follow:

> x=as.loci(file)
> hw.test(x)

#error message:
Error in expand.genotype(Nall, ploidy = ploidy, matrix = TRUE) :
  object 'ans' not found
#this could be due to the structure of the input file or its format (I used .csv)... I don't know...

I also tried the function read.loci, which reads allele data from text files (saving the input file as .txt before). This doesn't work either, as many other things I tried...
I think this analysis somehow should be simple to do...


Vitor Rezende da Costa Aguiar
---------------------------------------------------
PhD student in Biotechnology
Rede Nordeste de Biotecnologia
Universidade Federal do Espírito Santo
---------------------------------------------------
Current Adress:
Department of Integrative Biology
University of California, Berkeley
2033 Valley Life Sciences Building, office 4134
Berkeley, CA - USA 94720
Phone: 1 (510)-643-0060



More information about the adegenet-forum mailing list