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

Nevil Amos nevil.amos at gmail.com
Tue Jan 3 18:29:13 CET 2012


On 3/01/2012 10:03 PM, adegenet-forum-request at r-forge.wu-wien.ac.at wrote:
> 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. convert two columns per locus data frames into one column
>        with separator for import to genind (Nevil Amos)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 03 Jan 2012 04:14:07 +1100
> From: Nevil Amos<nevil.amos at gmail.com>
> Subject: [adegenet-forum] convert two columns per locus data frames
> 	into one column with separator for import to genind
> To: adegenet-forum at lists.r-forge.r-project.org
> Message-ID:<4F01E5DF.3050403 at monash.edu>
> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
>
> I have a heap of genotypes  in text files arranged with two columns per
> locus ( they are diploid)
>
> How can I quickly import and format these as one column per locus  given
> the number of loci varies
>
> alternatively is it possible to import the tow column per locus table as
> geno into genind directly?
>
>
> ie
>
> my data is formatted
>     BMC3_1 BMC3_2 Cpi4_1 Cpi4_2 epic23989s_1 epic23989s_2
> 1     98    106    286    288          284          284
> 2    116    116    284    308          286          286
> 3    108    116    302    304          286          288
> 4    106    118    288    302          286          286
> 5     98     98    294    304          284          286
> 6     98    120    284    312          282          284
>
>
> and needs to be:
>     BMC3         Cpi4         epic23989s
> 1     98 /106    286/288          284/284
> 2    116/116    284/308          286/286
> 3    108/116    302/304          286/288
> 4    106/118    288/302          286/286
> 5     98/98    294/304          284/286
> 6     98/120    284/312          282/284
>
> in order to import into genind object
>
> cheers
>
> Nevil Amos
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:<http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20120103/f1469b2e/attachment.html>
>
> ------------------------------
>
> _______________________________________________
> 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 41, Issue 1
> *********************************************
I sorted it in the end.

thanks

may be of assistance to others:

where X is the data.frame containing two columns per locus giving the 
allele lengths:

X<-mydata
N<-ncol(X)
n=N/2
A<-seq(1,N, by=2)
B<-seq(2,N, by=2)
for (i in 1:n){
   locus<-(paste(X[,A[i]],"/",X[,B[i]],sep=""))
   if (exists("geno")) geno<-data.frame(geno,locus) else 
geno<-as.data.frame(locus)
}




More information about the adegenet-forum mailing list