sgs: Run spatial genetic struture analysis

Description Usage Arguments Value Details See Also Examples

View source: R/genetic_functions.R

Description

sgs is the primary function for analysis of spatial genetic structure in the sgsR package. This function takes the data structure generated by createSgsObj as its primary argument, runs an analysis of spatial genetic structure (see Details below), and outputs the results.

Usage

1
sgs(sgsObj, distance_intervals, nperm = 999, dist_mat = NULL)

Arguments

sgsObj

A data structure created by createSgsObj

distance_intervals

either a vector with upper limits of distance intervals, or a negative integer with number of distance intervals to generate with approximately equal pairwise comparisons

nperm

Number of permutations of spatial locations among individuals to perform

dist_mat

A user-supplied distance matrix (Optional)

Value

A list of the class 'sgsOut' that contains the following elements, which can be accessed with the $ operator (see examples):

Details

di

A summary of information about each distance interval. Includes:

Values are checked against the rules of thumb presented by in the SPAGeDi manual and Vekemans and Hardy 2004 that the number of pairwise comparisons should be at least 100,

See Also

createSgsObj, summary.sgsOut, plot.sgsOut

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
## Simulate genetic data
Nind = 100 # Number of individuals
Nloci = 5 # Number of loci
Nallele = 10 # Number of alleles per loci

## Set up data frame and generate random spatial locations
dat <- data.frame(id = 0:(Nind - 1))
dat$x = runif(Nind, 0, 100)
dat$y = runif(Nind, 0, 100)

## Simulate Random genetic data and assign loci names
for (loci in 1:Nloci) {
 loci_name_a = paste("Loc", loci, "_A", sep = "")
 loci_name_b = paste("Loc", loci, "_B", sep = "")
 dat[loci_name_a] <- sample.int(Nallele, Nind, replace = TRUE)
 dat[loci_name_b] <- sample.int(Nallele, Nind, replace = TRUE)
}

## Convert to sgsObj
sgsObj = createSgsObj(sample_ids = dat$id,
                     genotype_data = dat[, 4:(Nloci*2 + 3)],
                     ploidy = 2,
                     x_coords = dat$x,
                     y_coords = dat$y)
summary(sgsObj)

lukembrowne/sgsR documentation built on May 21, 2019, 8:58 a.m.