## load 'rmetasim' library library(rmetasim) ## create skeleton landscape where toadland <- landscape.new.empty() toadland <- landscape.new.intparam(toadland, h=1, #one population s=8, #four female (1 through 4) and four male (5 through 8) classes cg=0, ce=0, totgen=100, maxland=500000) #toads don't self toadland <- landscape.new.floatparam(toadland, s=0.0) toadland <- landscape.new.switchparam(toadland, re=0, rd=0, mp=0) #the following survival matrix is slight modification from the #figure supplied with this file. The survivorship of eggs to juveniles #has been increased for both females and males. localsurvival <- matrix( c( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.3 ), ncol=8, nrow=8, byrow=TRUE) #each adult female produces an average of 10 males and 10 females localreproduction <- matrix( c( 0.0, 0.0, 0.0, 10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ), ncol=8, nrow=8, byrow=TRUE) #only adult males (class 8) contribute sperm to adult females (class 4) localmalecontrib <- matrix( c( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ), ncol=8, nrow=8, byrow=TRUE) toadland <- landscape.new.local.demo(toadland, localsurvival, localreproduction, localmalecontrib) #these matrices specify inter-population movement (only one pop, so they #are the same dimension as the local matrices) #if there are multiple habitats, these matrices will get big fast. There are #some convenience functions to create them for island models migsurvival<- matrix( c( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ), ncol=8, nrow=8, byrow=TRUE) migreproduction <- matrix( c( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ), ncol=8, nrow=8, byrow=TRUE) migmalecontrib <- matrix( c( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ), ncol=8, nrow=8, byrow=TRUE) toadland <- landscape.new.epoch(toadland, S=migsurvival, R=migreproduction, M=migmalecontrib, epochprob=1, startgen=0, extinct=NULL, carry=c(10000), localprob=NULL) #this call could be repeated to increase the number of loci toadland <- landscape.new.locus(toadland, type=2, ploidy=2, mutationrate=0.000001, transmission=0, numalleles=2, allelesize=20, frequencies=NULL) toadland <- landscape.new.locus(toadland, type=2, ploidy=2, mutationrate=0.000001, transmission=0, numalleles=2, allelesize=20, frequencies=NULL) #start out with 100 individuals in each class toadland <- landscape.new.individuals(toadland, c(100,100,100,100,100,100,100,100)) ## quick look at current input toadland table(toadland$individuals[,1]) #how many in each class? ## simulate data...for several time-clicks toadland <- landscape.simulate(toadland, 40) ## quick look after sim ## this demography will crash rapidly: either the reproduction ## or survival needs to be boosted for the population to persist ##also note that the individual's classes in the landscape object go from ##0 to 7 rather than 1->8. This is an artifact of C++ indexing table(toadland$individuals[,1]) #how many in each class?