[adegenet-forum] extracting genefreq $tab from an indexed list

Vikram Chhatre crypticlineage at gmail.com
Mon Mar 30 04:25:16 CEST 2015


I am working with hundreds of genpop objects indexed in a list.  Using
lapply and makefreq functions, population gene frequencies were stored in
individual objects (1 per data set).

Here is an example with just three objects:

>summary(mygenpop)
                  Length Class  Mode
data1.str 1      genpop S4
data2.str 1      genpop S4
data3.str 1      genpop S4

>mygenfreq <- lapply(mygenpop, function(x) makefreq(x, truenames=TRUE))

>summary(mygenfreq)
                  Length Class  Mode
data1.str 3      -none- list
data2.str 3      -none- list
data3.str 3      -none- list

>summary(mygenfreq[[1]]$tab)
> str(mygenfreq[[1]])
 $ tab : num [1:30, 1:1974] 0.6 0.5 0.325 0.675 0.6 0.5 0.5 0.375 0.55
0.475 ...
 $ nobs: num [1:30, 1:1000] 40 40 40 40 40 40 40 40 40 40 ...

Next job is to work with the $tab matrix, but I am not sure how to access
it from all objects in one command.

>mygenfreqT <- lapply(mygenfreq[[1:3]]$tab, function(x) t(x))

This throws an error.   The syntax seems to be wrong, but I am not sure how
to fix this.  Thanks for any help.

Vikram
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150329/f9c4c366/attachment.html>


More information about the adegenet-forum mailing list