Description Usage Arguments Value Examples
View source: R/plotting_functions.R
Plot spatial locations of individuals in sgsObj data structure
1 2 |
x |
An sgsObj data structure to be plotted |
pch |
Type of plotting character to display |
... |
Any arguments to pass to the generic plot function |
Plots the spatial location of individuals in the sgsObj data structure.
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 | ## 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,
missing_val = -999)
summary(sgsObj)
plot(sgsObj)
plot(sgsObj, pch = 21, col = "steelblue", cex = 1.5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.