Hi Thibaut, Thanks for having a look at this for me. What you have is close to what I'm looking for. Where I am stuck is that for me each data sheet does not necessarily have the same individuals. I have in the range of 20 different data sheets composed of various formulations of 200 individuals. Not all individuals are in every sheet. Each sheet has a column for individuals and columns for allele data from 2 or 3 microsatillate loci. I would like to read these into a data sheet that has all individual and locus data in a single sheet with a column of individuals and 2 columns per locus for microsat data.
I have done this the old-fashioned way in excel (with vlookup) but will have to do it again a few more times in the future do if it is relatively simple I am still interested in and suggestions on how it can be done. Cheers Grant So from your example it would be closer to: > A <- matrix(1:12, ncol=3) > B <- matrix(12:1, ncol=3) > rownames(A) <- letters[1:4] > rownames(B) <- letters[6:3] > A [,1] [,2] [,3] a 1 5 9 b 2 6 10 c 3 7 11 d 4 8 12 > B [,1] [,2] [,3] f 12 8 4 e 11 7 3 d 10 6 2 c 9 5 1 > Hello List, > Thanks in advance for any help. > I am trying to use R to combine panels of microsatellite scores in R and > having troubles. I am using GeneMarker 1.70 and my files are saved as tab > delimited text that look like the example below. I would like the output to > have a column for individuals ( eg, [ H1]H01.fsa) and then one column for > each allele at each locus. One of the spots I am have trouble with is that > each file has a different permutation of the same individuals. Has anyone > already put something together that they are willing to share? > Cheers > Grant Dear Grant, I think the simplest way to deal with your issue is to reorder matrices using the row names. Then you can safely cbind them if you wish to have all information in the same matrix. For instance : > A <- matrix(1:12, ncol=3) > B <- matrix(12:1, ncol=3) > rownames(A) <- letters[1:4] > rownames(B) <- letters[4:1] > A [,1] [,2] [,3] a 1 5 9 b 2 6 10 c 3 7 11 d 4 8 12 > B [,1] [,2] [,3] d 12 8 4 c 11 7 3 b 10 6 2 a 9 5 1 > B[rownames(A),] [,1] [,2] [,3] a 9 5 1 b 10 6 2 c 11 7 3 d 12 8 4 ## so to reorder B, just use: > B <- B[rownames(A),] Is this what you needed? Best, Thibaut. -- ###################################### Dr Thibaut JOMBART MRC Centre for Outbreak Analysis and Modelling Department of Infectious Disease Epidemiology Imperial College - Faculty of Medicine St Mary's Campus Norfolk Place London W2 1PG United Kingdom Tel. : 0044 (0)20 7594 3658 [email protected] http://biomserv.univ-lyon1.fr/%7Ejombart/ http://adegenet.r-forge.r-project.org/ [[alternative HTML version deleted]] [[alternative HTML version deleted]] _______________________________________________ R-sig-genetics mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-genetics
