bpec.contourPlot {BPEC}R Documentation

Plot contours of inferred clusters on geographical map


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.


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



R object from bpec.mcmc run


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


(optional) A vector of color codes.


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


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


The level of zoom into the map, default 6.


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.


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


Ioanna Manolopoulou, Axel Hille and Steve Brooks


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.


#to use example dataset:
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') 

[Package BPEC version 1.3.1 Index]