data(nancycats)
ia(nancycats)
# Pairwise over all loci:
data(partial_clone)
res <- pair.ia(partial_clone)
plot(res, low = "black", high = "green", index = "Ia")
# Get the indices back and plot them using base R graphics:
nansamp <- ia(nancycats, sample = 999, valuereturn = TRUE)
layout(matrix(c(1,1,2,2), 2, 2, byrow = TRUE))
hist(nansamp$samples$Ia); abline(v = nansamp$index[1])
hist(nansamp$samples$rbarD); abline(v = nansamp$index[3])
layout(matrix(c(1,1,1,1), 1, 1))
# You can also view them directly:
plot(nansamp, index = "Ia")
plot(nansamp, index = "rbarD")
# Get the index for each population.
lapply(seppop(nancycats), ia)
# With sampling
lapply(seppop(nancycats), ia, sample = 999)
# Plot pairwise ia for all populations in a grid with cowplot
# Set up the library and data
library("cowplot")
data(monpop)
splitStrata(monpop) <- ~Tree/Year/Symptom
setPop(monpop) <- ~Tree
# Need to set up a list in which to store the plots.
plotlist <- vector(mode = "list", length = nPop(monpop))
names(plotlist) <- popNames(monpop)
# Loop throgh the populations, calculate pairwise ia, plot, and then
# capture the plot in the list
for (i in popNames(monpop)){
x <- pair.ia(monpop[pop = i], limits = c(-0.15, 1)) # subset, calculate, and plot
plotlist[[i]] <- ggplot2::last_plot() # save the last plot
}
# Use the plot_grid function to plot.
plot_grid(plotlist = plotlist, labels = paste("Tree", popNames(monpop)))
Run the code above in your browser using DataLab