bpec.contourPlot: Plot contours of inferred clusters on geographical map

Description Usage Arguments Details Value Author(s) References Examples

View source: R/bpec.contourPlot.R

Description

Plots the contours for a set of population clusters, adding points for sampling locations, with larger points representing inferred ancestral locations. Assuming that the data input is in latitude and longitude form, the contour is superimposed onto the map of the corresponding region.

Usage

1
2
bpec.contourPlot(bpecout, GoogleEarth = 0, 
colorCode = c(7,5,6,3,2,8,4,9), mapType = 'plain', mapCentre = NULL, zoom = 6)

Arguments

bpecout

R object from bpec.mcmc run

GoogleEarth

If 1, .kml files are produced which can be opened with GoogleEarth.

colorCode

(optional) A vector of color codes.

mapType

Options are 'none' (no map shown in the background), 'plain' (outline shown only), 'google' (google maps), 'osm' (openstreetview maps).

mapCentre

(optional) The longitude and latitude to use as the centre of the map. If not provided, the midpoint of sampling range will be used.

zoom

The level of zoom into the map, default 6.

Details

Contours with level 0.5 of the posterior mean centres amd covariances of the clusters are shown on the map, with colour representing cluster index. Posterior samples are shown with semi-transparent filled contours, so that uncertainty can be represented directly on the map together with the posterior means. The sampling locations are shown as black dots, with the top three (in terms of posterior probability) ancestral locations represented by larger dots. If GoogleEarth=1, this same plot is exported in files that can be directly loaded into Google Earth.

Value

Produces a contour plot overlayed on a map. If GoogleEarth=1, files which may be loaded directly into Google Earth are produced.

Author(s)

Ioanna Manolopoulou, Axel Hille and Steve Brooks

References

I. Manolopoulou, A. Hille, B.C.Emerson B (2020). BPEC: An R Package for Bayesian Phylogeographic and Ecological Clustering. Journal of Statistical Software, 92(3), 1-32. doi: 10.18637/jss.v092.i03

D. Kahle and H. Wickham. ggmap: Spatial Visualization with ggplot2. The R Journal, 5(1), 144-161. URL http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf

I. Manolopoulou, L. Legarreta, B.C. Emerson, S. Brooks, and S. Tavare (2011). A Bayesian approach to phylogeographic clustering. Interface focus, rsfs20110054.

S.P. Brooks, I. Manolopoulou, and B.C. Emerson (2007). Assessing the Effect of Genetic Mutation - A Bayesian Framework for Determining Population History from DNA Sequence Data. Bayesian Statistics 8. Oxford University Press.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#to use example dataset:
data(MacrocnemisRawSeqs)
data(MacrocnemisCoordsLocs)
rawSeqs <- MacrocnemisRawSeqs
coordsLocs <- MacrocnemisCoordsLocs

##to use your own dataset: 
#rawSeqs <- bpec.loadSeq('Haplotypes.nex')
#coordsLocs <- bpec.loadCoords("coordsLocsFile.txt")

## to set phenotypic/environmental covariate names manually, use (as appropriate)
# colnames(coordsLocs)[1:dims] <- c('lat','long','cov1','cov2','cov3')   
## where dims is the corresponding number of measurements available 
## (2 for latitude and longitude only, add one for each additional available measurement) 

#for the analysis: 
#check the helpfile of bpec.mcmc using ?bpec.mcmc
colorCode <- c(7,5,6,3,2,8) #default colour scheme
bpecout <- bpec.mcmc(rawSeqs, coordsLocs, maxMig = 2, iter = 20, ds = 0, postSamples = 2, dims = 8)
bpec.contourPlot(bpecout, GoogleEarth = 0, colorCode, mapType = 'plain') 

BPEC documentation built on March 2, 2020, 1:07 a.m.