Learn R Programming

PopGenReport (version 0.96)

read.genetable: Function to convert textfiles into a genind object (the format required for popgenreport)

Description

This function converts genetic data provided in a tabular 'comma separated value' (.csv) file into a genind object, the data format required to run PopGenReport. At the moment it works only for codominant markers (e.g. microsatellites). This function is based on df2genind from the adegenet package.

Usage

read.genetable(filename, pop = NULL, ind = NULL, lat = NULL, long = NULL,
other.min = NULL, other.max = NULL, oneColPerAll, missing = NA, sep = NULL, ncode = NULL)

Arguments

Value

an object of the class genind This kind of object is needed to be passed on to the popgen.report function.

Details

The format of the .csv file is very important. Make sure your headings are exactly as provided in the example file or the conversion will likely fail. Use your favourite text editor to reformat the file (e.g. Excel) to prepare the data and save it as csv file. You need to provide the number of columns for each of your data sections. These are: ind, pop, lat, long, other.min, other.max, and whether there is a single column per allele (if you use a single column for both alleles then you need to specify the seperator as well), or two columns per allele. Please refer to the example files to make sure your file is in the correct format and then check the conversion by typing:

mydata <- read.genetable("mygeneticdat.csv") mydata

=== There are 3 treatments for missing values === - NA: kept as NA.

- 0: allelic frequencies are set to 0 on all alleles of the concerned locus. Recommended for a PCA on compositionnal data.

- "mean": missing values are replaced by the mean frequency of the corresponding allele, computed on the whole set of individuals. Recommended for a centred PCA.

=== Details for the sep argument === this character is directly used in reguar expressions like gsub, and thus require some characters to be preceeded by double backslashes. For instance, "/" works but "|" must be coded as "\\|".

See Also

import2genind, df2genind, read.fstat, read.structure, read.genetix read.genepop

Examples

Run this code
#example file with one column per loci, seperated by forwardslash
read.csv(paste(.libPaths()[1],"/PopGenReport/extdata/platypus1c.csv", sep="" ))
platy1c <- read.genetable( paste(.libPaths()[1],"/PopGenReport/extdata/platypus1c.csv"
, sep="" ), ind=1, pop=2, lat=3, long=4, other.min=5, other.max=8, oneColPerAll=TRUE, sep="/")


#example file with two columns per loci
read.csv(paste(.libPaths()[1],"/PopGenReport/extdata/platypus2c.csv", sep="" ))
platy2c <- read.genetable( paste(.libPaths()[1],"/PopGenReport/extdata/platypus2c.csv",
 sep="" ), ind=1, pop=2, lat=3, long=4, other.min=5, other.max=8, oneColPerAll=FALSE)

#to get a pdf output you need to have a running Latex version installed on your system.
#run a report (with a map)
#popgenreport(platy2c, mk.counts=TRUE, mk.map=TRUE, mk.allele.dist=TRUE, mk.pdf=TRUE)

Run the code above in your browser using DataLab