write_to_structure: Take simulated genotypes and write to a STRUCTURE input file...

Description Usage Arguments Value Examples

View source: R/write_to_structure.R

Description

Take simulated genotypes and write to a STRUCTURE input file format.

Usage

1
2
3
4
5
6
7
8
9
write_to_structure(
  sim_data,
  structure_snp_order = NULL,
  example_structure_file = NULL,
  sample_names = NULL,
  output = "test",
  type = c("txt", "csv"),
  keep_extra_snps = TRUE
)

Arguments

sim_data

Output from simulate_admixture

structure_snp_order

(Optional) The desired order of SNPs for columns of output file.

example_structure_file

(Optional) A sample STRUCTURE input file to extract the desired order of SNPs from. If both example_structure_file and structure_snp_order are specified, the order given by this will take precedence.

sample_names

(Optional) vector of names for the simulated samples.

output

Name for the output file.

type

Options for txt or csv file outputs.

keep_extra_snps

If there are SNPs present in the simulated data, but not in the SNP order provided by example_structure_file or structure_snp_order, should the extra SNPs be kept and appended to the table (on the right)?

Value

NULL

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#Download files to temporary directory:
temp_dir <- tempdir()
download.file(url = "https://raw.githubusercontent.com/danwkenn/SimAdmixtR/master/inst/example-files/input-allele-frequencies-three-snps.csv",destfile = paste0(temp_dir,"/input-af-example.csv"))
download.file(url = "https://raw.githubusercontent.com/danwkenn/SimAdmixtR/master/inst/example-files/simple-three-allele-example.csv",destfile = paste0(temp_dir,"/example-structure-file.csv"))

sim_data <- simulate_admixture(
n_samples = 10,
ancestor_pop_label = c(1,2,2,2),
file = paste0(temp_dir,"/input-af-example.csv")
)

write_to_structure(
sim_data = sim_data,
example_structure_file = paste0(temp_dir,"/example-structure-file.csv"),
output = "example-output",
type = c("txt","csv"))

danwkenn/SimAdmixtR documentation built on May 30, 2020, 7:25 a.m.