save_microsimr: Create input files

Description Usage Arguments Examples

Description

Create input files

Usage

1
2
save_microsimr(genotypes, filename, n_ind, n_pop, n_loc, format = "migrate-n",
  title = "microsimr simulated data")

Arguments

genotypes

A matrix outputted by sim_microsats function.

filename

A character string indicating the filename to be used for saving the input file.

n_ind

An integer indicating the number of sampled diploid individuals if n_pop = 1, or a vector of integers indicating the number of diploid individuals sampled in each population in n_pop > 1.

n_pop

An integer indicating the number of populations simulated.

n_loc

An integer indicating the number of loci simulated.

format

A character string indicating the format desired. Currently, 'migrate-n' is the only possible option.

title

A character string to be used as the title of the input file, only used if the format allows it.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#simulate a dataset with theta = 20, 5 loci genotyped at a total of 10
# individuals, with 5 individuals taken from each of 2 populations. The
# populations are connected by 4 migrants/generation (4Nem = 4).

simd_data <- microsimr::sim_microsats(theta = 20,
                                     n_ind = c(5,5),
                                     n_loc = 5,
                                     n_pop = 2,
                                     ms_options = "-I 2 10 10 4")

# write an input file for migrate-n
## Not run: 
microsimr::save_microsimr(genotypes = simd_data,
                         filename = "infile",
                         n_ind = c(5,5),
                         n_pop = 2,
                         n_loc = 5,
                         format = 'migrate-n')

## End(Not run)

## Not run: 
# changing the format to anything else other than 'migrate-n' currently
generates an error
microsimr::save_microsimr(genotypes = simd_data,
                         filename = "infile",
                         n_ind = c(5,5),
                         n_pop = 2,
                         n_loc = 5,
                         format = 'ima2')

## End(Not run)

andersgs/microsimr documentation built on May 12, 2019, 2:42 a.m.