[adegenet-forum] How can I filter out loci out of HWE from a genind object?

Jombart, Thibaut t.jombart at imperial.ac.uk
Tue Jul 28 16:31:01 CEST 2015


Hi there,

this is easy to do since adegenet 2.0.0. You can use x[loc=...] where ... is any usual subsetting, which will be matched against locNames(x). You can use it to retain relevant loci, or discard the unwanted ones.

For instance:

> library(adegenet)
Loading required package: ade4

   /// adegenet 2.0.0 is loaded ////////////

   > overview: '?adegenet'
   > tutorials/doc/questions: 'adegenetWeb()'
   > bug reports/feature resquests: adegenetIssues()


> data(nancycats)
> locNames(nancycats)
[1] "fca8"  "fca23" "fca43" "fca45" "fca77" "fca78" "fca90" "fca96" "fca37"

## removing loci 2, 4 and 5
> toRemove= c(2,4,5)
> x=nancycats[loc=-toRemove]
> x
/// GENIND OBJECT /////////

 // 237 individuals; 6 loci; 76 alleles; size: 102.9 Kb

 // Basic content
   @tab:  237 x 76 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 8-18)
   @loc.fac: locus factor for the 76 columns of @tab
   @all.names: list of allele names for each locus
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  codom
   @call: .local(x = x, i = i, j = j, loc = ..1, drop = drop)

 // Optional content
   @pop: population of each individual (group size range: 9-23)
   @other: a list containing: xy

## note the difference from locNames(nancycats):
> locNames(x)
[1] "fca8"  "fca43" "fca78" "fca90" "fca96" "fca37"


Cheers
Thibaut



==============================
Dr Thibaut Jombart
MRC Centre for Outbreak Analysis and Modelling
Department of Infectious Disease Epidemiology
Imperial College - School of Public Health
Norfolk Place, London W2 1PG, UK
Tel. : 0044 (0)20 7594 3658
http://sites.google.com/site/thibautjombart/
http://sites.google.com/site/therepiproject/
http://adegenet.r-forge.r-project.org/
Twitter: @thibautjombart


________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Ana Verissimo [verissimoac at gmail.com]
Sent: 20 July 2015 15:58
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] How can I filter out loci out of HWE from a genind object?

Hi all,

I have a data set comprised on 1000s of SNP loci genotyped for 10s of individuals. I have tested loci for conformance to HWE and want to filter out those loci out of HWE.

Is there a function already available to perform this filtering in genind objects?
If not, I am guessing I may need to figure out a way to subset my data using a list of loci that I want to keep?

Any tips or suggestions are welcome!
Ana

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150728/e80f77ce/attachment.html>


More information about the adegenet-forum mailing list