ENMTools in R- enmtools.species objects

1,124 views
Skip to first unread message

Tesa M

unread,
Feb 1, 2018, 8:18:29 PM2/1/18
to Maxent
Hello everyone,

I am wanting to create a few enmtools.species objects in ENMtools for creating an enmtools.clade object for subsequent age-range correlation... Can you use the .asc output of a Maxent (GUI) model to create enmtools.species objects?

Thanks in advance.

Dan Warren

unread,
Feb 2, 2018, 3:52:46 AM2/2/18
to Maxent
For what part of the species object are you interested in using the Maxent model?  A species object typically contains some combination of presence points, a species name, background points, and a range raster (which can also be thought of as the study area for modeling).  If you're using Maxent models in an age-overlap correlation test to calculate niche overlap, typically ENMTools would use those species objects to create the models.

However, I am about halfway through the process of setting that function up to just take a mostly-empty clade object and an externally-calculated overlap matrix.  Once that's ready you can create a set of enmtools.species objects that only contain a species name, then pack those into an enmtools.clade object with your tree, and throw that into the enmtools.aoc function with your overlap matrix.  Would that work for you?

basically you'd just create some overlap matrix "my.matrix" however you want, and then do:

species1 <- enmtools.species(species.name = "species1")
species2 <- enmtools.species(species.name = "species2")
species3 <- enmtools.species(species.name = "species3")
species4 <- enmtools.speces(species.name = "species4")

and then:

