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

Description Usage Arguments Examples

View source: R/subset_snps.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 ## 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 Oct. 10, 2020, 1:23 p.m.