write.GeneMapper: Write Genotypes to a Table Similarly to ABI GeneMapper

View source: R/dataexport.R

write.GeneMapperR Documentation

Write Genotypes to a Table Similarly to ABI GeneMapper

Description

Given a genambig object, write.GeneMapper writes a text file of a table containing columns for sample name, locus, and alleles.

Usage

write.GeneMapper(object, file = "", samples = Samples(object),
                 loci = Loci(object))

Arguments

object

A genambig object containing genotype data to write to the file. The Ploidies slot is used for determining how many allele columns to make.

file

Character string. The path to which to write the file.

samples

Character vector. Samples to write to the file. This should be a subset of Samples(object).

loci

Character vector. Loci to write to the file. This should be a subset of Loci(object).

Details

Although I do not know of any population genetic software other than polysat that will read this data format directly, the ABI GeneMapper Genotypes Table format is a convenient way for the user to store microsatellite genotype data and view it in a text editor or spreadsheet software. Each row contains the sample name, locus name, and alleles separated by tabs.

The number of allele columns needed is detected by the maximum value of Ploidies(object,samples,loci). The function will add additional columns if it encounters genotypes with more than this number of alleles.

write.GeneMapper handles missing data in a very simple way, in that it writes the missing data symbol directly to the table as though it were an allele. If you want missing data to be represented differently in the table, you can open it in spreadsheet software and use find/replace or conditional formatting to locate missing data.

The file that is produced can be read back into R directly by read.GeneMapper, and therefore may be a convenient way to backup genotype data for future analysis and manipulation in polysat. (save can also be used to backup an R object more directly, including population and other information.) This can also enable the user to edit genotype data in spreadsheet software, if the editGenotypes function is not sufficient.

Value

A file is written but no value is returned.

Author(s)

Lindsay V. Clark

References

GeneMapper website: https://www.thermofisher.com/order/catalog/product/4475073

See Also

read.GeneMapper, write.Structure, write.GenoDive, write.Tetrasat, write.ATetra, write.POPDIST, write.SPAGeDi, editGenotypes

Examples

# create a genotype object (usually done by reading a file)
mysamples <- c("ind1", "ind2", "ind3", "ind4")
myloci <- c("loc1", "loc2")
mygendata <- new("genambig", samples=mysamples, loci=myloci)
mygendata <- reformatPloidies(mygendata, output="one")
Genotypes(mygendata, loci="loc1") <- list(c(202,204), c(204),
                                          c(200,206,208,212),
                                          c(198,204,208))
Genotypes(mygendata, loci="loc2") <- list(c(78,81,84),
                                          c(75,90,93,96,99),
                                          c(87), c(-9))
Ploidies(mygendata) <- 6

## Not run: 
# write a GeneMapper file
write.GeneMapper(mygendata, "exampleGMoutput.txt")

# view the file with read.table
read.table("exampleGMoutput.txt", sep="\t", header=TRUE)

## End(Not run)


polysat documentation built on Aug. 23, 2022, 5:07 p.m.