plotMap: Plotting of maps

Description Usage Arguments Value Author(s) Examples

View source: R/Postprocessing.R

Description

Plots several kinds of maps (environmental variable distribution, population structure, marker absence or presence, autocorrelation of marker). Unlike plotResultInteractive, the resulting maps are non-interactive. The function can handle several marker/variables at once and create separate output files.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plotMap(
  envFile,
  x,
  y,
  locationProj,
  popStrCol,
  gdsFile,
  markerName,
  mapType,
  varEnvName,
  SAMethod = NULL,
  SAThreshold = NULL,
  saveType = NULL,
  rasterName = NULL,
  simultaneous = FALSE
)

Arguments

envFile

char The file containing the input environmental variable of sambada.

x

char The name of the column corresponding to the x-coordinate in the envFile. Can be set to null if unknown, in this case the maps will not be available

y

char The name of the column corresponding to the y-coordinate in the env file. Can be set to null if x is null.

locationProj

integer EPSG code of the geographical projection in the envFile

popStrCol

char The name or vector of name of column(s) in envFile describing population structure. If provided, additional layers on the map will be available representing population structure.

gdsFile

char The GDS file created in the preprocessing of sambada. If null, will try with envFile(without -env.csv) and .gds

markerName

name of the marker to be plotter if mapType is 'marker' or 'AS'. markerName can be found in preparedOutput$sambadaOutput[,”] where preparedOutput would be the result of the function prepareOutput

mapType

char A string or vector of string containing one or several of 'marker' (presence/absence of marker), 'env' (environmental variable distribution), 'popStr' (population variable on continuous scale), 'popPieChart' (belonging to a population in pie charts), 'AS' (autocorrelation of the marker). Note that the background of all maps, if found, will be the raster of the environmental variable. Thus the 'env' mapType is preferred when no raster is provided. For the 'AS' type, it is calculated on the fly for the markers provided and not the one possibly calculated by sambada.

varEnvName

char Name of the environmental variable. If a raster of the variable is located in your working directory, you can provide varEnvName even for mapType such as 'marker' or 'AS'. The function will scan the folder of your working directory for raster with the same name as varEnvName (and commonly used extension for raster) and put it as background.

SAMethod

char If mapType contains 'AS', then you must specify the method for setting the weights of neighbours. Can be one of 'knn' (k-nearest neighbours) or 'distance'

SAThreshold

char If mapType contains 'AS' and SAMethod is 'knn' then the number of neighbours. If SAMethod is 'distance' then the distance in map-unit (unless you use a spherical projection (latitude/longitude), in which case you should use km)

saveType

char One of NULL, 'png' or 'pdf'. If NULL is set, the maps will be shown in the R plotting window. Otherwise, it will be saved in the specified format in your working directory.

rasterName

char If a raster file with the environmental variable distribution exists with a different name than varEnvName, provide it here (including extension)

simultaneous

boolean If TRUE and mapType contains several kinds of maps, all maps corresponding to the same marker will be plotted on the same window. The resulting maps can be very small.

Value

None

Author(s)

Solange Duruz

Examples

 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
# Define right GDS file according to your OS
if(Sys.info()['sysname']=='Windows'){
  gdsFile=system.file("extdata", "uganda-subset-mol_windows.gds", package = "R.SamBada")
} else {
  gdsFile=system.file("extdata", "uganda-subset-mol_unix.gds", package = "R.SamBada")
}
#############
# Run plotMap
#############
# Map of environmental variable

plotMap(envFile=system.file("extdata", "uganda-subset-env-export.csv", package = "R.SamBada"), 
     x='longitude', y='latitude', locationProj=4326,  popStrCol='pop1', gdsFile=gdsFile, 
     markerName='Hapmap28985-BTA-73836_GG', mapType='env', varEnvName='bio1', 
     simultaneous=FALSE)

plotMap(envFile=system.file("extdata", "uganda-subset-env-export.csv", package = "R.SamBada"), 
     x='longitude', y='latitude', locationProj=4326,  popStrCol='pop1', gdsFile=gdsFile, 
     markerName='Hapmap28985-BTA-73836_GG', mapType='marker', varEnvName='bio1', 
     simultaneous=FALSE)

# Maps of marker and population structure (two subplot)
plotMap(envFile=system.file("extdata", "uganda-subset-env-export.csv", package = "R.SamBada"),
     'longitude','latitude', locationProj=4326,  popStrCol='pop1', 
     gdsFile=gdsFile, markerName='Hapmap28985-BTA-73836_GG', 
     mapType=c('marker', 'popStr'), varEnvName='bio1', simultaneous=TRUE)

R.SamBada documentation built on Jan. 5, 2022, 1:08 a.m.