AdaptR: Run the AdaptR model

Description Usage Arguments Value Examples

Description

Run the AdaptR model

Usage

1
2
3
4
5
6
7
8
AdaptR(run.name, parameter.file.name, ncols, nrows, output.folder.path,
  verbose.outputs = FALSE, n.time.points, n.env.vars, env.vars.names,
  env.grids.folder.path, env.grids.name.file, species.initial.grid,
  minimum.survival.percentage = 5, resident.population.weighting = 1000,
  dispersal.neighbourhood.file, species.location.file, env.lower.thresholds,
  env.upper.thresholds, env.low.adaptation, env.high.adaptation, adapt.limit,
  heritability, fitness.cost, adapt.threshold.grids, adapt.threshold.grid.names,
  phenotypic.sd.grid, phenotypic.sd.grid.names, phenotypic.sd.value, plasticity)

Arguments

run.name

A suitable name for the simulation run

parameter.file.name

A file path to the parameter file, which will be created & called

ncols

The number of columns on the spatial grid

nrows

The number of rows on the spatial grid

output.folder.path

A valid path to a folder where the results will be written

verbose.outputs

If TRUE, predictions will be written out at each time step

n.time.points

The number of time points in the simulation, which will equal the number of compacted environment grids

n.env.vars

The number of environment variables being considered

env.vars.names

A list of the names of the environment variables being considered

env.grids.folder.path

A valid path to the folder containing the compacted environment grids

env.grids.name.file

A file path to the file holding the names of the compacted environment grids, in order of their implementation in the simulation

species.initial.grid

A file path to the ascii file for the initial occurrence of the focal species, where 1 = present, 0 = absent, -9999 = not valid potential habitat.

minimum.survival.percentage

The percent of current population size below which local extinction will occur following a selection event. The complement of this value is used as the threshold below which evolutionary adaptation will occur.

resident.population.weighting

The percent weighting of a resident population when considering admixture through dispersal from neighbouring populations (weighted by dispersal probability)

dispersal.neighbourhood.file

A file path to the dispersal neighbourhood for AdaptR (.dna) file specifying the dispersal probability in the relative neighbourhood around each cell. See "Create_Dispersal"

species.location.file

A file path to a text file specifying the x and y coordinates for populations (grid cells) where outputs will be written for each generation. Format is space delimited text (.txt) of two columns, with row 1 = n_locations n, row 2 = Longitude Latitude, then n rows specifying the x & y locations to track

env.lower.thresholds

A list of length n.env.vars, specifying the lower tolerance threshold value for each environmental variable

env.upper.thresholds

A list of length n.env.vars, specifying the upper tolerance threshold value for each environmental variable

env.low.adaptation

A logical list (TRUE, FALSE) of length n.env.vars, specifying for each environmental variable whether adaptation on the lower tolerance threshold is being considered

env.high.adaptation

A logical list (TRUE, FALSE) of length n.env.vars, specifying for each environmental variable whether adaptation on the upper tolerance threshold is being considered

adapt.limit

A list of length n.env.vars specifying the value beyond which the threshold tolerance cannot adapt further

heritability

A list of length n.env.vars specifying the heritability of threshold tolerance attribute for each environmental variable

fitness.cost

A list of length n.env.vars specifying the 'fitness cost' of adaptation away from the original threshold tolerance values. This is the slope of the linear relation between the intensity of stabilising selection and the squared distance from the original threshold tolerance trait value.

adapt.threshold.grids

A logical list (TRUE, FALSE) of length n.env.vars, specifying for each environmental variable whether spatial grids will be provided specifying the initial threshold tolerance in each grid cell

adapt.threshold.grid.names

Where relevant, a list of length n.env.vars specifying the file paths to the ascii files of the initial threshold tolerance value across the grid

phenotypic.sd.grid

A logical list (TRUE, FALSE) of length n.env.vars, specifying for each environmental variable whether spatial grids will be provided specifying the initial phenotypic standard deviation for threhold tolerances in each grid cell

phenotypic.sd.grid.names

Where relevant, a list of length n.env.vars specifying the file paths to the ascii files of the initial threshold tolerance phenotypic standard deviation value across the grid

phenotypic.sd.value

Where relevant, a list of length n.env.vars specifying the initial phenotypic standard deviation values to be applied for all grid cells, for each environmental tolerance threshold.

plasticity

