[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 17:08:11 CEST 2015


Hmmm... weird.

Method #2 will not work, but #1 should. Can you try this and tell us what you get:

library(adegenet)
data(nancycats)
nancycats[loc=-1]

One possibility is that your adegenet 2.0.0 was the old from github. So maybe trying again after

install.packages("adegenet")

would be worth a try?
Cheers
Thibaut

________________________________
From: Vikram Chhatre [crypticlineage at gmail.com]
Sent: 28 July 2015 15:52
To: adegenet-forum at lists.r-forge.r-project.org
Cc: Jombart, Thibaut
Subject: Re: [adegenet-forum] How can I filter out loci out of HWE from a genind object?

Hi Thibaut,

This does not seem to work. Perhaps I am doing something wrong.  Here is an example:

head(locNames(mygenind))
[1] "loc_121" "loc_229" "loc_472" "loc510" "loc688"

## Method 1
rmloci <- c(1,3)
mygenind2 <- mygenind[loci=-rmloci]
Warning message:
In .local(x, i, j, ..., drop = drop) :
  the following specified loci do not exist: -1the following specified loci do not exist: -3

## Method 2
rmloci2 <- c("loc_121","loc_472")
mygenind2 <- mygenind[loci=-rmloci2]
Error in -rmloci : invalid argument to unary operator

sessionInfo()
adegenet_2.0.0
ade4_1.6-2
R 3.1.2

Thanks
V



On Tue, Jul 28, 2015 at 10:31 AM, Jombart, Thibaut <t.jombart at imperial.ac.uk<mailto:t.jombart at imperial.ac.uk>> wrote:
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<mailto:adegenet-forum-bounces at lists.r-forge.r-project.org> [adegenet-forum-bounces at lists.r-forge.r-project.org<mailto:adegenet-forum-bounces at lists.r-forge.r-project.org>] on behalf of Ana Verissimo [verissimoac at gmail.com<mailto:verissimoac at gmail.com>]
Sent: 20 July 2015 15:58
To: adegenet-forum at lists.r-forge.r-project.org<mailto: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


_______________________________________________
adegenet-forum mailing list
adegenet-forum at lists.r-forge.r-project.org<mailto:adegenet-forum at lists.r-forge.r-project.org>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum

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


More information about the adegenet-forum mailing list