my.tree <- load.tree(whatever you need to load your tree)
my.clade <- enmtools.clade(tree = my.tree, species = list(species1 = species1, species2 = species2, species3 = species 3, species4 = species4)

and finally:

my.aoc <- enmtools.aoc(my.clade, nreps = 100, overlap.source = "matrix", overlap.matrix = my.matrix)

So you don't need anything except the species names, the tree, and an overlap matrix.  Would that do what you want?


Tesa M

unread,
Feb 2, 2018, 12:03:54 PM2/2/18
to Maxent
Hello Dan,

First, I greatly appreciate your response! I am a newbie grad student, and it's such a relief to get some help- especially from the developer.

Essentially, I made 3 Maxent models using the GUI interface before finding the ENMtools package that creates the models for use in downstream analyses. So, I was trying to figure out how to use the .asc output to create the enmtools.clade objects instead of the enmtools models just to save time- but it sounds like maybe I should just go ahead and do the models in enmtools to make it easier.

Alternatively, if I were to use your suggestion for an externally-calculated overlap matrix using the Maxent models, how could I go about creating such an overlap matrix with the .asc rasters?

I do apologize for the elementary nature of my questions.

Many thanks,

Tesa

Tesa M

unread,
Feb 4, 2018, 5:31:03 PM2/4/18
to Maxent
Hello Dan and/or other members,

To the above question, I went ahead and tried creating an enmtools.clade just using present and background points, and then trying the age-overlap test using the overlap.source as "points". The red flag is that my p-value is zero. Anyone have any ideas?

Thanks in advance.


#creating an enmtools.species object
Kalmia_buxifolia <- enmtools.species()
Kalmia_buxifolia$species.name <- "Kalmia_buxifolia"
Kalmia_buxifolia$presence.points <- Kbux_thin[,2:3]
Kalmia_buxifolia$range <- background.raster.buffer(Kalmia_buxifolia$presence.points, 50000, mask = env)
Kalmia_buxifolia$background.points <- background.points.buffer(points = Kalmia_buxifolia$presence.points,
                                                   radius = 20000, n = 1000, mask = env[[1]])
kalmia_clade <- enmtools.clade(species = list(Kalmia_buxifolia, Kalmia_latifolia, Kalmia_angustifolia), tree = tree)
check.clade(kalmia_clade)
#make sure it worked

###age-overlap correlation
points.aoc <- enmtools.aoc(clade = kalmia_clade,  nreps = 50, overlap.source = "points")
summary(range.aoc)                                    
## Age-Overlap Correlation test
#
##50 replicates 
#
##p values:
#  (Intercept)         age 
#0.0000000   0.5882353    

Dan Warren

unread,
Feb 5, 2018, 4:12:00 AM2/5/18
to Maxent
Yeah, that shouldn't be happening.  What do you see when you look at the "coefficients" entry in your enmtools.aoc object?

Tesa Madsen-McQueen

unread,
Feb 5, 2018, 8:58:31 AM2/5/18
to max...@googlegroups.com
Hi Dan,

This is what's there; though the numbers look pretty funky to me. I've attached my script in case I am doing something drastically wrong.

points.aoc$coefficients
          (Intercept)        age
empirical   0.8034129 -30.377964
rep 1      -0.3198782  26.059372
rep 2       0.1128358   4.318592
rep 3      -0.3198782  26.059372
rep 4       0.8034129 -30.377964
rep 5       0.8034129 -30.377964
rep 6      -0.3198782  26.059372
rep 7       0.8034129 -30.377964
rep 8       0.1128358   4.318592
rep 9       0.8034129 -30.377964
rep 10     -0.3198782  26.059372
rep 11      0.1128358   4.318592
rep 12      0.1128358   4.318592
rep 13      0.1128358   4.318592
rep 14     -0.3198782  26.059372
rep 15      0.1128358   4.318592
rep 16      0.1128358   4.318592
rep 17      0.1128358   4.318592
rep 18      0.8034129 -30.377964
rep 19      0.1128358   4.318592


On Mon, Feb 5, 2018 at 4:12 AM, Dan Warren <dan.l....@gmail.com> wrote:
Yeah, that shouldn't be happening.  What do you see when you look at the "coefficients" entry in your enmtools.aoc object?

--
You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/BTuEaa-IRfs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+unsubscribe@googlegroups.com.
To post to this group, send email to max...@googlegroups.com.
Visit this group at https://groups.google.com/group/maxent.
For more options, visit https://groups.google.com/d/optout.



--
Tesa Madsen-McQueen
Graduate Student
Appalachian State University, Department of Biology
Boone, NC 28679
417.880.8319
ENMTools.R

Dan Warren

unread,
Feb 6, 2018, 4:42:52 AM2/6/18
to Maxent
Okay there's definitely something wrong with that p value, but I think the bigger problem for this particular analysis is that there's just so few species in this clade that you really shouldn't ever expect a significant result.  There are only three possible arrangements of a rooted tree with three tips, so your Monte Carlo test is going to just keep doing the same three things over and over.  

I've gotta figure out that p value thing though; I'll work on that this afternoon.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.

To post to this group, send email to max...@googlegroups.com.
Visit this group at https://groups.google.com/group/maxent.
For more options, visit https://groups.google.com/d/optout.

Dan Warren

unread,
Feb 6, 2018, 6:52:50 AM2/6/18
to Maxent
Okay I've found the issue with the p values now, I'll upload a fix shortly.

Dan Warren

unread,
Feb 6, 2018, 8:50:36 AM2/6/18
to Maxent
The current version on GitHub should now have the issue with p values corrected.  Do examine results closely, though, because it hasn't been through full testing yet.

Tesa M

unread,
Feb 6, 2018, 6:18:48 PM2/6/18
to Maxent
Hi Dan,

I appreciate your help so much- everything is working great now, and I have added in more species.

Thank you!


bil.bi...@gmail.com

unread,
Apr 12, 2019, 11:25:28 PM4/12/19
to Maxent
sorry, what is the background point?

Dan Warren

unread,
Apr 13, 2019, 4:41:04 AM4/13/19
to Maxent
Background points can be supplied manually (in the species "background.points" slot), can be drawn from the species range (a raster in the species "range" slot), or can be drawn from the environmental rasters.  The default priority is background points > range > environmental layers, but you can override that using the "bg.source" argument for any of the modeling functions.

Suzu

unread,
Mar 8, 2021, 6:11:06 PM3/8/21
to Maxent
HI,
I am trying to run enmtools.maxent and i get this error "unable to find an inherited method for function ‘raster’ for signature ‘"numeric"’". Could anyone please help me to understand this issue. Packages like ENMTools, raster are already installed; raster stack layer is correctly created with exact same extent.

Thank you

Dan Warren

unread,
Mar 9, 2021, 4:27:44 AM3/9/21
to Maxent
What do you have in the "range" slot of your species object?  Does it work when you try interactive.plot(my.species), where "my.species" is your species object?

sujata

unread,
Mar 9, 2021, 4:48:46 AM3/9/21
to max...@googlegroups.com
HI Dan,
Thank you for reaching out, for some reason i can't post back in the group although I am a member of the group so I will be replying to you via email and hopefully it will be posted in the group too
Code:
MT <- enmtools.species()
MT$species.name <- "sp"
MT$presence.points <- read.csv("C:\\My Thesis\\Occurrence data\\Presence points\\Presence.csv")
head(MT$presence.points)
rasterlist=list.files("C:/My Thesis/Environmental data/Variables ascii",pattern="asc$",full.names=T)
vars = stack(rasterlist)

my.args.mt = c("betamultiplier=4", "autofeature=FALSE", "linear=TRUE", "product=TRUE", "hinge=TRUE",
               "threshold=FALSE", "quadratic=TRUE", "replicatetype=crossvalidate","replicates=10", "randomseed=TRUE",
               "jackknife=TRUE", "doclamp=FALSE", "extrapolate=FALSE",
               "applythresholdrule=Equal training sensitivity and specificity")

mt.mx <- enmtools.maxent(MT, vars, test.prop = 0.3, nback=15000, env.nback = 15000, rts.reps = 100, bg.source="vars" args = my.args.mt)

So, I dint give any background points in the species.object because i want to do 10 replicates with random seed for each replicate but i have given the bg.source = "vars" . 
Is enmtools.maxent able to run replicates? I saw an issue raised for replicates in github, after which i reduced the replicates to just 1 and then the code was working. Is there a solution to that issue i can apply?

Thank you 
Stay safe

Best regards
Sujata

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/1a80b331-b3c5-472e-b1c0-bffe1b315d9dn%40googlegroups.com.

Dan Warren

unread,
Mar 9, 2021, 5:15:25 AM3/9/21
to Maxent
Ah!  I don't think it's understanding the bg.source = "vars" argument for one thing.  It only understands "points", "range", or "env" for that argument, but I think it should be failing through to "env" anyway so it's probably still doing the right thing.

Just to check the obvious stuff first, what happens when you do plot(vars[[1]])?

We actually haven't set it up to do replicates yet, but if I could slap together some fakey code to do it and post it on the blog.  That'll be a day or two, though.

sujata

unread,
Mar 9, 2021, 5:24:46 AM3/9/21
to max...@googlegroups.com
Hi,
With the plot(vars[[1]])
image.png
Its plotting my aspect(1st in the list or variables rasterstack) correctly

So, where does this land us now 🤔

Thank you

Best regards
Suzu

sujata

unread,
Mar 9, 2021, 8:23:26 AM3/9/21
to max...@googlegroups.com, dan.l....@gmail.com
Hi Dan,
Since my plot(vars[[1]]) is working fine ( as depicted in earlier email) and probably a fakey code like you suggested could be temporary solution but i also need to do niche similarity and other tests that ENMtools provide via R so I dont think its a good idea. 
If i may speak my mind, just a suggestion as it crossed my mind, wouldn't it be great if ENMTools could take output files from Maxent standalone software runs. Maxent software with minimal effort from user gives meaningful output (.asc) but it does not have other tests that ENMTools give like identity test, backgroud test, null model significance test, calibration index calculation, which are important. Therefore, from the user perspective it would really contribute to better experience if it was possible.

Have a nice day
Thank you
Stay safe

Best regsrds
Suzu

Dan Warren

unread,
Mar 9, 2021, 5:22:56 PM3/9/21
to sujata, max...@googlegroups.com
The change you suggest been suggested before, but it's not possible for ENMTools to do many of the tests it does using just the output from Maxent.  ENMTools actually has to simulate new data sets and send them to Maxent (or other modeling algorithms) to make models, and then uses the results of those models to make measurements for hypothesis tests.  The information to do that is not in the Maxent output.  

More importantly, though, one of the main goals of the ENMTools R package is to make other modeling methods easier and to give a single interface that works with a bunch of different algorithms, so that people can explore modeling options other than Maxent more easily.  Maxent's great, but we think that the field would be substantially improved if people would explore alternatives.  That being the case, we wouldn't really want to change the package to be Maxent-centric even if we could.  

As for fixing your issue, is there a dropbox folder you can share with me that has code and data?  It's way easier to figure this stuff out if I can just directly look at it.

Cheers!

Dan Warren
Email: dan.l....@gmail.com
Phone (US): 530-848-3809
Skype: dan.l.warren

sujata

unread,
Mar 9, 2021, 5:38:26 PM3/9/21
to Dan Warren, max...@googlegroups.com
Dear Dan,
Yes, indeed I agree with what you said and I am thankful that I am learning it from that angle too (which I was not aware of before). Again, this brings me back to replicates, since in Maxent GUI i have done 10 replicates and model evaluation is also based on that result, however I got pulled towards using ENMTools after listening to your tutorial where only 'Discrimination' type of evaluation method might be good but 'Calibration' type of evaluation makes more sense incase of habitat suitability (main objective) type of study. The Maxent GUI cannot do that so I would like to use ENMTools. But, if I cannot do replicates (I can run one time in R using ENMTools as of now) in ENMTools , and report on the Boyce index, I was thinking will it still make sense because AUC and TSS will be reported on average of 10 replicates and CBI on one. Please kindly advise me on this.

As for sharing materials, I can share the codes but I am not allowed to share the data as I have signed agreements with my data providers. Therefore, I am sorry about it.

Thanking you in anticipation
Stay safe

Best regards
Suzu

Dan Warren

unread,
Mar 9, 2021, 9:42:43 PM3/9/21
to sujata, max...@googlegroups.com
I totally understand about sharing materials, no worries!  It may make it harder to figure out what the problem is, but we'll do our best.  Can you send me your code?


Dan Warren
Email: dan.l....@gmail.com
Phone (US): 530-848-3809
Skype: dan.l.warren

Dan Warren

unread,
Mar 11, 2021, 3:03:52 AM3/11/21
to Maxent
For anyone interested, I added a bit of code showing how you could do reps using ENMTools to the blog:


At some point we'll need to add a simpler way to do that, but I've got a lot on my plate at the moment so it may be a while.

Suzu

unread,
Mar 11, 2021, 10:47:49 AM3/11/21
to Maxent
HI Dan,
Thank you for the time and code.
Best regards
Suzu

Belay Ejigu

unread,
Mar 11, 2021, 12:55:09 PM3/11/21
to max...@googlegroups.com
Dear Suzu, please visit the link: www. joshbanta.org. The site which taught me a lot.
Stay safe!

Reply all
Reply to author
Forward
0 new messages