dbailleul / RClone

5 stars 0 forks source link

Input format for AFLP data #3

Closed Astahlke closed 4 years ago

Astahlke commented 4 years ago

Hello - thanks for RClone!

What is the proper way to read an AFLP dataset into RClone? Here's what I have so far:

> GMtable <-  read.csv("genomatrix_filtered.csv")
> head(genomatrix)[,1:10]
  Allele1 Allele2 Allele3 Allele4 Allele8 Allele9 Allele10 Allele11 Allele12 Allele15
1       1       0       0       0       0       1        0        0        0        0
2       1       0       0       0       0       1        0        0        0        0
3       1       0       0       0       0       1        0        0        0        0
4       1       0       0       0       0       1        0        0        0        0
5       0       1       0       0       0       0        0        0        0        0
6       1       0       0       0       0       1        0        1        0        0

> genind <- df2genind(genomatrix, type="PA", 
                    pop = popmatrix$site,
                    ind.names = popmatrix[,'sampleName'],
                    loc.names = colnames(genomatrix),
                    sep = ".",
                    strata = popmatrix[,c('site','plot', 'subplot', 'plant')]) ## 
> genind
/// GENIND OBJECT /////////

 // 180 individuals; 95 loci; 95 alleles; size: 112.2 Kb

 // Basic content
   @tab:  180 x 95 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 95-95)
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  PA
   @call: df2genind(X = genomatrix, sep = ".", ind.names = popmatrix[, 
    "sampleName"], loc.names = colnames(genomatrix), pop = popmatrix$site, 
    type = "PA", strata = popmatrix[, c("site", "plot", "subplot", 
        "plant")])

 // Optional content
   @pop: population of each individual (group size range: 30-30)
   @strata: a data frame with 4 columns ( site, plot, subplot, plant )

> test <- genind2df(genind)
> data2 <- convert_GC(test, 1) ## How many alleles do AFLP markers have? 1/0 is presence/absence.
> head(data2)
        pop_1 pop_2 Allele1_1 Allele1_2 Allele2_1 Allele2_2 Allele3_1 Allele3_2 Allele4_1 Allele4_2 Allele8_1
1.1.1.1           1                   1                   0                   0                   0          
1.1.1.2           1                   1                   0                   0                   0          
1.1.2.1           1                   1                   0                   0                   0          
1.1.2.2           1                   1                   0                   0                   0          
1.1.3.1           1                   0                   1                   0                   0          

## Doesn't seem quite right
> head(data2$Allele1_1)
[1] "" "" "" "" "" ""
> head(data2$Allele1_2)
[1] "1" "1" "1" "1" "0" "1"

Thanks for any suggestions!

Amanda

dbailleul commented 4 years ago

Dear Amanda,

Thanks for using RClone !

I have no knowledge of AFLP markers. I think it's a good idea to rely on poppr data transformation as you did: https://cran.r-project.org/web/packages/poppr/vignettes/poppr_manual.html

There appears to have a little problem with the fisrt column name. If you want, you can send me a fraction of your data table "data2" by mail and I'll check it.

Just to remind you, when you're using the _convertGC function: _data2 <- convertGC(test, 1) 1 is for the digits length of your allele markers. And for your data, 1 is the good parameter.

Sincerely, Diane

Astahlke commented 4 years ago

That seems to have worked! And now I have access to all the great spatial statistics of RClone! Thank you very much!

Amanda