multiple home range

264 views
Skip to first unread message

Gianluca Roncalli

unread,
Jan 29, 2020, 9:49:44 AM1/29/20
to ctmm...@googlegroups.com
Hi,
I'm new in movement ecology and in using this interesting package. I'm analysing trajectory and home ranges in mallards and I would like to see how the home range change according to mallard biological season. Therefor I need to calculate for each animals 3 home ranges. I have 50 mallard tagged. So, my question is if I have to run each analysis for separate or there are some ways to do it quickly. 
Than you for any suggestions.
All the best,
--
Gianluca Roncalli

ISPRA (Istituto Superiore per la Protezione e la Ricerca Ambientale)
Area per l'Avifauna Migratrice (BIO-AVM)
Via Cà Fornacetta 9,  
40064 Ozzano dell'Emilia, BO 
Italy
 

Christen Fleming

unread,
Jan 29, 2020, 12:24:06 PM1/29/20
to ctmm R user group
Hi Gianluca,

If working in R, you can just put everything in a loop. Alternatively, the ctmmweb package facilitates some batch calculations: https://github.com/ctmm-initiative/ctmmweb

Best,
Chris

Askren Ryan

unread,
Aug 25, 2020, 9:30:32 AM8/25/20
to ctmm R user group
Any chance some one would be willing to post and example with a for loop? I'm dealing with a similar situation and struggling.

Appreciate everyone's help,
Ryan

Christen Fleming

unread,
Aug 25, 2020, 2:50:23 PM8/25/20
to ctmm R user group
Hi Ryan,

A simple example would be something like

DATA <- as.telemetry("Movebank.csv")
FITS <- UDS <- list()

for(i in 1:length(DATA))
{
  print(i)
  GUESS <- ctmm.guess(DATA[[i]],interactive=FALSE)
  FITS[[i]] <- ctmm.select(DATA[[i]],GUESS,trace=2)
  UDS[[i]] <- akde(DATA[[i]],FITS[[i]])
}

When you get what you want in your loop, if it's still taking a long time, you can upgrade to a parallelized loop with foreach. I have 4 of my cores running analysis on 49 coatis right now.
For longer runs, I recommend save() incrementally, in case you run into trouble somewhere, so you don't have to start over from scratch.

I'm also listing project code on the group description/intro, and there's one there already.

Best,
Chris

Askren Ryan

unread,
Aug 25, 2020, 4:19:14 PM8/25/20
to ctmm R user group
Thank you Chris, appreciate your help!  Woof. Sounds daunting! Looks like I might need to look into some more computing power. 

That helps a lot and gets me a lot closer. Still need to go revisit some for loop lessons to work on printing out the areas. Don't use them near as often as I should.

Amanda Droghini

unread,
Aug 31, 2020, 3:10:41 PM8/31/20
to ctmm R user group
Hi Ryan, 

I have some code posted on GitHub that might help. 

I ran into some memory limit issues (I only have 16GB of RAM on my work laptop), so I had to cut my data up into several chunks. Not ideal, but it did allow me to work through my dataset.

Lines 29-59 of the ctmmModelSelection script generates initialized parameters and movement models using lapply. It took 28 hours to run 50 seasonal home ranges with ctmm.select. 
The generateHomeRange script splits up the data and runs the akde function on the top-performing models (selected in previous scripts). 

If you intend to split up the data into workable chunks, I recommend using a predefined extent, that way the extent will be consistent across all individuals. There's some code for that at the beginning of the generateHomeRange script

If you are interested in seasonal home ranges and overlaps, I recommend placing all the data from the same individual in the same data chunk. That way you never need to merge into one giant master file- again, if your computer is low on RAM, loading a very large file might take up so much memory that you won't be able to do anything.

I can't remember why I didn't use a parallel for loop- I'll definitely look into that once I jump back into these analyses again, and I'd be happy to share my code with everyone.

Good luck,
Amanda
Reply all
Reply to author
Forward
0 new messages