GENPRES/PRESENCE in a batch file
For example, I could enter the following into a text file named 'script1.sh':
!#/usr/bin/sh # script1.sh wine genpres4 4 100 .75 .5 .5 .5 .5
This runs genpres with 4 surveys, 100 sites, psi=.75, p(1)=.5, p(2)=.5, p(3)=.5, p(4)=.5.
In a terminal window, I could then run the textfile by typing, 'script1.sh' or 'sh script1.sh'.
This example isn't very useful as it only runs genpres once and does nothing with the output. If I wanted to run genpres with different values of detection probabilities, my script file could be (script2.sh):
!#/usr/bin/sh # script2.sh wine genpres4 4 100 .75 .1 .1 .1 .1 mv genpres.pao genpres1.pao wine genpres4 4 100 .75 .2 .2 .2 .2 mv genpres.pao genpres2.pao wine genpres4 4 100 .75 .3 .3 .3 .3 mv genpres.pao genpres3.pao wine genpres4 4 100 .75 .4 .4 .4 .4 mv genpres.pao genpres4.pao wine genpres4 4 100 .75 .5 .5 .5 .5 mv genpres.pao genpres5.pao wine genpres4 4 100 .75 .6 .6 .6 .6 mv genpres.pao genpres6.pao wine genpres4 4 100 .75 .7 .7 .7 .7 mv genpres.pao genpres7.pao wine genpres4 4 100 .75 .8 .8 .8 .8 mv genpres.pao genpres8.pao wine genpres4 4 100 .75 .9 .9 .9 .9 mv genpres.pao genpres9.pao
This would run genpres with 9 different values of detection probability (from 0.1 to 0.9) and rename the default output files with different names. Of course, it would be easier to do this in a loop as in (script3.sh):
!#/usr/bin/sh # script3.sh for i in 1 2 3 4 5 6 7 8 9; do wine genpres4 4 100 .75 .$i .$i .$i .$i mv genpres.pao genpres$i.pao end
You probably want to run PRESENCE on each of the files created by GENPRES. This script will do it (script4.sh):
!#/usr/bin/sh # script4.sh for i in 1 2 3 4 5 6 7 8 9; do wine genpres4 4 100 .75 .$i .$i .$i .$i mv genpres.pao genpres$i.pao wine presence.exe i=genpres$i.pao l=presence$i.out model=1c end
The arguments to presence.exe are: i=inputfile, l=outputfile, model=xx, where xx=
wine genpres4 4 100 .75 .5 .5 .5 .5 0 .1 0 0 .2 0 SRVYPERSEASN=2
Since we have 4 surveys, there are 4 detection probabilities, but only 3 colonization probabilities and 3 extinction probabilities. This is because colonization and extinction only occur between surveys and there are 3 intervals between the 4 surveys. I specified '0 .1 0' for the 3 colonization rates, meaning there is no colonization in the 1st interval (between surveys 1 and 2) and no colonization in the 3rd interval (between surveys 3 and 4). However, there is colonization in interval 2 (between surveys 2 and 3). The same applies to extinction as I specified '0 .2 0'. This is how to create multi-season data. Specify zero for colonization and extinction for intervals which are between surveys in the same season and non-zero values for intervals between seasons. So, we have 4 surveys, with 2 seasons of 2 surveys each. (Surveys 1 and 2 are in season 1, and surveys 3 and 4 are in season 2.)
To run PRESENCE with multi-season data, you will need to create a design-matrix file since there are no pre-defined models for multi-season models. The design-matrix file is a simple text file containing 6 tables. Each table is preceeded by a line containing the table number, number of rows in the table, and number of columns. These tables are just the design-matrix tables you see when you run the interactive PRESENCE program. Here is a design matrix file for a multi-season model (mod1.dm):
0 2 2 -,a1 psi,11 2 2 -,b1 gam1,12 2 2 -,c1 eps1,13 5 2 -,d1 p(1_1),1 p(1_2),1 p(2_1),1 p(2_2),1 4 0 0 5 0 0
Note that there is a line containing the column labels, and each row contains the
parameter label as the 1st entry in the line. So, the row and column count preceeding
each table includes these labels. Also, only 1 row per interval between seasons is
needed for colonization and extinction in the design-matrix.
The first table (
!#/usr/bin/sh # script5.sh for i in 1 2 3 4 5 6 7 8 9; do wine genpres4 4 100 .75 .$i .$i .$i .$i 0 .1 0 0 .2 0 mv genpres.pao genpres$i.pao wine presence.exe i=genpres$i.pao l=presence$i.out j=mod1.dm model=200 end
Note that I added the argument 'j=mod1.dm' to specify the design-matrix file and changed the model to 'model=200' to specify a multi-season model. My preference is to incorporate the design matrix into the script, like this (script6.sh):
!#/usr/bin/sh # script6.sh echo '0 2 2' > tmp.dm echo '-,a1' >> tmp.dm echo 'psi,1' >> tmp.dm echo '1 2 2' >> tmp.dm echo '-,b1' >> tmp.dm echo 'gam1,1' >> tmp.dm echo '2 2 2' >> tmp.dm echo '-,c1' >> tmp.dm echo 'eps1,1' >> tmp.dm echo '3 5 2' >> tmp.dm echo '-,d1' >> tmp.dm echo 'p(1_1),1' >> tmp.dm echo 'p(1_2),1' >> tmp.dm echo 'p(2_1),1' >> tmp.dm echo 'p(2_2),1' >> tmp.dm echo '4 0 0' >> tmp.dm echo '5 0 0' >> tmp.dm for i in 9; do echo $i wine genpres4.exe 4 100 .75 .$i .$i .$i .$i 0 .1 0 0 .2 0 SRVYPERSEASN=2 mv genpres.pao genpres$i.pao wine presence.exe i=genpres$i.pao j=tmp.dm model=200 l=presence$i.out done
We now should have 9 PRESENCE output files, and we could extract whatever we desire using the 'grep' command:
grep '^psi.+1 site_1' presence.out