csim2pam: Converts community simulation to a Presence Absence Matrix (PAM)
Source:R/csim2pam.R
csim2pam.Rd
Converts community simulation object into a Presence Absence Matrices (PAM) for a given simulation steps.
Arguments
- community_sim
An object of class
community_bam
.- which_steps
Steps in the simulation object to be converted into a PAM
Value
An object of class pam
; it contains five slots.
1) pams: a list of sparse matrices with Presence-Absence information (PAMs).
2) which_steps: time steps corresponding to each PAM. 3) sp_names: a
vector of species names. 4) the grid area used in the simulation. 5) Non NA
cell (pixel) IDs.
Details
For details about the object community_sim see
community_sim
References
Soberón J, Osorio-Olvera L (2023). “A dynamic theory of the area of distribution.” Journal of Biogeography6, 50, 1037-1048. doi:10.1111/jbi.14587 , https://onlinelibrary.wiley.com/doi/abs/10.1111/jbi.14587. .
Examples
# \donttest{
lagos_path <- system.file("extdata/conejos",
package = "bamm")
enm_path <- list.files(lagos_path,
pattern = ".tif",
full.names = TRUE)[seq(1,10)]
en_models <- raster::stack(enm_path)
ngbs_vect <- sample(1:2,replace = TRUE,
size = raster::nlayers(en_models))
init_coords <- read.csv(file.path(lagos_path,
"lagos_initit.csv"))[seq(1,10),]
nsteps <- 10
sdm_comm <- bamm::community_sim(en_models = en_models,
ngbs_vect = ngbs_vect,
init_coords = init_coords,
nsteps = nsteps,
threshold = 0.1)
#>
|
| | 0%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|======= | 10%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|============== | 20%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|===================== | 30%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|============================ | 40%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|=================================== | 50%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|========================================== | 60%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|================================================= | 70%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|======================================================== | 80%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|=============================================================== | 90%
|
| | 0%
|
|====== | 9%
|
|============= | 18%
|
|=================== | 27%
|
|========================= | 36%
|
|================================ | 45%
|
|====================================== | 55%
|
|============================================= | 64%
|
|=================================================== | 73%
|
|========================================================= | 82%
|
|================================================================ | 91%
|
|======================================================================| 100%
|
|======================================================================| 100%
pamt10 <- bamm::csim2pam(community_sim = sdm_comm ,
which_steps = 10)
pams <- bamm::csim2pam(community_sim = sdm_comm ,
which_steps = seq_len(10))
rich_pam <- bamm::pam2richness(pams,which_steps = c(1,5))
#>
|
| | 0%
|
|=================================== | 50%
|
|======================================================================| 100%
print(rich_pam)
#> class : RasterStack
#> dimensions : 75, 112, 8400, 2 (nrow, ncol, ncell, nlayers)
#> resolution : 1, 1 (x, y)
#> extent : -168.1667, -56.16667, 8.166667, 83.16667 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#> names : time_step_1, time_step_5
#> min values : 0, 0
#> max values : 1, 3
#>
# }