A list of length n.env.vars specifying the plasticity in the threshold tolerance trait for each environmental variable.

Value

A set of output files written in the specified folder, each containing the run.name

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## Complete example of the multiple steps in applying AdaptR using data example provided for Drosophila jambulina

# 1. Set the filepath to the example data set
filepath.data <- system.file("extdata", package="AdaptR")

# 2. Create text files to describe the file path to each input variable, and the output variable
write.table((file.path(filepath.data,"Tmax",paste0("Tmax",seq(1:159),".asc"))), file = file.path(filepath.data,"Tmax","Tmax_filenames.txt"), eol = "\n", row.names = FALSE, col.names = FALSE, quote=FALSE )
write.table((file.path(filepath.data,"Habitat",paste0("Habitat",seq(1:159),".asc"))), file = file.path(filepath.data,"Habitat","Habitat_filenames.txt"), eol = "\n", row.names = FALSE, col.names = FALSE, quote=FALSE )
write.table((file.path(filepath.data,"compact_grids",paste0("demo_compact_grids_T",seq(1:159)))), file = file.path(filepath.data,"compact_grids","demo_compact_grids_output_filenames.txt"), eol = "\n", row.names = FALSE, col.names = FALSE, quote=FALSE )

# 3. Run the grid compactor
CompactGrids(compactor.parameter.file.name = file.path(filepath.data,"species_inputs","Jambulina__grid_compactor_parameter_file.txt"),
             ncols = 100,
             nrows = 79,
             n.env.vars = 2,
             n.time.points = 159,
             raw.env.grids.name.files = c(file.path(filepath.data,"Tmax","Tmax_filenames.txt"),file.path(filepath.data,"Habitat","Habitat_filenames.txt")),
             output.env.name.file = file.path(filepath.data,"compact_grids","demo_compact_grids_output_filenames.txt"))

# 4. Generate a dispersal kernel for the drosophila example
filepath.data <- system.file("extdata", package="AdaptR")
Dispersal_Neighbourhood(radius=5, 
                       type="neg.power", 
                       params=c(1,1), 
                       output.name="Dispersal_relfile_L1_K1_rad5",
                       output.directory=file.path(filepath.data,"species_inputs"),
                       dispersal.plot=TRUE)  

# 5. Create text files to describe the file path to the compact grids
write.table(paste0("demo_compact_grids_T",rep(1:159, length.out=159)), file = file.path(filepath.data,"species_inputs","compact_series_names.txt"), eol = "\n", row.names = FALSE, col.names = FALSE, quote=FALSE )

# 6. Run the AdaptR model
AdaptR(run.name = "jambulina_test",
        parameter.file.name = file.path(filepath.data,"outputs","jambulina_test_parameters.txt"),
        ncols = 100,
        nrows = 79,
        output.folder.path = file.path(filepath.data,"outputs"),
        verbose.outputs = FALSE,
        n.time.points = 159,
        n.env.vars = 2,
        env.vars.names = c("MaxTemp", "Other_Maxent"),
        env.grids.folder.path = file.path(filepath.data,"compact_grids"),
        env.grids.name.file = file.path(filepath.data,"species_inputs","compact_series_names.txt"),
        species.initial.grid = file.path(filepath.data,"species_inputs","demo_jambulia_initial_distribution.asc"),
        minimum.survival.percentage = 5,
        resident.population.weighting = 1000,
        dispersal.neighbourhood.file = file.path(filepath.data,"species_inputs","Dispersal_relfile_L1_K1_rad5.dna"),
        species.location.file = file.path(filepath.data,"species_inputs","demo_locations_out.txt"),
        env.lower.thresholds = c(19.47,0.99),
        env.upper.thresholds = c(37.94547,1.01),
        env.low.adaptation = c(FALSE,FALSE),
        env.high.adaptation = c(TRUE,FALSE),
        adapt.limit = c(40,0),
        heritability = c(0.53,0),
        fitness.cost = c(0.05,0),
        adapt.threshold.grids = c(FALSE,FALSE),
        phenotypic.sd.grid = c(FALSE,FALSE),
        phenotypic.sd.value = c(1.106,0),
        plasticity = c(1.106,0))

# 7. Map the predictions of the model (at the last time point)
map.single.run(output.folder.path = file.path(filepath.data,"outputs"), 
               run.name = "jambulina_test")

KarelMokany/AdaptR documentation built on May 8, 2019, 4:48 p.m.