read.structure: Read 'Structure' data file

Description Usage Arguments Value Author(s) Examples

View source: R/read.structure.R

Description

Read a data file formatted as input for ‘Structure’

Usage

1
read.structure(file, suffix = c("A", "B"))

Arguments

file

file name.

suffix

suffix to be attached to column names containing homologous alleles.

Value

A data.frame, where rows represent individuals. The first column patch gives the patch number, and the remaining columns contain integer allele values.

Author(s)

Kamil Bartoń

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#read example file:
dat <- read.structure(system.file(package = "ibmpm", "examples", "structure.txt"))

# infer sex from rownames
dat$sex <- factor(gsub("^.*([MF])[0-9]+$", "\\1", rownames(dat), perl = TRUE),
		levels = c("F", "M"))

head(dat)

n.patch <- max(dat$patch)
# random dispersal matrix
disp.mat <- array(runif(n.patch^2), dim = c(n.patch, n.patch))

dat <- metapop(disp.mat, dat, sim.len = 20, n.offspring = 5, carr.cap = 100)

ibmpm documentation built on May 2, 2019, 5:45 p.m.