Description Usage Arguments Value Details See Also Examples
View source: R/genetic_functions.R
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.
1 |
sgsObj |
A data structure created by |
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) |
A list of the class 'sgsOut' that contains the following elements, which can be accessed with the $ operator (see examples):
sgsObj - the original sgsObj data structure used in the sgs analysis
di - summary of distance intervals used in analysis (see Details for more information)
fij_obs - observed Fij values in each distance interval for each locus, and averaged across loci
sp_obs - observed values of the Sp statistic in each distance interval for each locus, and averaged across loci
slope_obs - observed values of the slope of the regression of pairwise Fij on log distance for each distance interval and locus, and also averaged across loci
fij_perm_avg - average value of fij for each locus and distance interval after permutation of spatial locations among individuals
fij_perm_025 - lower 2.5% quantile of fij for each locus and distance interval after permutation of spatial locations among individuals
fij_perm_975 - upper 97.5% quantile of fij for each locus and distance interval after permutation of spatial locations among individuals
di
A summary of information about each distance interval. Includes:
Max distance - maximum pairwise distance within distance interval.
Average distance - average pairwise distance within distance interval.
Number of pairs - number of pairwise comparisons within distance interval.
% participation - the proportion of all individuals represented at least once in each distance interval
CV participation - the coefficient of variation (CV) of the number of times each individual is represented in each distance interval
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,
createSgsObj
, summary.sgsOut
, plot.sgsOut
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.