subset_snps: This function subsets a structure file based on a list of...

View source: R/subset_snps.R

subset_snpsR Documentation

This function subsets a structure file based on a list of loci to retain

Description

This function subsets a structure file based on a list of loci to retain

Usage

subset_snps(input.file, result.file, loci.to.keep, popnumbers = FALSE)

Arguments

input.file

A character string giving the path to the file to subset

result.file

A character string name of your result file

loci.to.keep

A vector of character strings naming the loci to retain (based on the locus names in the original file)

popnumbers

an optional logical stating whether to convert the population column from character strings to numbers (default = FALSE)

Examples

 ## set directory for results to be written
 setwd("path/to/working/directory")

 # load example structure file
 stfile <- system.file("extdata", "Mfsub500.stru", package="melfuR")
 # generate list of loci to keep
 snplist <- as.data.frame(c("SNP_1", "SNP_45", "SNP_96"))

 # subset file to the three loci, keeping original population codes
 subset_snps(stfile, "new_file", snplist)

 # subset file to three loci, replacing original population codes with numbers
 subset_snps(stfile, "new_file", snplist, popnumbers = TRUE)

pygmyperch/melfuR documentation built on April 19, 2024, 7:24 a.m.