[adegenet-forum] adegenet-forum Digest, Vol 68, Issue 1

Sara Bonanomi bonanomi.sara85 at gmail.com
Sun Apr 13 18:32:53 CEST 2014


Hi again,

I have two more questions:

1) is there a way to get loci with both alleleles 01 and 02 (in my case)?
I want this combination because afterwards I want to assess which of these
two alleles most highlight the originality of x pop using loadingplot...

2)once I selected only the loci with allele "01", then I would get a genind
object only with those loci.
So first I did:

a<-which(sapply(alleles(mydata), function(e) "01" %in% e))

#then:

newdata <-mydata[,a]

but if I look: newdata$all.names  I can see loci with others alleles, while
I should get only the loci with allele 01.  ???

Thank you,

Best regards

Sara


2014-04-11 12:00 GMT+02:00 <
adegenet-forum-request at lists.r-forge.r-project.org>:

> Send adegenet-forum mailing list submissions to
>         adegenet-forum at lists.r-forge.r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
>
> or, via email, send a message with subject or body 'help' to
>         adegenet-forum-request at lists.r-forge.r-project.org
>
> You can reach the person managing the list at
>         adegenet-forum-owner at lists.r-forge.r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of adegenet-forum digest..."
>
>
> Today's Topics:
>
>    1. select loci with specific genotype in genind object
>       (Sara Bonanomi)
>    2. Re: select loci with specific genotype in genind object
>       (Jombart, Thibaut)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 10 Apr 2014 16:26:18 +0200
> From: Sara Bonanomi <bonanomi.sara85 at gmail.com>
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] select loci with specific genotype in genind
>         object
> Message-ID:
>         <CANyZ5TOEwoYqNBAUOF3iS3=
> V+RLTCf7S7uqd3B9PncSGY7xbZw at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi all,
>
> In my genind object I would like to select only the loci with a certain
> genotype (e.g. 0102). Then I wanna check the allele contribution
> ($var.contr).
>
>  If I digit: mygenindobject$all.names I get a list with xx components
> yielding allele names for each locus.
>
> For instance:
>
>
>
> $L262
>
>    1    2
>
> "01" "02"
>
>
>
> Then, to get the loci only the loci with a certain genotype (e.g. 0102) , I
> have tried with the subset function: selectLoci<-subset(mydata$all.names,
> 1=="01" & 2=="02", select=c(1,2)) But then I get: named list ()
>
>  Is there a specific function in adegenet to subset the data? Could you
> please help me?
>
>
> Thank you very much,
>
>
> Best
>
>
> Jasmine
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20140410/c8bb71b3/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Thu, 10 Apr 2014 15:35:07 +0000
> From: "Jombart, Thibaut" <t.jombart at imperial.ac.uk>
> To: Sara Bonanomi <bonanomi.sara85 at gmail.com>,
>         "adegenet-forum at lists.r-forge.r-project.org"
>         <adegenet-forum at lists.r-forge.r-project.org>
> Subject: Re: [adegenet-forum] select loci with specific genotype in
>         genind object
> Message-ID:
>         <2CB2DA8E426F3541AB1907F98ABA657075F7EDA4 at icexch-m1.ic.ac.uk>
> Content-Type: text/plain; charset="Windows-1252"
>
> Hello,
>
> yes, there are a few functions that can be helpful here. Most of them are
> probably documented in the 'basics' tutorial:
> - 'alleles' to pull the lists of alleles for each locus
> - 'locNames' to pull the locus names, with an option to get alleles too
> - seploc which allows for separating loci
> - []: which you can use to isolate specific loci
>
> Example using some of these:
>
> > data(microbov)
>
> ## list alleles per locus (just first 3)
> > alleles(microbov)[1:3]
> $L01
>     1     2     3     4     5     6     7     8     9
> "167" "171" "173" "175" "177" "179" "181" "183" "185"
>
> $L02
>     1     2     3     4     5     6     7
> "137" "139" "141" "143" "145" "147" "149"
>
> $L03
>    01    02    03    04    05    06    07    08    09    10    11    12
> "137" "139" "141" "143" "145" "147" "149" "151" "153" "155" "157" "159"
>
>
> ## to get loci having e.g. alleles 140:
> ## (TRUE = this locus has an allele "140")
> > sapply(alleles(microbov), function(e) "140" %in% e)
>   L01   L02   L03   L04   L05   L06   L07   L08   L09   L10   L11   L12
> L13
> FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> FALSE
>   L14   L15   L16   L17   L18   L19   L20   L21   L22   L23   L24   L25
> L26
> FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
> FALSE
>   L27   L28   L29   L30
> FALSE  TRUE FALSE FALSE
>
> ## which loci are these?
> > which(sapply(alleles(microbov), function(e) "140" %in% e))
> L15 L18 L25 L28
>  15  18  25  28
>
> ## if you want to get the position of the alleles "140" across all loci:
> ## this is a vector of all allele names (locus.allele)
> > head(locNames(microbov, withAlleles=TRUE))
> [1] "INRA63.167" "INRA63.171" "INRA63.173" "INRA63.175" "INRA63.177"
> [6] "INRA63.179"
>
> ## position of those having an allele 140:
> > grep("140",locNames(microbov, withAlleles=TRUE))
> [1] 161 200 289 324
>
> ## there full names:
> > posi <- grep("140",locNames(microbov, withAlleles=TRUE))
> > locNames(microbov, withAlleles=TRUE)[posi]
> [1] "BM2113.140"  "INRA37.140"  "HAUT27.140"  "TGLA122.140"
>
>
> You can use this type of subsetting to isolate specific contributions.
>
> Best
> Thibaut
>
> --
> ######################################
> Dr Thibaut JOMBART
> MRC Centre for Outbreak Analysis and Modelling
> Department of Infectious Disease Epidemiology
> Imperial College - School of Public Health
> St Mary?s Campus
> Norfolk Place
> London W2 1PG
> United Kingdom
> Tel. : 0044 (0)20 7594 3658
> t.jombart at imperial.ac.uk
> http://sites.google.com/site/thibautjombart/
> http://adegenet.r-forge.r-project.org/
> ________________________________________
> From: adegenet-forum-bounces at lists.r-forge.r-project.org [
> adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Sara
> Bonanomi [bonanomi.sara85 at gmail.com]
> Sent: 10 April 2014 15:26
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] select loci with specific genotype in genind
> object
>
> Hi all,
>
>
> In my genind object I would like to select only the loci with a certain
> genotype (e.g. 0102). Then I wanna check the allele contribution
> ($var.contr).
>
>  If I digit: mygenindobject$all.names I get a list with xx components
> yielding allele names for each locus.
>
> For instance:
>
>
>
> $L262
>
>    1    2
>
> "01" "02"
>
>
>
> Then, to get the loci only the loci with a certain genotype (e.g. 0102) ,
> I have tried with the subset function: selectLoci<-subset(mydata$all.names,
> 1=="01" & 2=="02", select=c(1,2)) But then I get: named list ()
>
>  Is there a specific function in adegenet to subset the data? Could you
> please help me?
>
>
> Thank you very much,
>
>
> Best
>
>
> Jasmine
>
>
> ------------------------------
>
> _______________________________________________
> adegenet-forum mailing list
> adegenet-forum at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
>
> End of adegenet-forum Digest, Vol 68, Issue 1
> *********************************************
>



-- 

*Sara Bonanomi*PhD Student
DTU Aqua

Technical University of Denmark <http://www.dtu.dk/english.aspx>
National Institute <http://www.aqua.dtu.dk/>*o**f* Aquatic
Resources<http://www.aqua.dtu.dk/>
Vejlsøvej 39 8600 Silkeborg
Alternative email: sarb at aqua.dtu.dk <sofer at aqua.dtu.dk>
Mobile: +45 52 73 54 58+45 52 73 54 58
Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20140413/ad069763/attachment.html>


More information about the adegenet-forum mailing list