[adegenet-forum] Hardy-weinberg using R

Vitor Aguiar vitor.aguiar at me.com
Thu Jan 19 04:58:23 CET 2012


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20120118/b550facf/attachment-0001.htm>


More information about the adegenet-forum mailing list