vcfR (version 1.8.0)

vcfR2migrate: Convert a vcfR object to MigrateN input file

Description

The function converts a vcfR object to a text format that can be used as an infile for MigrateN.

Usage

vcfR2migrate(vcf, pop, in_pop, out_file = "MigrateN_infile.txt",
  method = c("N", "H"))

Arguments

vcf

a vcfR object.

pop

factor indicating population membership for each sample.

in_pop

vector of population names indicating which population to include in migrate output file.

out_file

name of output file.

method

should 'N' or 'H' format data be generated?

Value

a text file that can be used as an input for MigrateN software (SNP format).

Details

This function converts a vcfR object to a text file which can be used as input for MigrateN. The function will remove loci with missing data, indels, and loci that are not bialleleic (loci with more than two alleles). Thus, only SNP data analysed where the length of each locus (inmutational steps) is 1 (as opposed to microsatellites or indels).

The output file should contain Unix line endings ("\n"). Note that opening the output file in a Windows text editor (just to validate number of markers, individuals or populations) might change the end of line character (eol) to a Windows line ending ("\r\n"). This may produce an error running migrate-n. Because these are typically non-printing characters, this may be a difficult problem to troubleshoot. The easiest way to circumvent the problem is to transfer the output file to Unix machine and view it there. If you do introduce Windows line endings you can convert them back to Unix with a program such as `dos2unix` or `fromdos` to change the line endings.

See Also

Migrate-N website.

Examples

Run this code
# NOT RUN {
data(vcfR_example)
my_pop <- as.factor(paste("pop_", rep(c("A", "B", "C"), each = 6), sep = ""))
vcfR2migrate(vcf = vcf , pop = my_pop , in_pop = c("pop_A","pop_C"),
             out_file = "my2pop.txt", method = 'H')
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab