<div dir="ltr"><div><div><div><div><div><div><div>Hi again,<br><br></div>I have two more questions:<br><br></div><div>1) is there a way to get loci with both alleleles 01 and 02 (in my case)?<br></div><div>I
want this combination because afterwards I want to assess which of
these two alleles most highlight the originality of x pop using
loadingplot...<br>
</div><div><br>2)once I selected only the loci with allele "01", then I would get a genind object only with those loci.<br></div>So first I did:<br><br>a<-which(sapply(alleles(mydata), function(e) "01" %in% e))<br>
<br>#then:<br></div><br>newdata <-mydata[,a]<br><br></div>but if I look: newdata$all.names I can see loci with others alleles, while I should get only the loci with allele 01. ???<br><br></div>Thank you,<br><br></div>
Best regards<br><br></div>Sara</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-11 12:00 GMT+02:00 <span dir="ltr"><<a href="mailto:adegenet-forum-request@lists.r-forge.r-project.org" target="_blank">adegenet-forum-request@lists.r-forge.r-project.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send adegenet-forum mailing list submissions to<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
<br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:adegenet-forum-request@lists.r-forge.r-project.org">adegenet-forum-request@lists.r-forge.r-project.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:adegenet-forum-owner@lists.r-forge.r-project.org">adegenet-forum-owner@lists.r-forge.r-project.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of adegenet-forum digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. select loci with specific genotype in genind object<br>
(Sara Bonanomi)<br>
2. Re: select loci with specific genotype in genind object<br>
(Jombart, Thibaut)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 10 Apr 2014 16:26:18 +0200<br>
From: Sara Bonanomi <<a href="mailto:bonanomi.sara85@gmail.com">bonanomi.sara85@gmail.com</a>><br>
To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
Subject: [adegenet-forum] select loci with specific genotype in genind<br>
object<br>
Message-ID:<br>
<CANyZ5TOEwoYqNBAUOF3iS3=<a href="mailto:V%2BRLTCf7S7uqd3B9PncSGY7xbZw@mail.gmail.com">V+RLTCf7S7uqd3B9PncSGY7xbZw@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi all,<br>
<br>
In my genind object I would like to select only the loci with a certain<br>
genotype (e.g. 0102). Then I wanna check the allele contribution<br>
($var.contr).<br>
<br>
If I digit: mygenindobject$all.names I get a list with xx components<br>
yielding allele names for each locus.<br>
<br>
For instance:<br>
<br>
<br>
<br>
$L262<br>
<br>
1 2<br>
<br>
"01" "02"<br>
<br>
<br>
<br>
Then, to get the loci only the loci with a certain genotype (e.g. 0102) , I<br>
have tried with the subset function: selectLoci<-subset(mydata$all.names,<br>
1=="01" & 2=="02", select=c(1,2)) But then I get: named list ()<br>
<br>
Is there a specific function in adegenet to subset the data? Could you<br>
please help me?<br>
<br>
<br>
Thank you very much,<br>
<br>
<br>
Best<br>
<br>
<br>
Jasmine<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20140410/c8bb71b3/attachment-0001.html" target="_blank">http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20140410/c8bb71b3/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 10 Apr 2014 15:35:07 +0000<br>
From: "Jombart, Thibaut" <<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>><br>
To: Sara Bonanomi <<a href="mailto:bonanomi.sara85@gmail.com">bonanomi.sara85@gmail.com</a>>,<br>
"<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>"<br>
<<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>><br>
Subject: Re: [adegenet-forum] select loci with specific genotype in<br>
genind object<br>
Message-ID:<br>
<<a href="mailto:2CB2DA8E426F3541AB1907F98ABA657075F7EDA4@icexch-m1.ic.ac.uk">2CB2DA8E426F3541AB1907F98ABA657075F7EDA4@icexch-m1.ic.ac.uk</a>><br>
Content-Type: text/plain; charset="Windows-1252"<br>
<br>
Hello,<br>
<br>
yes, there are a few functions that can be helpful here. Most of them are probably documented in the 'basics' tutorial:<br>
- 'alleles' to pull the lists of alleles for each locus<br>
- 'locNames' to pull the locus names, with an option to get alleles too<br>
- seploc which allows for separating loci<br>
- []: which you can use to isolate specific loci<br>
<br>
Example using some of these:<br>
<br>
> data(microbov)<br>
<br>
## list alleles per locus (just first 3)<br>
> alleles(microbov)[1:3]<br>
$L01<br>
1 2 3 4 5 6 7 8 9<br>
"167" "171" "173" "175" "177" "179" "181" "183" "185"<br>
<br>
$L02<br>
1 2 3 4 5 6 7<br>
"137" "139" "141" "143" "145" "147" "149"<br>
<br>
$L03<br>
01 02 03 04 05 06 07 08 09 10 11 12<br>
"137" "139" "141" "143" "145" "147" "149" "151" "153" "155" "157" "159"<br>
<br>
<br>
## to get loci having e.g. alleles 140:<br>
## (TRUE = this locus has an allele "140")<br>
> sapply(alleles(microbov), function(e) "140" %in% e)<br>
L01 L02 L03 L04 L05 L06 L07 L08 L09 L10 L11 L12 L13<br>
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE<br>
L14 L15 L16 L17 L18 L19 L20 L21 L22 L23 L24 L25 L26<br>
FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE<br>
L27 L28 L29 L30<br>
FALSE TRUE FALSE FALSE<br>
<br>
## which loci are these?<br>
> which(sapply(alleles(microbov), function(e) "140" %in% e))<br>
L15 L18 L25 L28<br>
15 18 25 28<br>
<br>
## if you want to get the position of the alleles "140" across all loci:<br>
## this is a vector of all allele names (locus.allele)<br>
> head(locNames(microbov, withAlleles=TRUE))<br>
[1] "INRA63.167" "INRA63.171" "INRA63.173" "INRA63.175" "INRA63.177"<br>
[6] "INRA63.179"<br>
<br>
## position of those having an allele 140:<br>
> grep("140",locNames(microbov, withAlleles=TRUE))<br>
[1] 161 200 289 324<br>
<br>
## there full names:<br>
> posi <- grep("140",locNames(microbov, withAlleles=TRUE))<br>
> locNames(microbov, withAlleles=TRUE)[posi]<br>
[1] "BM2113.140" "INRA37.140" "HAUT27.140" "TGLA122.140"<br>
<br>
<br>
You can use this type of subsetting to isolate specific contributions.<br>
<br>
Best<br>
Thibaut<br>
<br>
--<br>
######################################<br>
Dr Thibaut JOMBART<br>
MRC Centre for Outbreak Analysis and Modelling<br>
Department of Infectious Disease Epidemiology<br>
Imperial College - School of Public Health<br>
St Mary?s Campus<br>
Norfolk Place<br>
London W2 1PG<br>
United Kingdom<br>
Tel. : 0044 (0)20 7594 3658<br>
<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><br>
<a href="http://sites.google.com/site/thibautjombart/" target="_blank">http://sites.google.com/site/thibautjombart/</a><br>
<a href="http://adegenet.r-forge.r-project.org/" target="_blank">http://adegenet.r-forge.r-project.org/</a><br>
________________________________________<br>
From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>] on behalf of Sara Bonanomi [<a href="mailto:bonanomi.sara85@gmail.com">bonanomi.sara85@gmail.com</a>]<br>
Sent: 10 April 2014 15:26<br>
To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
Subject: [adegenet-forum] select loci with specific genotype in genind object<br>
<br>
Hi all,<br>
<br>
<br>
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).<br>
<br>
If I digit: mygenindobject$all.names I get a list with xx components yielding allele names for each locus.<br>
<br>
For instance:<br>
<br>
<br>
<br>
$L262<br>
<br>
1 2<br>
<br>
"01" "02"<br>
<br>
<br>
<br>
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 ()<br>
<br>
Is there a specific function in adegenet to subset the data? Could you please help me?<br>
<br>
<br>
Thank you very much,<br>
<br>
<br>
Best<br>
<br>
<br>
Jasmine<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
<br>
End of adegenet-forum Digest, Vol 68, Issue 1<br>
*********************************************<br>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><i><font size="4">Sara Bonanomi</font><br></i>PhD Student<br>DTU Aqua<br><br><div><span style="font-size:x-small"><a href="http://www.dtu.dk/english.aspx" target="_blank">Technical University of Denmark</a></span></div>
<div><span style="font-size:x-small"><a href="http://www.aqua.dtu.dk/" target="_blank">National Institute<u style="color:rgb(0,0,153)"> </u></a></span><font size="1"><u style="color:rgb(0,0,153)">o</u></font><span style="font-size:x-small"><a href="http://www.aqua.dtu.dk/" target="_blank"><u style="color:rgb(0,0,153)">f</u> Aquatic Resources</a></span></div>
<div><font size="1">Vejlsøvej 39</font> <span style="font-size:x-small">8600 Silkeborg<br></span></div>
<div><span style="font-size:x-small">Alternative email: <a href="mailto:sofer@aqua.dtu.dk" target="_blank">sarb@aqua.dtu.dk</a></span></div><font size="1">Mobile: <span>+45 52 73 54 58</span><span dir="ltr"><span dir="ltr"><span><img><span>+45 52 73 54 58</span><span></span></span></span></span></font><br>
<div><div><a>Call</a></div><div><a>Send SMS</a></div><div><a>Add to Skype</a></div><div><span>You'll need Skype Credit</span><span>Free via Skype</span></div></div></div>
</div>