diff --git a/.gitignore b/.gitignore index d2c23c6..e2faf87 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ workspace/ .Rproj.user PhylGeo.Rcheck/00_pkg_src 00check.log -phylosim.Rproj RcppExports.cpp .Rhistory diff --git a/PhyloSim/DESCRIPTION b/PhyloSim/DESCRIPTION index 77efec2..89865bd 100644 --- a/PhyloSim/DESCRIPTION +++ b/PhyloSim/DESCRIPTION @@ -2,8 +2,8 @@ Package: PhyloSim Type: Package Title: Analysis of Phylogenetic and Biogeographic patterns, inferring species community assembly -Version: 0.3 -Date: 2015-02-12 +Version: 0.3.0.1 +Date: 2024-01-19 Authors: c(person("Paul", "Bauche", role = c("aut","cre")), person("Florian", "Hartig", role = "aut"), person("Christian", "Buschbeck", role = "ctb"), @@ -34,7 +34,8 @@ Imports: Suggests: knitr LinkingTo: Rcpp +RoxygenNote: 7.3.0 +Roxygen: list(old_usage = TRUE, markdown = TRUE) LazyData: true VignetteBuilder: knitr -LinkingTo: Rcpp -RoxygenNote: 6.0.1 +Encoding: UTF-8 diff --git a/PhyloSim/R/PhyloSim-package.R b/PhyloSim/R/PhyloSim-package.R new file mode 100644 index 0000000..fe6b5cc --- /dev/null +++ b/PhyloSim/R/PhyloSim-package.R @@ -0,0 +1,28 @@ +#' @keywords internal +#' @title Analysing phylogenetic and biogeographic patterns and inferring species community assembly +#' @name PhyloSim +#' @useDynLib PhyloSim, .registration = TRUE +#' @description +#' This package is designed to simulate and analyse species community assembly processes. It allows the user to implement different mechanisms of community assembly such as environmental filtering, competitive exclusion or dispersal limitation. These mechanisms can be combined or activated seprately, which allows the user to identify biogeographic or phylogenetic patterns exclusively correlated with a certain mechanism or combination of mechanisms. +#' @details +#' The core of this package is basically a community assembly model, which can be run with \code{\link{runSimulation}} or \code{\link{runSimulationBatch}}. All other functions help analize and visualize the model outcome. For visualization the following functions can be useful: +#'\tabular{ll}{ +#' \code{\link{plotSpatialPhylo}} \tab Plots the phylogeny tree ,the spatially abundance of the evolved species and their traits.\cr +#' \code{\link{rac}} \tab Plots the Rank Abundance Curve for a given community\cr +#' \code{\link{sac}} \tab Plots the species area curve for a given community\cr +#' \code{\link{plotclades}} \tab Visualises the phylogenetic clades of a local community within a metacommunity.\cr +#' \code{\link{plotTraitDistribution}} \tab Plots trait-histograms, trait ~ Environment relationship and the spatial distribution of the different traits\cr +#'} +#' +#' +#'The function \code{\link{phyloReconstruct}} creates a phylogeny from given neutral traits of a community in order to compare them with the existing phylogeny. The observed patterns in the simulation output can be tested against null models using the function \code{\link{nullModel}}. +#' +#' +#' @author Paul Bauche, Florian Hartig +#' +#' @example /inst/examples/phylosim-help.R +#' +"_PACKAGE" +## usethis namespace: start +## usethis namespace: end +NULL \ No newline at end of file diff --git a/PhyloSim/R/createPhylosimList.R b/PhyloSim/R/createPhylosimList.R index a77bc48..99d0c09 100644 --- a/PhyloSim/R/createPhylosimList.R +++ b/PhyloSim/R/createPhylosimList.R @@ -3,21 +3,7 @@ #' @param simu List of objects of type Phylosim as created by \code{\link{runSimulation}} #' @return An object of type PhylosimList #' @details The function is used to make functions for objets of type "PhylosimList" usable for objects of class "Phylosim". The function needs at least two objets to work. -#' @examples -#' ## Create two objects of type Phylosim -#' par1 <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, -#' density = 1, environment = 0.5, specRate = 1) -#' par2 <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, -#' density = 1, environment = 0.5, specRate = 2) -#' -#' simu1 <- runSimulation(par1) -#' simu2 <- runSimulation(par2) -#' -#' ## Use the function -#' simuList <- createPhylosimList(list(simu1,simu2)) -#' -#' ## The object can now be handed to functions designed for objects of type "PhylosimList". -#' +#' @example /inst/examples/createPhylosimList-help.R #' @export diff --git a/PhyloSim/R/localPlots.R b/PhyloSim/R/localPlots.R index 201aa15..6ea627b 100644 --- a/PhyloSim/R/localPlots.R +++ b/PhyloSim/R/localPlots.R @@ -9,7 +9,7 @@ #' @param nested Logical, determining whether the subplots should be nested (see Details). #' @return A list of subplots and (if coomunity = T) a community table with plots in rows and species in collumns #' @details If nested == TRUE the subplots are poduced in a sequential order. That means if your 'size' argument has the length 5 and your 'n' argument has the size 2 you will get ten subplots. The first five will be one group of nested plots and the last five the second group of nested plots. -#' @example inst/examples/localPlots.R +#' @example inst/examples/localPlots-help.R #' @export localPlots <- function(simu, which.result=NULL,size, n, community = FALSE, plot = FALSE, nested = FALSE){ diff --git a/PhyloSim/R/neutralModelR.R b/PhyloSim/R/neutralModelR.R index ff14eff..8a7d9e0 100644 --- a/PhyloSim/R/neutralModelR.R +++ b/PhyloSim/R/neutralModelR.R @@ -7,22 +7,8 @@ #' @param runs The number of generations the model runs through #' @references Hubbell, Stephen P. The unified neutral theory of biodiversity and biogeography (MPB-32). Vol. 32. Princeton University Press, 2001. #' @details This model is to be seen only for test and teaching purpose. However, if you want to use the results for further analysis please call the model with \code{\link{runSimulation}}. \cr\cr Be careful with the dimensions you choose. Large grids and many generations may take very long to compute. You can assume to have reached the equilibrium state of the model after dim^2/2. -#' @examples -#' # Run the model -#' metaCom <- NeutralMod(xdim=50, ydim=50, specRate=2, seed=1500, runs=500) -#' image(metaCom) -#' -#' # Usually the function is called by the runSimualtion function -#' # Define a parameter set -#' parNeut <- createCompletePar(x = 50, y = 50, dispersal = FALSE , runs = 500, -#' density = 1, environment = 0.5, specRate = 1, type="Rneutral") -#' -#' # Run the model -#' simuNeut <- runSimulation(parNeut) -#' -#' # Visualize the grid -#' image(simuNeut$Output[[1]]$specMat) -#' +#' @example /inst/examples/neutralModelR-help.R + #' @export NeutralMod <- function( xdim = 100, ydim=100, specRate = 2, seed = NULL, runs = 500 ){ @@ -49,4 +35,4 @@ NeutralMod <- function( xdim = 100, ydim=100, specRate = 2, seed = NULL, runs } print (paste("Finished after",floor(((proc.time() - ptm)[3])/60), "minute(s) and", ((proc.time() - ptm)[3])%%60, "second(s).")) return (mat) -} \ No newline at end of file +} diff --git a/PhyloSim/R/nullModel.R b/PhyloSim/R/nullModel.R index c2e88cd..0983b59 100644 --- a/PhyloSim/R/nullModel.R +++ b/PhyloSim/R/nullModel.R @@ -8,36 +8,8 @@ #' @param repetitions number of generated null model plots #' @param fun String, phylogenetic measure that is used. Possible inputs are "mpd" (\code{\link[picante]{mpd}}) and "pd" (\code{\link[picante]{pd}}). Only used if abundance = FALSE. #' @return A numeric vector with pValues for each plot in the observed metacommunity -#' @examples -#' -#' ### Usage with runSimulation -#' ## Define a parameter set -#' par <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), density = 1, environment = 0.5, specRate = 1) -#' -#' ## Run Model -#' simu <- runSimulation(par) -#' -#' ## Compare to null model -#' nullModel(simu, abundance= FALSE, localPlotSize = 100, numberOfPlots = 10, repetitions = 10) -#' -#' ## Usage with runSimulationBatch -#' ## Define two (or multiple) parameter sets -#' par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), -#' density = 1, environment = 0.5, specRate = 1) -#' par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), -#' density = 2, environment = 0.5, specRate = 1) -#' -#' ## Merge the parameter sets. It is important to note, that the funktion -#' ## needs a list of parameter sets. -#' par <- list(par1,par2) -#' -#' ## Run the model -#' simubatch <- runSimulationBatch(par, parallel=2) -#' -#' ## Compare results to null model -#' nullModel(simubatch[[1]],localPlotSize = 100, numberOfPlots = 10, repetitions = 10) -#' nullModel(simubatch[[2]],localPlotSize = 100, numberOfPlots = 10, repetitions = 10) -#' +#' @example /inst/examples/nullModel-help.R + #' @export nullModel <- function(simu, which.result=NULL, abundance = FALSE, localPlotSize, numberOfPlots, repetitions, fun="mpd"){ diff --git a/PhyloSim/R/parCreator.R b/PhyloSim/R/parCreator.R index b037551..069e75b 100644 --- a/PhyloSim/R/parCreator.R +++ b/PhyloSim/R/parCreator.R @@ -23,14 +23,7 @@ #' @param prunePhylogeny Logical, determining whether the phylogeny should be prune by the internal pruning function #' @details If runs is a sequence of generations the intermediate and end results are saved in the output of \code{runSimulation}. \cr\cr If type = "Rneutral" the model will run entirely in R. This model is to be seen only for test and teaching purpose. To be used in practice it is far too slow. Also the output is reduced. Only the species landscape and the parameter settings will be displayed in the output. #' @return A List with parameters -#' @examples -#' ## Define a parameter set -#' par <- createCompletePar(x = 50, y = 50, dispersal = FALSE , runs = c(500,1000), -#' density = 1, environment = 0.5, specRate = 1) -#' -#' ## Run the model -#' simu <- runSimulation(par) -#' +#' @example /inst/examples/parCreator-help.R #' @export createCompletePar <- function(x = 50, y = 50, dispersal = "global", runs = 100, specRate = 1.0, density = 0, environment = 0, fitnessActsOn = "mortality" , fitnessBaseMortalityRatio = 10, densityCut = 1, seed=NULL, type = "base", fission = 0, redQueen = 0, redQueenStrength = 0, protracted = 0, airmat = 1, scenario = NULL, calculateSummaries = FALSE, convertToBinaryTree = TRUE, prunePhylogeny = TRUE){ diff --git a/PhyloSim/R/phylogeneticDispersion.R b/PhyloSim/R/phylogeneticDispersion.R index 8664af6..a284dcb 100644 --- a/PhyloSim/R/phylogeneticDispersion.R +++ b/PhyloSim/R/phylogeneticDispersion.R @@ -7,24 +7,9 @@ #' @param types String, determines which null model should be created. Possible inputs are "PhylMeta" (default), "PhylSample", "PhylPool", "SamplePool" (see details). #' @param which.result Integer, determines which result should be used. This argument is only usefull if your 'runs' argument in \code{\link{createCompletePar}} contains more than one element. By default (NULL), the last result is used. You can choose a particular result, a vector of results, or use all result with which.result = "all". #' @param fun String, determines which function should be used to calculate the phylogenetic diversity in the sample plot. Possible inputs are "mpd" or "pd" (see details). -#' @details In the types argument "PhylMeta" is equivalent to \code{\link{nullModel}} with abundance = FALSE, "PhylSample" is equivalent to the same function with abundance = TRUE, wheras the two other option use \code{\link[picante]{ses.mpd}}. "PhylPool" uses the argument null.model = "phylogeny.pool", "SamplePool" is setting null.model to "sample.pool". \cr\cr The fun argument is only used if types="PhylSample". For more information see \code{\link{nullModel}}. \cr \cr If yu choose which.result = NULL (default), the length of the output corresponds to the length of the 'runs' argument in your parameter definition. Otherwise the length of the list corresponds to the length of your which.result argument. \cr\cr The structure of the output is organitzed as follows with output[[n]] you will get the results for the scenario 'n'. With output[[n]][[t]] you will get the results for 'n' at timestep 't'. output[[n]][[t]] is a list that contains one vector with p values for each element in the plotlengths argument. +#' @details In the types argument "PhylMeta" is equivalent to \code{\link{nullModel}} with abundance = FALSE, "PhylSample" is equivalent to the same function with abundance = TRUE, wheras the two other option use \code{\link[picante]{ses.mpd}}. "PhylPool" uses the argument null.model = "phylogeny.pool", "SamplePool" is setting null.model to "sample.pool". \cr\cr The fun argument is only used if types="PhylSample". For more information see \code{\link{nullModel}}. \cr \cr If yu choose which.result = NULL (default), the length of the output corresponds to the length of the 'runs' argument in your parameter definition. Otherwise the length of the list corresponds to the length of your which.result argument. \cr\cr The structure of the output is organitzed as follows with `output[[n]]` you will get the results for the scenario 'n'. With `output[[n]][[t]]` you will get the results for `n` at timestep `t`. `output[[n]][[t]]` is a list that contains one vector with p values for each element in the plotlengths argument. #' @return A list with pValues for each plot in the observed metacommunity. If you have calculated multiple scenarios, the results can be visualized by \code{\link{plotPhylogeneticDisperion}}. -#' @examples -#' ## Create a set of parameters -#' par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), -#' density = 0, environment = 0.5, specRate = 1) -#' par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), -#' density = 1, environment = 0.5, specRate = 1) -#' -#' ## Merge the parameter sets. -#' par <- list(par1,par2) -#' -#' ## Run the model -#' simu <- runSimulationBatch(par, parallel = 2) -#' -#' ## Calculate null model and compare the observed results against -#' pValues <- calculatePhylogeneticDispersion(simu, plotlength=20, plots=20, replicates=20, type="PhylMeta") -#' +#' @example /inst/examples/phylogeneticDispersion-help.R #' #' @export diff --git a/PhyloSim/R/plotHighlightLocalPhylo.R b/PhyloSim/R/plotHighlightLocalPhylo.R index 548b4f1..316ba9e 100644 --- a/PhyloSim/R/plotHighlightLocalPhylo.R +++ b/PhyloSim/R/plotHighlightLocalPhylo.R @@ -7,37 +7,7 @@ #' @param subplot if no simu object is given, a communitytable of a local community can be given here #' @param phylogeny if no simu object is ginve, an object of the class 'phylo' can be given here to describe the communites phylogeny #' @details This function works with a single simu object (class "phylosim"). If no simu object is given, it is also possible to calculate the clades from a given phylogeny and localc plots. Here the phylogeny represents the metacommunity wihtin which the local plots create the clades -#' @examples -#' -#' #Load data -#' data(simu.neutral.global) -#' data(simu.neutral.local) -#' data(simu.envcom.local) -#' -#' -#' -#' #Plot clades for neutral model with global dispersal with three subplots -#' par(mfrow=c(1,3)) -#' highlightLocalPhylo(simu.neutral.global, size = 50, n = 3) -#' -#' -#' -#' #Plot clades for neutral model with local dispersal with three subplots -#' par(mfrow=c(1,3)) -#' highlightLocalPhylo(simu.neutral.local, size = 50, n = 3) -#' -#' -#' -#'#Plot clades for environment and competition model with global dispersal with three subplots -#' par(mfrow=c(1,3)) -#' highlightLocalPhylo(simu.envcom.local, size = 50, n = 3) -#' -#' -#' -#'#increasing plot size -#'par(mfrow=c(2,2)) -#'highlightLocalPhylo(simu.envcom.local, size = 50, n =2) -#'highlightLocalPhylo(simu.envcom.local, size = 1000, n =2) +#' @example /inst/examples/plotHighlightLocalPhylo-help.R #' @export highlightLocalPhylo <- function(simu,which.result=NULL, size, n, subplot = NULL, phylogeny=NULL){ diff --git a/PhyloSim/R/plotPhylogeneticDispersion.R b/PhyloSim/R/plotPhylogeneticDispersion.R index a007ea5..d5a6320 100644 --- a/PhyloSim/R/plotPhylogeneticDispersion.R +++ b/PhyloSim/R/plotPhylogeneticDispersion.R @@ -10,51 +10,7 @@ #' @param ymin Float, determines the plot limit (min) of the y axis. #' @param means Integer, determines the number of results which are used to average the results. #' @details In every subplot the x-axis represents the size of the subplots used in the null models. Hence, it is recommended to use a vector of plot sizes in your \code{\link{calculatePhylogeneticDispersion}} setup. \cr\cr The which.result argument here is used on the input list of p-values. Hence, which.result = 1 plots the first list slice of the input here. This is not necessarily the first time step of of your parameter settings in \code{\link{runSimulationBatch}}. \cr\cr For an further explanation please see the Examples section. -#' @examples -#' ## First the experimental design has to be defined. -#' ## In this example we will test seven different combinations of the parameters -#' ## 'density and 'environment' under four different dispersal distances. -#' ## This design leads to 28 experiments. -#' -#' dispOptions <- 4 -#' fitOptions <- 7 -#' -#' # These are the parameters that are tested. -#' # We are testing seven combinations of the parameters 'density' and 'environment'... -#' density <- rep(c(0,seq(0,1,len = fitOptions-2),1),dispOptions) -#' environment <- rep(c(0,seq(1,0,len = fitOptions-2),1),dispOptions) -#' -#' # ... for four different dispersal ranges. -#' dispersal <- rep(c(0,0.5, 2,4), each = fitOptions) -#' -#' ## The modes and scenarios are only defined to label the plots. They have no influence on the -#' ## calculations. -#' modes <- ifelse(dispersal == 0, "global", "local") -#' scenarios <- paste(modes, " dens=", density, " env=", environment, sep = "") -#' -#' ## Now we can define a list of parameter sets. -#' pars <- list() -#' for (i in 1:length(scenarios)){pars[[i]] = createCompletePar(x = 20,y = 20, runs = 1000,scenario = scenarios[i], dispersal = dispersal[i],specRate = 2,density = density[i],environment = environment[i], fitnessBaseMortalityRatio = 5, densityCut = 1,seed = 1000)} -#' -#' ## Run the simulations -#' simulationOut <- runSimulationBatch(pars, parallel = 2) -#' -#' ## Calculate null models. For each model run 9 plot sizes are tested. In the plot they are -#' ## used to calculate the confidence interval for the results. -#' nullMeta <- calculatePhylogeneticDispersion(simulationOut, plotlengths = c(2,3,4,5,6,7,8,9,10), reduce = TRUE) -#' -#' ## Now we can define the positions and labels of the plots. -#' ## Note that here the 28 simulations need to be covered in the right order. -#' ## In this example there will be 7 rows and 4 collumns to represent the 28 cases. -#' positions <- list(x= c(1:7), -#' y = c(4, 1:3), # this is beacause dispersal = "global" is equal to dispersal = "0" -#' zname = c("neutral", "1", "0.75", "0.5", "0.25", "0", "both"), # = environment -#' yname = c("global", "0.5", "2", "4"), # = dispersal -#' xname=c("neutral", "0", "0.25", "0.5","0.75","1","both")) # = density -#' -#' ## Now you can plot the results. -#' plotPhylogeneticDispersion(pvalues = nullMeta, positions = positions, title = "Null Meta") -#' +#' @example /inst/examples/plotPhylogeneticDispersion-help.R #' @export #' plotPhylogeneticDispersion <- function(pvalues, positions=NULL, title = "P-values", which.result = NULL, xmax = 5.5, ymax = 2.5, xmin = -0.2, ymin = 0.5, means=1){ diff --git a/PhyloSim/R/plotRAC.R b/PhyloSim/R/plotRAC.R index c74074e..c746af7 100644 --- a/PhyloSim/R/plotRAC.R +++ b/PhyloSim/R/plotRAC.R @@ -6,36 +6,7 @@ #' @param title String, determining the title of the plot. #' @details Each species is given a rank according to their abundance (highest = rank 1). Then the the species' abundance is plotted in dependency of their rank. It can be used as an indicator for the ammount of equally abundant species a community can support. \cr\cr If which.result = "all" all intermediate results are shown in one plot. The colors of the lines are plotted as a gradient from blue (first results) to red (end result). #' @return A dataframe containing the ranked abundances, sorted by ascending rank. If which.result = "all" only the plot will be returned. -#' @examples -#' -#' #Load data -#' data(simu.neutral.global) -#' data(simu.neutral.local) -#' data(simu.envcom.local) -#' -#' -#' -#' #Plot RAC curve for neutral model and global dispersion -#' -#' rac(simu = simu.neutral.global) -#' rac(simu = simu.neutral.global, plot ="bar") -#' -#' -#' -#' #Plot RAC curve for neutral model and local dispersion -#' -#' rac(simu = simu.neutral.local) -#' rac(simu = simu.neutral.local, plot ="bar") -#' -#' -#' -#' #Plot RAC curve for environment and competition model and local dispersion -#' -#' rac(simu = simu.envcom.local) -#' rac(simu = simu.envcom.local, plot ="bar") -#' -#' -#' +#' @example inst/examples/plotRAC-help.R #' @export rac <- function(simu,which.result=NULL, plot="line", title="RAC"){ diff --git a/PhyloSim/R/plotSAC.R b/PhyloSim/R/plotSAC.R index efda73d..1f2affe 100644 --- a/PhyloSim/R/plotSAC.R +++ b/PhyloSim/R/plotSAC.R @@ -10,46 +10,8 @@ #' @param title String, determining the title of the plot #' @details Displays the accumulated species richness as a function of plot size or the amount of equally sized plots. It serves as an indicator for the clustering of a species community. A positively bent curve usually indicates clustering since an increase in plot size or number leads to an increase in species richness while a negatively bent curve indicates a more neutral distribution of species within the community. \cr\cr If which.result = "all" all intermediate results are shown in one plot. The colors of the lines are plotted as a gradient from blue (first results) to red (end result). #' @return A list containing the mean species richness for each size and the respective standard deviation. If which.result = "all" only the plot will be returned. -#' @examples -#' -#' #Load data -#' data(simu.neutral.global) -#' data(simu.neutral.local) -#' data(simu.envcom.local) -#' -#' -#' -#' #Plot SAC curve for neutral model and global dispersion -#' -#' sac(simu = simu.neutral.global) -#' -#' -#' -#' #Plot SAC curve for neutral model and local dispersion -#' -#' sac(simu = simu.neutral.local) -#' -#' -#' -#' #Plot SAC curve for environment and competition model and local dispersion -#' -#' sac(simu = simu.envcom.local) -#' -#' -#' -#' #Plot SAC curve with random plotsize -#' -#' sac(simu=simu.envcom.local, size = sort(sample(c(10:1000), size = 10))) -#' -#' -#' -#' #Plot SAC curve with different repititions -#' simu <- simu.envcom.local -#' par(mfrow=c(3,1)) -#' sac(simu=simu.envcom.local, rep = 3) -#' sac(simu=simu.envcom.local, rep = 30) -#' sac(simu=simu.envcom.local, rep = 30) -#' +#' @example /inst/examples/plotSAC-help.R + #' @export #' ## Modification of the SAC function to plot all recorded time steps diff --git a/PhyloSim/R/plotSpatialPhylo.R b/PhyloSim/R/plotSpatialPhylo.R index a864d5c..7e61f86 100644 --- a/PhyloSim/R/plotSpatialPhylo.R +++ b/PhyloSim/R/plotSpatialPhylo.R @@ -5,58 +5,7 @@ #' @param plotTraits logical, defines if the traits should be plotted #' @param which.result Integer, determines which result should be used. This argument is only usefull if your 'runs' argument in \code{\link{createCompletePar}} contains more than one element. By default (NULL), the last result is used. #' @details The tiplabels of the phylogeny tree are colored in correspondency to the spatial abundance plot -#' @examples -#' -#' #Load data -#' -#' data(simu.neutral.global) -#' data(simu.neutral.local) -#' data(simu.envcom.local) -#' -#' #neutral model with global dispersal -#' simu <- simu.neutral.global -#' #phylogeny and traits -#' plotSpatialPhylo(simu, plot = "phylogeny") -#' -#' #phylogeny and spatial distribution -#' plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) -#' -#' #all three -#' plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) -#' -#' -#' #neutral model with local dispersal -#' simu <- simu.neutral.local -#' #phylogeny and traits -#' plotSpatialPhylo(simu, plot = "phylogeny") -#' -#' #phylogeny and spatial distribution -#' plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) -#' -#' #all three -#' plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) -#' -#' -#' #evironment and competition model with local dispersal -#' simu <- simu.envcom.local -#' #phylogeny and traits -#' plotSpatialPhylo(simu, plot = "phylogeny") -#' -#' #phylogeny and spatial distribution -#' plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) -#' -#' #all three -#' plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) -#' -#' #Set simulation run with which.result -#' #Here, two simulation runs are stored in simu (one with 500 timesteps, one with 1000) -#' par <- createCompletePar(x = 50, y = 50, dispersal = 1, runs = c(500,1000), density = 1, environment = 0.5, specRate = 1) -#' simu <- runSimulation(par) -#' -#' #Choose to take the first simulation run (default is the last) -#' plotSpatialPhylo(simu, which.result = 1) -#' -#' +#' @example /inst/examples/plotSpatialPhylo-help.R #' @import ape #' #' @export diff --git a/PhyloSim/R/plotTraitDistribution.R b/PhyloSim/R/plotTraitDistribution.R index 83387c9..77f14c9 100644 --- a/PhyloSim/R/plotTraitDistribution.R +++ b/PhyloSim/R/plotTraitDistribution.R @@ -3,31 +3,9 @@ #' @param simu Simulation output of the class "Phylosim", usually consisting out of several lists. Needs to contain at least the three trait matrices ($traitMat;$compMat;$neutMat) and the environment matrix ($envMat) #' @param which.result Integer, determines which result should be used. This argument is only usefull if your 'runs' argument in \code{\link{createCompletePar}} contains more than one element. By default (NULL), the last result is used. #' @param type defines wether the histogram should be plotted standalone or with the trait ~ Environment relationship and the spatial distribution. Latter is done by type = "all". Default is "hist" -#' @examples +#' @example /inst/examples/plotTraitDistribution-help.R #' -#'#Load data -#'data(simu.neutral.global) -#'data(simu.neutral.local) -#'data(simu.envcom.local) -#' -#' -#' -#'#neutral model with global dispersal -#'plotTraitDistribution(simu=simu.neutral.global) -#'plotTraitDistribution(simu=simu.neutral.global, type ="all") -#' -#' -#'#neutral model with local dispersal -#'plotTraitDistribution(simu=simu.neutral.local) -#'plotTraitDistribution(simu=simu.neutral.local, type = "all") -#' -#' -#' -#'#evironment and competition model with local dispersal -#'plotTraitDistribution(simu=simu.envcom.local) -#'plotTraitDistribution(simu=simu.envcom.local, type = "all") -#' -#' + #' @export plotTraitDistribution <- function (simu, type = "hist", which.result = NULL){ diff --git a/PhyloSim/R/reconstructPhylogeny.R b/PhyloSim/R/reconstructPhylogeny.R index 1929abf..c1ee3bd 100644 --- a/PhyloSim/R/reconstructPhylogeny.R +++ b/PhyloSim/R/reconstructPhylogeny.R @@ -4,20 +4,7 @@ #' @param which.result Integer, determines which result should be used. This argument is only usefull if your 'runs' argument in \code{\link{createCompletePar}} contains more than one element. By default (NULL), the last result is used. #' @param ... Additional arguments to be passed to function \code{\link{hclust}} #' @return An object of class 'phylo' -#' @examples -#' ## Run a simulation -#' par <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, -#' density = 1, environment = 0.5, specRate = 1) -#' -#' simu <- runSimulation(par) -#' -#' ## Reconstruct phylogeny -#' rePhyl <- phyloReconstruct(simu) -#' -#' ## Compare to the real phylogeny (requires package 'ape') -#' par(mfrow=c(1,2)) -#' plot(ape::drop.fossil(simu$Output[[1]]$phylogeny)) -#' plot(rePhyl) +#' @example /inst/examples/reconstructPhylogeny-help.R #' @export #' phyloReconstruct <- function(simu, which.result = NULL, ...) diff --git a/PhyloSim/R/runSimulation.R b/PhyloSim/R/runSimulation.R index ae18c5f..64809a0 100644 --- a/PhyloSim/R/runSimulation.R +++ b/PhyloSim/R/runSimulation.R @@ -2,37 +2,13 @@ #' @description A model of species community assembly under different assembly mechanisms. #' @param par, a list of model parameters created with \link{createCompletePar} #' @return An object of class "Phylosim". This objet contains the species matrix, the trait matrix, the environmental matrix, the competition matrix and the neutral matrix, as well as the phlogeny and the parameter settings of the simulation. -#' @details If your parameterset contains more than one runs argument, each interim step is saved in the Phylosim object. \cr\cr For larger simularions consider \link{runSimulationBatch} to make use of parallel computing. \cr\cr If you are using type="Rneutral" only one runs argument can be processed.\cr\cr It is possible that more than one new species arises per generation. This leads to a multifurcated phylogeny, yet many packages such as "ape" can only work with bifurcated tree. Setting converToBinaryTree to TRUE converts the generated phylogeny to a bifurcate one using multi2di() from the "ape" package. +#' @details If your parameterset contains more than one runs argument, each interim step is saved in the Phylosim object. \cr\cr For larger simularions consider \link{runSimulationBatch} to make use of parallel computing. \cr\cr If you are using `type="Rneutral"` only one runs argument can be processed.\cr\cr It is possible that more than one new species arises per generation. This leads to a multifurcated phylogeny, yet many packages such as "ape" can only work with bifurcated tree. Setting `converToBinaryTree = TRUE` converts the generated phylogeny to a bifurcate one using `multi2di()` from the "ape" package. #' @importFrom adephylo distTips #' @import Rcpp #' @useDynLib PhyloSim, .registration = TRUE #' @export -#' @examples -#' library(PhyloSim) -#' # Define a parameter set -#' par <- createCompletePar(x = 50, y = 50, dispersal = 1 , runs = 1000, -#' density = 0, environment = 0, specRate = 1, fission = 0, redQueen=0, redQueenStrength=0, -#' protracted=0) -#' -#' # Run the model -#' simut <- runSimulation(par) -#' -#' plot(simu) -#' -#' # Look at the phylogeny (requires package 'ape') -#' require(ape) -#' -#' # Get the phylogeny of the last run. In this example this is after 1000 runs. -#' phylogeny <- simu$Output[[2]]$phylogeny -#' -#' # Only extant taxa -#' extantPhylogeny <- drop.fossil(phylogeny) -#' -#' # Display the results -#' plot(extantPhylogeny) -#' -#' #Look at the species area relation -#' sac(simu, area = c(1,10,100,1000), rep = 100, plot= TRUE) +#' @example /inst/examples/runSimulation-help.R + runSimulation <- function(par) { diff --git a/PhyloSim/R/runSimulationBatch.R b/PhyloSim/R/runSimulationBatch.R index b2d246e..7f181f4 100644 --- a/PhyloSim/R/runSimulationBatch.R +++ b/PhyloSim/R/runSimulationBatch.R @@ -7,25 +7,8 @@ #' @param strip NULL or "summaries", determining whether the whole simulation or only the summary statistics should be returned. #' @return An object of class "PhylosimList". #' @details The "PhylosimList" object is a list of "Phylosim" objects. They can be accessed by indexing (see Example).\cr\cr This function uses the \code{\link{foreach}} and \code{\link{doParallel}} package to compute the model scenarios parallel on several cores. \cr\cr The phylogeny is passed to R in the newick format and parsed to an object of class "phylo" with the function \code{\link[ape]{read.tree}} from the \code{\link{ape}} package. -#' @examples -#' ## Define two parameter sets -#' par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), -#' density = 0, environment = 0.5, specRate = 1) -#' par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), -#' density = 1, environment = 0.5, specRate = 1) -#' -#' ## Merge the parameter sets. It is important to note, that the function -#' ## needs a list of parameter sets. -#' par <- list(par1,par2) -#' -#' ## Run the model -#' simu <- runSimulationBatch(par, parallel = 2) -#' -#' -#' ## Compare the results, here the SAC is shown exemplarily. -#' par(mfrow=c(1,2)) -#' sac(simu[[1]]) -#' sac(simu[[2]]) +#' @example /inst/examples/runSimulationBatch-help.R + #' @export runSimulationBatch <- function(pars, parallel = FALSE, backup = FALSE, strip = NULL){ #start timing diff --git a/PhyloSim/R/summaryStatistics.R b/PhyloSim/R/summaryStatistics.R index 7609f6f..d3b729a 100644 --- a/PhyloSim/R/summaryStatistics.R +++ b/PhyloSim/R/summaryStatistics.R @@ -4,12 +4,7 @@ #' @param simulation Simulation output of the class "Phylosim" #' @details TODO: implement #' @return A list containing the summary statistics. -#' @examples -#' -#' simu <- runSimulation(createCompletePar(x=50, y=50, runs=1000, specRate=2)) -#' summStat <- calculateSummaryStatistics(simu) -#' -#' +#' @example /inst/examples/summaryStatistics-help.R #' @export #' diff --git a/PhyloSim/inst/examples/createPhylosimList-help.R b/PhyloSim/inst/examples/createPhylosimList-help.R new file mode 100644 index 0000000..4f3c31e --- /dev/null +++ b/PhyloSim/inst/examples/createPhylosimList-help.R @@ -0,0 +1,13 @@ +## Create two objects of type Phylosim +par1 <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, + density = 1, environment = 0.5, specRate = 1) +par2 <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, + density = 1, environment = 0.5, specRate = 2) + +simu1 <- runSimulation(par1) +simu2 <- runSimulation(par2) + +## Use the function +simuList <- createPhylosimList(list(simu1,simu2)) + +## The object can now be handed to functions designed for objects of type "PhylosimList". diff --git a/PhyloSim/inst/examples/localPlots.R b/PhyloSim/inst/examples/localPlots-help.R similarity index 100% rename from PhyloSim/inst/examples/localPlots.R rename to PhyloSim/inst/examples/localPlots-help.R diff --git a/PhyloSim/inst/examples/neutralModelR-help.R b/PhyloSim/inst/examples/neutralModelR-help.R new file mode 100644 index 0000000..1fd0027 --- /dev/null +++ b/PhyloSim/inst/examples/neutralModelR-help.R @@ -0,0 +1,14 @@ +# Run the model +metaCom <- NeutralMod(xdim=50, ydim=50, specRate=2, seed=1500, runs=500) +image(metaCom) + +# Usually the function is called by the runSimualtion function +# Define a parameter set +parNeut <- createCompletePar(x = 50, y = 50, dispersal = FALSE , runs = 500, + density = 1, environment = 0.5, specRate = 1, type="Rneutral") + +# Run the model +simuNeut <- runSimulation(parNeut) + +# Visualize the grid +image(simuNeut$Output[[1]]$specMat) diff --git a/PhyloSim/inst/examples/nullModel-help.R b/PhyloSim/inst/examples/nullModel-help.R new file mode 100644 index 0000000..43046a8 --- /dev/null +++ b/PhyloSim/inst/examples/nullModel-help.R @@ -0,0 +1,28 @@ + +### Usage with runSimulation +## Define a parameter set +par <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), density = 1, environment = 0.5, specRate = 1) + +## Run Model +simu <- runSimulation(par) + +## Compare to null model +nullModel(simu, abundance= FALSE, localPlotSize = 100, numberOfPlots = 10, repetitions = 10) + +## Usage with runSimulationBatch +## Define two (or multiple) parameter sets +par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), + density = 1, environment = 0.5, specRate = 1) +par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), + density = 2, environment = 0.5, specRate = 1) + +## Merge the parameter sets. It is important to note, that the funktion +## needs a list of parameter sets. +par <- list(par1,par2) + +## Run the model +simubatch <- runSimulationBatch(par, parallel=2) + +## Compare results to null model +nullModel(simubatch[[1]],localPlotSize = 100, numberOfPlots = 10, repetitions = 10) +nullModel(simubatch[[2]],localPlotSize = 100, numberOfPlots = 10, repetitions = 10) diff --git a/PhyloSim/inst/examples/parCreator-help.R b/PhyloSim/inst/examples/parCreator-help.R new file mode 100644 index 0000000..144d13e --- /dev/null +++ b/PhyloSim/inst/examples/parCreator-help.R @@ -0,0 +1,6 @@ +## Define a parameter set +par <- createCompletePar(x = 50, y = 50, dispersal = FALSE , runs = c(500,1000), + density = 1, environment = 0.5, specRate = 1) + +## Run the model +simu <- runSimulation(par) diff --git a/PhyloSim/inst/examples/phylogeneticDispersion-help.R b/PhyloSim/inst/examples/phylogeneticDispersion-help.R new file mode 100644 index 0000000..3361e8b --- /dev/null +++ b/PhyloSim/inst/examples/phylogeneticDispersion-help.R @@ -0,0 +1,15 @@ + +## Create a set of parameters +par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), + density = 0, environment = 0.5, specRate = 1) +par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), + density = 1, environment = 0.5, specRate = 1) + +## Merge the parameter sets. +par <- list(par1,par2) + +## Run the model +simu <- runSimulationBatch(par, parallel = 2) + +## Calculate null model and compare the observed results against +pValues <- calculatePhylogeneticDispersion(simu, plotlength=20, plots=20, replicates=20, type="PhylMeta") \ No newline at end of file diff --git a/PhyloSim/inst/examples/phylosim-help.R b/PhyloSim/inst/examples/phylosim-help.R new file mode 100644 index 0000000..d04c28e --- /dev/null +++ b/PhyloSim/inst/examples/phylosim-help.R @@ -0,0 +1,6 @@ +data(simu.envcom.local) +plotSpatialPhylo(simu.envcom.local) + +par <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = c(500,1000),density = 1, environment =0.5, specRate = 1) +new.simulation <- runSimulation(par) +plotSpatialPhylo(new.simulation) \ No newline at end of file diff --git a/PhyloSim/inst/examples/plotHighlightLocalPhylo-help.R b/PhyloSim/inst/examples/plotHighlightLocalPhylo-help.R new file mode 100644 index 0000000..d13a246 --- /dev/null +++ b/PhyloSim/inst/examples/plotHighlightLocalPhylo-help.R @@ -0,0 +1,30 @@ + +#Load data +data(simu.neutral.global) +data(simu.neutral.local) +data(simu.envcom.local) + + + +#Plot clades for neutral model with global dispersal with three subplots +par(mfrow=c(1,3)) +highlightLocalPhylo(simu.neutral.global, size = 50, n = 3) + + + +#Plot clades for neutral model with local dispersal with three subplots +par(mfrow=c(1,3)) +highlightLocalPhylo(simu.neutral.local, size = 50, n = 3) + + + +#Plot clades for environment and competition model with global dispersal with three subplots +par(mfrow=c(1,3)) +highlightLocalPhylo(simu.envcom.local, size = 50, n = 3) + + + +#increasing plot size +par(mfrow=c(2,2)) +highlightLocalPhylo(simu.envcom.local, size = 50, n =2) +highlightLocalPhylo(simu.envcom.local, size = 1000, n =2) \ No newline at end of file diff --git a/PhyloSim/inst/examples/plotPhylogeneticDispersion-help.R b/PhyloSim/inst/examples/plotPhylogeneticDispersion-help.R new file mode 100644 index 0000000..cced3a0 --- /dev/null +++ b/PhyloSim/inst/examples/plotPhylogeneticDispersion-help.R @@ -0,0 +1,44 @@ +## First the experimental design has to be defined. +## In this example we will test seven different combinations of the parameters +## 'density and 'environment' under four different dispersal distances. +## This design leads to 28 experiments. + +dispOptions <- 4 +fitOptions <- 7 + +# These are the parameters that are tested. +# We are testing seven combinations of the parameters 'density' and 'environment'... +density <- rep(c(0,seq(0,1,len = fitOptions-2),1),dispOptions) +environment <- rep(c(0,seq(1,0,len = fitOptions-2),1),dispOptions) + +# ... for four different dispersal ranges. +dispersal <- rep(c(0,0.5, 2,4), each = fitOptions) + +## The modes and scenarios are only defined to label the plots. They have no influence on the +## calculations. +modes <- ifelse(dispersal == 0, "global", "local") +scenarios <- paste(modes, " dens=", density, " env=", environment, sep = "") + +## Now we can define a list of parameter sets. +pars <- list() +for (i in 1:length(scenarios)){pars[[i]] = createCompletePar(x = 20,y = 20, runs = 1000,scenario = scenarios[i], dispersal = dispersal[i],specRate = 2,density = density[i],environment = environment[i], fitnessBaseMortalityRatio = 5, densityCut = 1,seed = 1000)} + +## Run the simulations +simulationOut <- runSimulationBatch(pars, parallel = 2) + +## Calculate null models. For each model run 9 plot sizes are tested. In the plot they are +## used to calculate the confidence interval for the results. +nullMeta <- calculatePhylogeneticDispersion(simulationOut, plotlengths = c(2,3,4,5,6,7,8,9,10), reduce = TRUE) + +## Now we can define the positions and labels of the plots. +## Note that here the 28 simulations need to be covered in the right order. +## In this example there will be 7 rows and 4 collumns to represent the 28 cases. +positions <- list(x= c(1:7), + y = c(4, 1:3), # this is beacause dispersal = "global" is equal to dispersal = "0" + zname = c("neutral", "1", "0.75", "0.5", "0.25", "0", "both"), # = environment + yname = c("global", "0.5", "2", "4"), # = dispersal + xname=c("neutral", "0", "0.25", "0.5","0.75","1","both")) # = density + +## Now you can plot the results. +plotPhylogeneticDispersion(pvalues = nullMeta, positions = positions, title = "Null Meta") + diff --git a/PhyloSim/inst/examples/plotRAC-help.R b/PhyloSim/inst/examples/plotRAC-help.R new file mode 100644 index 0000000..5e28450 --- /dev/null +++ b/PhyloSim/inst/examples/plotRAC-help.R @@ -0,0 +1,28 @@ + +#Load data +data(simu.neutral.global) +data(simu.neutral.local) +data(simu.envcom.local) + + + +#Plot RAC curve for neutral model and global dispersion + +rac(simu = simu.neutral.global) +rac(simu = simu.neutral.global, plot ="bar") + + + +#Plot RAC curve for neutral model and local dispersion + +rac(simu = simu.neutral.local) +rac(simu = simu.neutral.local, plot ="bar") + + + +#Plot RAC curve for environment and competition model and local dispersion + +rac(simu = simu.envcom.local) +rac(simu = simu.envcom.local, plot ="bar") + + diff --git a/PhyloSim/inst/examples/plotSAC-help.R b/PhyloSim/inst/examples/plotSAC-help.R new file mode 100644 index 0000000..fbddfd1 --- /dev/null +++ b/PhyloSim/inst/examples/plotSAC-help.R @@ -0,0 +1,38 @@ + +#Load data +data(simu.neutral.global) +data(simu.neutral.local) +data(simu.envcom.local) + + + +#Plot SAC curve for neutral model and global dispersion + +sac(simu = simu.neutral.global) + + + +#Plot SAC curve for neutral model and local dispersion + +sac(simu = simu.neutral.local) + + + +#Plot SAC curve for environment and competition model and local dispersion + +sac(simu = simu.envcom.local) + + + +#Plot SAC curve with random plotsize + +sac(simu=simu.envcom.local, size = sort(sample(c(10:1000), size = 10))) + + + +#Plot SAC curve with different repititions +simu <- simu.envcom.local +par(mfrow=c(3,1)) +sac(simu=simu.envcom.local, rep = 3) +sac(simu=simu.envcom.local, rep = 30) +sac(simu=simu.envcom.local, rep = 30) diff --git a/PhyloSim/inst/examples/plotSpatialPhylo-help.R b/PhyloSim/inst/examples/plotSpatialPhylo-help.R new file mode 100644 index 0000000..2204b98 --- /dev/null +++ b/PhyloSim/inst/examples/plotSpatialPhylo-help.R @@ -0,0 +1,51 @@ + +#Load data + +data(simu.neutral.global) +data(simu.neutral.local) +data(simu.envcom.local) + +#neutral model with global dispersal +simu <- simu.neutral.global + #phylogeny and traits + plotSpatialPhylo(simu, plot = "phylogeny") + + #phylogeny and spatial distribution + plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) + + #all three + plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) + + + #neutral model with local dispersal + simu <- simu.neutral.local + #phylogeny and traits + plotSpatialPhylo(simu, plot = "phylogeny") + + #phylogeny and spatial distribution + plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) + + #all three + plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) + + + #evironment and competition model with local dispersal + simu <- simu.envcom.local + #phylogeny and traits + plotSpatialPhylo(simu, plot = "phylogeny") + + #phylogeny and spatial distribution + plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) + + #all three + plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) + +#Set simulation run with which.result +#Here, two simulation runs are stored in simu (one with 500 timesteps, one with 1000) +par <- createCompletePar(x = 50, y = 50, dispersal = 1, runs = c(500,1000), density = 1, environment = 0.5, specRate = 1) +simu <- runSimulation(par) + +#Choose to take the first simulation run (default is the last) +plotSpatialPhylo(simu, which.result = 1) + + diff --git a/PhyloSim/inst/examples/plotTraitDistribution-help.R b/PhyloSim/inst/examples/plotTraitDistribution-help.R new file mode 100644 index 0000000..e207205 --- /dev/null +++ b/PhyloSim/inst/examples/plotTraitDistribution-help.R @@ -0,0 +1,22 @@ +#Load data +data(simu.neutral.global) +data(simu.neutral.local) +data(simu.envcom.local) + + + +#neutral model with global dispersal +plotTraitDistribution(simu=simu.neutral.global) +plotTraitDistribution(simu=simu.neutral.global, type ="all") + + +#neutral model with local dispersal +plotTraitDistribution(simu=simu.neutral.local) +plotTraitDistribution(simu=simu.neutral.local, type = "all") + + + +#evironment and competition model with local dispersal +plotTraitDistribution(simu=simu.envcom.local) +plotTraitDistribution(simu=simu.envcom.local, type = "all") + diff --git a/PhyloSim/inst/examples/reconstructPhylogeny-help.R b/PhyloSim/inst/examples/reconstructPhylogeny-help.R new file mode 100644 index 0000000..1a5c2f9 --- /dev/null +++ b/PhyloSim/inst/examples/reconstructPhylogeny-help.R @@ -0,0 +1,13 @@ +# Run a simulation +par <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, + density = 1, environment = 0.5, specRate = 1) + +simu <- runSimulation(par) + +## Reconstruct phylogeny +rePhyl <- phyloReconstruct(simu) + +## Compare to the real phylogeny (requires package 'ape') +par(mfrow=c(1,2)) +plot(ape::drop.fossil(simu$Output[[1]]$phylogeny)) +plot(rePhyl) \ No newline at end of file diff --git a/PhyloSim/inst/examples/runSimulation-help.R b/PhyloSim/inst/examples/runSimulation-help.R new file mode 100644 index 0000000..af66f01 --- /dev/null +++ b/PhyloSim/inst/examples/runSimulation-help.R @@ -0,0 +1,25 @@ + library(PhyloSim) +# Define a parameter set +par <- createCompletePar(x = 50, y = 50, dispersal = 1 , runs = 1000, + density = 0, environment = 0, specRate = 1, fission = 0, redQueen=0, redQueenStrength=0, + protracted=0) + +# Run the model +simut <- runSimulation(par) + +plot(simu) + +# Look at the phylogeny (requires package 'ape') +require(ape) + +# Get the phylogeny of the last run. In this example this is after 1000 runs. +phylogeny <- simu$Output[[2]]$phylogeny + +# Only extant taxa +extantPhylogeny <- drop.fossil(phylogeny) + +# Display the results +plot(extantPhylogeny) + +#Look at the species area relation +sac(simu, area = c(1,10,100,1000), rep = 100, plot= TRUE) \ No newline at end of file diff --git a/PhyloSim/inst/examples/runSimulationBatch-help.R b/PhyloSim/inst/examples/runSimulationBatch-help.R new file mode 100644 index 0000000..e269422 --- /dev/null +++ b/PhyloSim/inst/examples/runSimulationBatch-help.R @@ -0,0 +1,18 @@ +## Define two parameter sets +par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), + density = 0, environment = 0.5, specRate = 1) +par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), + density = 1, environment = 0.5, specRate = 1) + +## Merge the parameter sets. It is important to note, that the function +## needs a list of parameter sets. +par <- list(par1,par2) + +## Run the model +simu <- runSimulationBatch(par, parallel = 2) + + +## Compare the results, here the SAC is shown exemplarily. +par(mfrow=c(1,2)) +sac(simu[[1]]) +sac(simu[[2]]) \ No newline at end of file diff --git a/PhyloSim/inst/examples/summaryStatistics-help.R b/PhyloSim/inst/examples/summaryStatistics-help.R new file mode 100644 index 0000000..fc9bc4f --- /dev/null +++ b/PhyloSim/inst/examples/summaryStatistics-help.R @@ -0,0 +1,3 @@ + +simu <- runSimulation(createCompletePar(x=50, y=50, runs=1000, specRate=2)) +summStat <- calculateSummaryStatistics(simu) diff --git a/PhyloSim/man/NeutralMod.Rd b/PhyloSim/man/NeutralMod.Rd index 4151940..fe71b36 100644 --- a/PhyloSim/man/NeutralMod.Rd +++ b/PhyloSim/man/NeutralMod.Rd @@ -39,7 +39,6 @@ simuNeut <- runSimulation(parNeut) # Visualize the grid image(simuNeut$Output[[1]]$specMat) - } \references{ Hubbell, Stephen P. The unified neutral theory of biodiversity and biogeography (MPB-32). Vol. 32. Princeton University Press, 2001. diff --git a/PhyloSim/man/PhyloSim-package.Rd b/PhyloSim/man/PhyloSim.Rd similarity index 70% rename from PhyloSim/man/PhyloSim-package.Rd rename to PhyloSim/man/PhyloSim.Rd index 143fe7d..7594f0e 100644 --- a/PhyloSim/man/PhyloSim-package.Rd +++ b/PhyloSim/man/PhyloSim.Rd @@ -1,22 +1,14 @@ -\name{PhyloSim-package} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PhyloSim-package.R +\docType{package} +\name{PhyloSim} \alias{PhyloSim-package} \alias{PhyloSim} -\docType{package} -\title{ -Analysing phylogenetic and biogeographic patterns and inferring species community assembly -} +\title{Analysing phylogenetic and biogeographic patterns and inferring species community assembly} \description{ This package is designed to simulate and analyse species community assembly processes. It allows the user to implement different mechanisms of community assembly such as environmental filtering, competitive exclusion or dispersal limitation. These mechanisms can be combined or activated seprately, which allows the user to identify biogeographic or phylogenetic patterns exclusively correlated with a certain mechanism or combination of mechanisms. } \details{ -\tabular{ll}{ -Package: \tab PhyloSim\cr -Type: \tab Package\cr -Version: \tab 1.0\cr -Date: \tab 2015-02-12\cr -License: \tab GPL (>= 2)\cr -} - The core of this package is basically a community assembly model, which can be run with \code{\link{runSimulation}} or \code{\link{runSimulationBatch}}. All other functions help analize and visualize the model outcome. For visualization the following functions can be useful: \tabular{ll}{ \code{\link{plotSpatialPhylo}} \tab Plots the phylogeny tree ,the spatially abundance of the evolved species and their traits.\cr @@ -28,27 +20,15 @@ The core of this package is basically a community assembly model, which can be r The function \code{\link{phyloReconstruct}} creates a phylogeny from given neutral traits of a community in order to compare them with the existing phylogeny. The observed patterns in the simulation output can be tested against null models using the function \code{\link{nullModel}}. } +\examples{ +data(simu.envcom.local) +plotSpatialPhylo(simu.envcom.local) - - +par <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = c(500,1000),density = 1, environment =0.5, specRate = 1) +new.simulation <- runSimulation(par) +plotSpatialPhylo(new.simulation) +} \author{ Paul Bauche, Florian Hartig - -Maintainer: Florian Hartig -} -\references{ -~~ Literature or other references for background information ~~ -} - -\keyword{ package } -\seealso{ -\code{\link{../doc/PhyloSimManual.pdf}} -} -\examples{ -# data(simu.envcom.local) -# plotSpatialPhylo(simu.envcom.local) -# -# par <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = c(500,1000),density = 1, environment =0.5, specRate = 1) -# new.simulation <- runSimulation(par) -# plotSpatialPhylo(new.simulation) } +\keyword{internal} diff --git a/PhyloSim/man/calculatePhylogeneticDispersion.Rd b/PhyloSim/man/calculatePhylogeneticDispersion.Rd index 0e87084..41ddfe5 100644 --- a/PhyloSim/man/calculatePhylogeneticDispersion.Rd +++ b/PhyloSim/man/calculatePhylogeneticDispersion.Rd @@ -30,23 +30,22 @@ A list with pValues for each plot in the observed metacommunity. If you have cal Generates a null models for a list of Phylosim objects as created by \code{\link{runSimulationBatch}} and compares the observed results against. } \details{ -In the types argument "PhylMeta" is equivalent to \code{\link{nullModel}} with abundance = FALSE, "PhylSample" is equivalent to the same function with abundance = TRUE, wheras the two other option use \code{\link[picante]{ses.mpd}}. "PhylPool" uses the argument null.model = "phylogeny.pool", "SamplePool" is setting null.model to "sample.pool". \cr\cr The fun argument is only used if types="PhylSample". For more information see \code{\link{nullModel}}. \cr \cr If yu choose which.result = NULL (default), the length of the output corresponds to the length of the 'runs' argument in your parameter definition. Otherwise the length of the list corresponds to the length of your which.result argument. \cr\cr The structure of the output is organitzed as follows with output[[n]] you will get the results for the scenario 'n'. With output[[n]][[t]] you will get the results for 'n' at timestep 't'. output[[n]][[t]] is a list that contains one vector with p values for each element in the plotlengths argument. +In the types argument "PhylMeta" is equivalent to \code{\link{nullModel}} with abundance = FALSE, "PhylSample" is equivalent to the same function with abundance = TRUE, wheras the two other option use \code{\link[picante]{ses.mpd}}. "PhylPool" uses the argument null.model = "phylogeny.pool", "SamplePool" is setting null.model to "sample.pool". \cr\cr The fun argument is only used if types="PhylSample". For more information see \code{\link{nullModel}}. \cr \cr If yu choose which.result = NULL (default), the length of the output corresponds to the length of the 'runs' argument in your parameter definition. Otherwise the length of the list corresponds to the length of your which.result argument. \cr\cr The structure of the output is organitzed as follows with \code{output[[n]]} you will get the results for the scenario 'n'. With \code{output[[n]][[t]]} you will get the results for \code{n} at timestep \code{t}. \code{output[[n]][[t]]} is a list that contains one vector with p values for each element in the plotlengths argument. } \examples{ + ## Create a set of parameters par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), - density = 0, environment = 0.5, specRate = 1) + density = 0, environment = 0.5, specRate = 1) par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), density = 1, environment = 0.5, specRate = 1) -## Merge the parameter sets. +## Merge the parameter sets. par <- list(par1,par2) ## Run the model -simu <- runSimulationBatch(par, parallel = 2) +simu <- runSimulationBatch(par, parallel = 2) ## Calculate null model and compare the observed results against pValues <- calculatePhylogeneticDispersion(simu, plotlength=20, plots=20, replicates=20, type="PhylMeta") - - } diff --git a/PhyloSim/man/calculateSummaryStatistics.Rd b/PhyloSim/man/calculateSummaryStatistics.Rd index 887f662..2c03fb9 100644 --- a/PhyloSim/man/calculateSummaryStatistics.Rd +++ b/PhyloSim/man/calculateSummaryStatistics.Rd @@ -22,6 +22,4 @@ TODO: implement simu <- runSimulation(createCompletePar(x=50, y=50, runs=1000, specRate=2)) summStat <- calculateSummaryStatistics(simu) - - } diff --git a/PhyloSim/man/createCompletePar.Rd b/PhyloSim/man/createCompletePar.Rd index 999a348..422f1d6 100644 --- a/PhyloSim/man/createCompletePar.Rd +++ b/PhyloSim/man/createCompletePar.Rd @@ -9,8 +9,8 @@ createCompletePar(x = 50, y = 50, dispersal = "global", runs = 100, fitnessActsOn = "mortality", fitnessBaseMortalityRatio = 10, densityCut = 1, seed = NULL, type = "base", fission = 0, redQueen = 0, redQueenStrength = 0, protracted = 0, airmat = 1, - scenario = NULL, calculateSummaries = FALSE, convertToBinaryTree = TRUE, - prunePhylogeny = TRUE) + scenario = NULL, calculateSummaries = FALSE, + convertToBinaryTree = TRUE, prunePhylogeny = TRUE) } \arguments{ \item{x}{Integer, Dimension of the model landscape in x-direction} @@ -71,5 +71,4 @@ par <- createCompletePar(x = 50, y = 50, dispersal = FALSE , runs = c(500,1000), ## Run the model simu <- runSimulation(par) - } diff --git a/PhyloSim/man/createPhylosimList.Rd b/PhyloSim/man/createPhylosimList.Rd index 4088a63..ce323cc 100644 --- a/PhyloSim/man/createPhylosimList.Rd +++ b/PhyloSim/man/createPhylosimList.Rd @@ -24,7 +24,7 @@ par1 <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, density = 1, environment = 0.5, specRate = 1) par2 <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, density = 1, environment = 0.5, specRate = 2) - + simu1 <- runSimulation(par1) simu2 <- runSimulation(par2) @@ -32,5 +32,4 @@ simu2 <- runSimulation(par2) simuList <- createPhylosimList(list(simu1,simu2)) ## The object can now be handed to functions designed for objects of type "PhylosimList". - } diff --git a/PhyloSim/man/highlightLocalPhylo.Rd b/PhyloSim/man/highlightLocalPhylo.Rd index edc46f4..50c32d4 100644 --- a/PhyloSim/man/highlightLocalPhylo.Rd +++ b/PhyloSim/man/highlightLocalPhylo.Rd @@ -27,32 +27,31 @@ Visualises the phylogenetic clades of a local community within a metacommunity. This function works with a single simu object (class "phylosim"). If no simu object is given, it is also possible to calculate the clades from a given phylogeny and localc plots. Here the phylogeny represents the metacommunity wihtin which the local plots create the clades } \examples{ - #Load data data(simu.neutral.global) data(simu.neutral.local) data(simu.envcom.local) - + #Plot clades for neutral model with global dispersal with three subplots par(mfrow=c(1,3)) -highlightLocalPhylo(simu.neutral.global, size = 50, n = 3) +highlightLocalPhylo(simu.neutral.global, size = 50, n = 3) + - #Plot clades for neutral model with local dispersal with three subplots par(mfrow=c(1,3)) -highlightLocalPhylo(simu.neutral.local, size = 50, n = 3) +highlightLocalPhylo(simu.neutral.local, size = 50, n = 3) + - #Plot clades for environment and competition model with global dispersal with three subplots par(mfrow=c(1,3)) -highlightLocalPhylo(simu.envcom.local, size = 50, n = 3) +highlightLocalPhylo(simu.envcom.local, size = 50, n = 3) + - #increasing plot size par(mfrow=c(2,2)) diff --git a/PhyloSim/man/nullModel.Rd b/PhyloSim/man/nullModel.Rd index 3b68c01..cdab7ff 100644 --- a/PhyloSim/man/nullModel.Rd +++ b/PhyloSim/man/nullModel.Rd @@ -43,7 +43,7 @@ nullModel(simu, abundance= FALSE, localPlotSize = 100, numberOfPlots = 10, repet ## Usage with runSimulationBatch ## Define two (or multiple) parameter sets par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), - density = 1, environment = 0.5, specRate = 1) + density = 1, environment = 0.5, specRate = 1) par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), density = 2, environment = 0.5, specRate = 1) @@ -52,10 +52,9 @@ par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), par <- list(par1,par2) ## Run the model -simubatch <- runSimulationBatch(par, parallel=2) +simubatch <- runSimulationBatch(par, parallel=2) ## Compare results to null model nullModel(simubatch[[1]],localPlotSize = 100, numberOfPlots = 10, repetitions = 10) nullModel(simubatch[[2]],localPlotSize = 100, numberOfPlots = 10, repetitions = 10) - } diff --git a/PhyloSim/man/phyloReconstruct.Rd b/PhyloSim/man/phyloReconstruct.Rd index b483805..fb76462 100644 --- a/PhyloSim/man/phyloReconstruct.Rd +++ b/PhyloSim/man/phyloReconstruct.Rd @@ -20,8 +20,7 @@ An object of class 'phylo' reconstructs a phylogeny from a neutral trait matrix as returned by \code{\link{runSimulation}} } \examples{ - -## Run a simulation +# Run a simulation par <- createCompletePar(x = 50, y = 50, dispersal = "global" , runs = 500, density = 1, environment = 0.5, specRate = 1) diff --git a/PhyloSim/man/plotPhylogeneticDispersion.Rd b/PhyloSim/man/plotPhylogeneticDispersion.Rd index 8f9be79..516aa68 100644 --- a/PhyloSim/man/plotPhylogeneticDispersion.Rd +++ b/PhyloSim/man/plotPhylogeneticDispersion.Rd @@ -38,11 +38,11 @@ In every subplot the x-axis represents the size of the subplots used in the null ## In this example we will test seven different combinations of the parameters ## 'density and 'environment' under four different dispersal distances. ## This design leads to 28 experiments. - + dispOptions <- 4 fitOptions <- 7 -# These are the parameters that are tested. +# These are the parameters that are tested. # We are testing seven combinations of the parameters 'density' and 'environment'... density <- rep(c(0,seq(0,1,len = fitOptions-2),1),dispOptions) environment <- rep(c(0,seq(1,0,len = fitOptions-2),1),dispOptions) @@ -50,7 +50,7 @@ environment <- rep(c(0,seq(1,0,len = fitOptions-2),1),dispOptions) # ... for four different dispersal ranges. dispersal <- rep(c(0,0.5, 2,4), each = fitOptions) -## The modes and scenarios are only defined to label the plots. They have no influence on the +## The modes and scenarios are only defined to label the plots. They have no influence on the ## calculations. modes <- ifelse(dispersal == 0, "global", "local") scenarios <- paste(modes, " dens=", density, " env=", environment, sep = "") @@ -62,12 +62,12 @@ for (i in 1:length(scenarios)){pars[[i]] = createCompletePar(x = 20,y = 20, runs ## Run the simulations simulationOut <- runSimulationBatch(pars, parallel = 2) -## Calculate null models. For each model run 9 plot sizes are tested. In the plot they are +## Calculate null models. For each model run 9 plot sizes are tested. In the plot they are ## used to calculate the confidence interval for the results. nullMeta <- calculatePhylogeneticDispersion(simulationOut, plotlengths = c(2,3,4,5,6,7,8,9,10), reduce = TRUE) ## Now we can define the positions and labels of the plots. -## Note that here the 28 simulations need to be covered in the right order. +## Note that here the 28 simulations need to be covered in the right order. ## In this example there will be 7 rows and 4 collumns to represent the 28 cases. positions <- list(x= c(1:7), y = c(4, 1:3), # this is beacause dispersal = "global" is equal to dispersal = "0" diff --git a/PhyloSim/man/plotSpatialPhylo.Rd b/PhyloSim/man/plotSpatialPhylo.Rd index 97b280a..632c54d 100644 --- a/PhyloSim/man/plotSpatialPhylo.Rd +++ b/PhyloSim/man/plotSpatialPhylo.Rd @@ -4,7 +4,8 @@ \alias{plotSpatialPhylo} \title{Phylogeny And Spatial Abundance Plot} \usage{ -plotSpatialPhylo(simu, plot = "both", plotTraits = T, which.result = NULL) +plotSpatialPhylo(simu, plot = "both", plotTraits = T, + which.result = NULL) } \arguments{ \item{simu}{Simulation output of the class "Phylosim", usually consisting out of several lists. Needs to contain at least the spatial species matrix ($specMat) and the phylogeny ($phylogeny)} @@ -32,35 +33,35 @@ data(simu.envcom.local) #neutral model with global dispersal simu <- simu.neutral.global #phylogeny and traits - plotSpatialPhylo(simu, plot = "phylogeny") + plotSpatialPhylo(simu, plot = "phylogeny") #phylogeny and spatial distribution plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) - + #all three plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) - + #neutral model with local dispersal simu <- simu.neutral.local #phylogeny and traits - plotSpatialPhylo(simu, plot = "phylogeny") + plotSpatialPhylo(simu, plot = "phylogeny") #phylogeny and spatial distribution plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) - + #all three plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) - + #evironment and competition model with local dispersal simu <- simu.envcom.local #phylogeny and traits - plotSpatialPhylo(simu, plot = "phylogeny") + plotSpatialPhylo(simu, plot = "phylogeny") #phylogeny and spatial distribution plotSpatialPhylo(simu, plot = "both", plotTraits = FALSE) - + #all three plotSpatialPhylo(simu, plot = "both", plotTraits = TRUE) diff --git a/PhyloSim/man/plotTraitDistribution.Rd b/PhyloSim/man/plotTraitDistribution.Rd index 620268c..a432275 100644 --- a/PhyloSim/man/plotTraitDistribution.Rd +++ b/PhyloSim/man/plotTraitDistribution.Rd @@ -17,28 +17,26 @@ plotTraitDistribution(simu, type = "hist", which.result = NULL) Plots trait-histograms, trait ~ Environment relationship and the spatial distribution of the different traits } \examples{ - -#Load data +#Load data data(simu.neutral.global) data(simu.neutral.local) data(simu.envcom.local) - - + + #neutral model with global dispersal plotTraitDistribution(simu=simu.neutral.global) plotTraitDistribution(simu=simu.neutral.global, type ="all") - - + + #neutral model with local dispersal plotTraitDistribution(simu=simu.neutral.local) plotTraitDistribution(simu=simu.neutral.local, type = "all") - - + + #evironment and competition model with local dispersal plotTraitDistribution(simu=simu.envcom.local) plotTraitDistribution(simu=simu.envcom.local, type = "all") - } diff --git a/PhyloSim/man/rac.Rd b/PhyloSim/man/rac.Rd index 4cfdc99..ee6986e 100644 --- a/PhyloSim/man/rac.Rd +++ b/PhyloSim/man/rac.Rd @@ -31,27 +31,26 @@ data(simu.neutral.global) data(simu.neutral.local) data(simu.envcom.local) - + #Plot RAC curve for neutral model and global dispersion rac(simu = simu.neutral.global) rac(simu = simu.neutral.global, plot ="bar") - + #Plot RAC curve for neutral model and local dispersion rac(simu = simu.neutral.local) rac(simu = simu.neutral.local, plot ="bar") - + #Plot RAC curve for environment and competition model and local dispersion rac(simu = simu.envcom.local) rac(simu = simu.envcom.local, plot ="bar") - } diff --git a/PhyloSim/man/runSimulation.Rd b/PhyloSim/man/runSimulation.Rd index 22406f1..75c9906 100644 --- a/PhyloSim/man/runSimulation.Rd +++ b/PhyloSim/man/runSimulation.Rd @@ -16,7 +16,7 @@ An object of class "Phylosim". This objet contains the species matrix, the trait A model of species community assembly under different assembly mechanisms. } \details{ -If your parameterset contains more than one runs argument, each interim step is saved in the Phylosim object. \cr\cr For larger simularions consider \link{runSimulationBatch} to make use of parallel computing. \cr\cr If you are using type="Rneutral" only one runs argument can be processed.\cr\cr It is possible that more than one new species arises per generation. This leads to a multifurcated phylogeny, yet many packages such as "ape" can only work with bifurcated tree. Setting converToBinaryTree to TRUE converts the generated phylogeny to a bifurcate one using multi2di() from the "ape" package. +If your parameterset contains more than one runs argument, each interim step is saved in the Phylosim object. \cr\cr For larger simularions consider \link{runSimulationBatch} to make use of parallel computing. \cr\cr If you are using \code{type="Rneutral"} only one runs argument can be processed.\cr\cr It is possible that more than one new species arises per generation. This leads to a multifurcated phylogeny, yet many packages such as "ape" can only work with bifurcated tree. Setting \code{converToBinaryTree = TRUE} converts the generated phylogeny to a bifurcate one using \code{multi2di()} from the "ape" package. } \examples{ library(PhyloSim) @@ -32,16 +32,16 @@ plot(simu) # Look at the phylogeny (requires package 'ape') require(ape) - + # Get the phylogeny of the last run. In this example this is after 1000 runs. phylogeny <- simu$Output[[2]]$phylogeny - + # Only extant taxa extantPhylogeny <- drop.fossil(phylogeny) - -# Display the results + +# Display the results plot(extantPhylogeny) - + #Look at the species area relation sac(simu, area = c(1,10,100,1000), rep = 100, plot= TRUE) } diff --git a/PhyloSim/man/runSimulationBatch.Rd b/PhyloSim/man/runSimulationBatch.Rd index de483a0..b5ff089 100644 --- a/PhyloSim/man/runSimulationBatch.Rd +++ b/PhyloSim/man/runSimulationBatch.Rd @@ -27,7 +27,7 @@ The "PhylosimList" object is a list of "Phylosim" objects. They can be accessed \examples{ ## Define two parameter sets par1 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), - density = 0, environment = 0.5, specRate = 1) + density = 0, environment = 0.5, specRate = 1) par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), density = 1, environment = 0.5, specRate = 1) @@ -36,7 +36,7 @@ par2 <- createCompletePar(x = 50, y = 50, dispersal = 0 , runs = c(500,1000), par <- list(par1,par2) ## Run the model -simu <- runSimulationBatch(par, parallel = 2) +simu <- runSimulationBatch(par, parallel = 2) ## Compare the results, here the SAC is shown exemplarily. diff --git a/PhyloSim/man/sac.Rd b/PhyloSim/man/sac.Rd index c985491..c7f6ae9 100644 --- a/PhyloSim/man/sac.Rd +++ b/PhyloSim/man/sac.Rd @@ -39,36 +39,35 @@ data(simu.neutral.local) data(simu.envcom.local) - + #Plot SAC curve for neutral model and global dispersion sac(simu = simu.neutral.global) - - + + #Plot SAC curve for neutral model and local dispersion sac(simu = simu.neutral.local) - - + + #Plot SAC curve for environment and competition model and local dispersion sac(simu = simu.envcom.local) - - -#Plot SAC curve with random plotsize + + +#Plot SAC curve with random plotsize sac(simu=simu.envcom.local, size = sort(sample(c(10:1000), size = 10))) - - + + #Plot SAC curve with different repititions simu <- simu.envcom.local par(mfrow=c(3,1)) sac(simu=simu.envcom.local, rep = 3) sac(simu=simu.envcom.local, rep = 30) sac(simu=simu.envcom.local, rep = 30) - } diff --git a/PhyloSim/man/simu.envcom.local.Rd b/PhyloSim/man/simu.envcom.local.Rd index fd67ef8..efb65a2 100644 --- a/PhyloSim/man/simu.envcom.local.Rd +++ b/PhyloSim/man/simu.envcom.local.Rd @@ -3,15 +3,17 @@ \name{simu.envcom.local} \alias{simu.envcom.local} \title{Simulation output of community assembly with local dispersion under the influence of environment and competition} -\format{A list containing two lists: The model output and the model input. The model output is described here +\format{ +A list containing two lists: The model output and the model input. The model output is described here \describe{ - \item{specMat}{species matrix, a matrix representing the species abundance} - \item{traitMat}{trait matrix, a matrix containing the environmental trait for each species (corresponding to the species matrix)} - \item{envMat}{environment matrix, contains the environmental conditions for each cell} - \item{compMat}{competition matrix, contains the competition attribute for each cell} - \item{neutMat}{neutral matrix, contains the neutral traits} - \item{phylogeny}{phylogeny of the community stored in a list} - }} +\item{specMat}{species matrix, a matrix representing the species abundance} +\item{traitMat}{trait matrix, a matrix containing the environmental trait for each species (corresponding to the species matrix)} +\item{envMat}{environment matrix, contains the environmental conditions for each cell} +\item{compMat}{competition matrix, contains the competition attribute for each cell} +\item{neutMat}{neutral matrix, contains the neutral traits} +\item{phylogeny}{phylogeny of the community stored in a list} +} +} \source{ created with \code{\link{runSimulation}} } diff --git a/PhyloSim/man/simu.neutral.global.Rd b/PhyloSim/man/simu.neutral.global.Rd index a81ee2a..43c7cf2 100644 --- a/PhyloSim/man/simu.neutral.global.Rd +++ b/PhyloSim/man/simu.neutral.global.Rd @@ -3,15 +3,17 @@ \name{simu.neutral.global} \alias{simu.neutral.global} \title{Simulation output of community assembly with global dispersion under neutral conditions} -\format{A list containing two lists: The model output and the model input. The model output is described here +\format{ +A list containing two lists: The model output and the model input. The model output is described here \describe{ - \item{specMat}{species matrix, a matrix representing the species abundance} - \item{traitMat}{trait matrix, a matrix containing the environmental trait for each species (corresponding to the species matrix)} - \item{envMat}{environment matrix, contains the environmental conditions for each cell} - \item{compMat}{competition matrix, contains the competition attribute for each cell} - \item{neutMat}{neutral matrix, contains the neutral traits} - \item{phylogeny}{phylogeny of the community stored in a list} - }} +\item{specMat}{species matrix, a matrix representing the species abundance} +\item{traitMat}{trait matrix, a matrix containing the environmental trait for each species (corresponding to the species matrix)} +\item{envMat}{environment matrix, contains the environmental conditions for each cell} +\item{compMat}{competition matrix, contains the competition attribute for each cell} +\item{neutMat}{neutral matrix, contains the neutral traits} +\item{phylogeny}{phylogeny of the community stored in a list} +} +} \source{ created with \code{\link{runSimulation}} } diff --git a/PhyloSim/man/simu.neutral.local.Rd b/PhyloSim/man/simu.neutral.local.Rd index e601cb6..5bd1f5b 100644 --- a/PhyloSim/man/simu.neutral.local.Rd +++ b/PhyloSim/man/simu.neutral.local.Rd @@ -3,15 +3,17 @@ \name{simu.neutral.local} \alias{simu.neutral.local} \title{Simulation output of community assembly with local dispersion under neutral conditions} -\format{A list containing two lists: The model output and the model input. The model output is described here +\format{ +A list containing two lists: The model output and the model input. The model output is described here \describe{ - \item{specMat}{species matrix, a matrix representing the species abundance} - \item{traitMat}{trait matrix, a matrix containing the environmental trait for each species (corresponding to the species matrix)} - \item{envMat}{environment matrix, contains the environmental conditions for each cell} - \item{compMat}{competition matrix, contains the competition attribute for each cell} - \item{neutMat}{neutral matrix, contains the neutral traits} - \item{phylogeny}{phylogeny of the community stored in a list} - }} +\item{specMat}{species matrix, a matrix representing the species abundance} +\item{traitMat}{trait matrix, a matrix containing the environmental trait for each species (corresponding to the species matrix)} +\item{envMat}{environment matrix, contains the environmental conditions for each cell} +\item{compMat}{competition matrix, contains the competition attribute for each cell} +\item{neutMat}{neutral matrix, contains the neutral traits} +\item{phylogeny}{phylogeny of the community stored in a list} +} +} \source{ created with \code{\link{runSimulation}} } diff --git a/phylosim.Rproj b/phylosim.Rproj new file mode 100644 index 0000000..b31d927 --- /dev/null +++ b/phylosim.Rproj @@ -0,0 +1,19 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackagePath: /Users/florian/Dropbox/Home/Projekte/Papers_in_Progress/17-PhylogeneticRpackage/phylosim/PhyloSim +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace