[adegenet-forum] (no subject)

Jombart, Thibaut t.jombart at imperial.ac.uk
Thu May 14 14:46:01 CEST 2009


Dear Axel, 

I may have to add this feature for the next release. Added to the TODO list meanwhile. 
A simple workaround would be :

1) produce a data.frame with commas as separators between alleles, using genind2df
2) write this to a file, using write.table
3) read the file, using read.csv

For instance:
> data(sim2pop)
> foo=genind2df(sim2pop, sep=",") ### 1 ###
> head(foo)
       pop   L01   L02   L03   L04   L05 L06 L07   L08 L09   L10 L11   L12
0771 Pop A 01,13 01,05 03,11 02,05 02,10 1,6 1,3 02,08 3,7 05,09 5,5 02,06
0478 Pop A 03,09 05,10 09,16 02,02 09,10 6,8 3,3 09,09 3,7 08,09 4,8 02,06
0530 Pop A 03,06 05,05 15,17 02,02 09,09 1,6 3,7 02,09 3,3 02,08 5,7 06,06
0211 Pop A 06,13 05,10 13,15 02,11 09,10 8,8 3,3 02,09 3,7 02,08 5,5 01,06
0017 Pop A 03,13 05,10 03,13 03,07 07,10 6,8 2,3 03,09 4,4 08,10 5,5 04,06
0492 Pop A 01,03 05,10 03,17 02,11 02,10 2,6 1,3 08,09 5,7 04,09 2,5 06,06
       L13   L14   L15   L16   L17   L18   L19   L20
0771 05,05 10,10 04,11 12,13 02,14 14,14 02,02 02,05
0478 05,05 08,12 01,02 02,08 02,10 02,07 03,04 10,13
0530 05,07 07,10 02,11 02,08 10,14 06,13 02,10 07,07
0211 03,05 02,02 02,09 01,12 04,14 04,14 02,06 10,13
0017 05,11 10,10 08,11 01,02 02,14 12,14 02,02 10,13
0492 03,05 10,13 11,11 01,13 14,14 04,13 02,02 07,11
> 

> colnames(foo)=NULL
> write.table(foo,file="foo.csv", col.names=FALSE, sep=",", quote=FALSE)  ### 2 ###

> newFoo = read.csv("foo.csv",head=FALSE)  ### 3 ###
> head(newFoo)
   V1    V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20
1 771 Pop A  1 13  1  5  3 11  2   5   2  10   1   6   1   3   2   8   3   7
2 478 Pop A  3  9  5 10  9 16  2   2   9  10   6   8   3   3   9   9   3   7
3 530 Pop A  3  6  5  5 15 17  2   2   9   9   1   6   3   7   2   9   3   3
4 211 Pop A  6 13  5 10 13 15  2  11   9  10   8   8   3   3   2   9   3   7
5  17 Pop A  3 13  5 10  3 13  3   7   7  10   6   8   2   3   3   9   4   4
6 492 Pop A  1  3  5 10  3 17  2  11   2  10   2   6   1   3   8   9   5   7
  V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37 V38 V39
1   5   9   5   5   2   6   5   5  10  10   4  11  12  13   2  14  14  14   2
2   8   9   4   8   2   6   5   5   8  12   1   2   2   8   2  10   2   7   3
3   2   8   5   7   6   6   5   7   7  10   2  11   2   8  10  14   6  13   2
4   2   8   5   5   1   6   3   5   2   2   2   9   1  12   4  14   4  14   2
5   8  10   5   5   4   6   5  11  10  10   8  11   1   2   2  14  12  14   2
6   4   9   2   5   6   6   3   5  10  13  11  11   1  13  14  14   4  13   2
  V40 V41 V42
1   2   2   5
2   4  10  13
3  10   7   7
4   6  10  13
5   2  10  13
6   2   7  11
> 


Best,

Thibaut.


________________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] On Behalf Of Axel Hille [axel.hille at gmx.net]
Sent: 14 May 2009 12:51
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] (no subject)

Dear adegent-users, dear Thibaut,
it maybe naive but i have problems with the genind2df function. what i want to do is - after reading in successfully a structure file - to generate a barebone data.frame without column names only rows x 2 columns for individuals x genotypes in 2 colums which can be used as input to the Geneland package. The problem: The dataframe generated by the genind2df function produces columns like "198 204" (STR genotypes and column names "RECALQ". What i need is 2 separate columns "198" "204" with column names for example RECALQ.a1 and RECALQ.a2 or no column names at all. I have no idea to generate this output. I really appreciate your help.
Following piece of code relates to my problem:

bf.geno.str <- read.structure("c:\\Dokumente und Einstellungen\\Axel Hille\\Desktop\\davidbeiaxel\\david_structure_example\\brownfrogs_3digit_122.str",
n.ind=122, n.loc=5, onerowperind=F, col.lab=T, col.pop=1, col.others=NULL, row.marknames=1, missing=-9, pop=NULL,quiet=T,ask=F)
##
   #####################
   ### Genind object ###
   #####################
- genotypes of individuals -
S4 class:  genind
@call: .local(x = x, i = i, j = j, drop = drop)
@tab:  1 x 29 matrix of genotypes
@ind.names: vector of  1 individual names
@loc.names: vector of  5 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  29 columns of @tab
@all.names: list of  5 components yielding allele names for each locus
@ploidy:  2
@type:  codom
Optionnal contents:
@pop:  factor giving the population of each individual
@pop.names:  factor giving the population of each individual
@other: a list containing: elements without names
##
#?genind2df
bf.geno.df.2 <- genind2df(bf.geno.str,sep=" ")
bf.geno.df.2[1:5,1:5]
##
        pop  RECALQ  RNTYR2  RC0608  RCIDLL
TAB7   TAB7 198 204 623 623 176 176 128 130
TAB8   TAB8 198 204 608 644 166 180 128 130
TAB9   TAB9 198 204 608 644 166 174 130 130
TAB10 TAB10 204 204 608 608 174 182 128 130
TAB11 TAB11 198 198 608 644 176 180 128 130
##
names(bf.geno.df.2)
##
[1] "pop"    "RECALQ" "RNTYR2" "RC0608" "RCIDLL" "RAI022"
##
....


Best regards
Axel Hille

--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a
_______________________________________________
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


More information about the adegenet-forum mailing list