These instructions describe how to use the R package move2 on the HPC cluster:
On this system, credentials are stored per R session using the keyring env backend (expected behaviour on headless nodes).
~$ srun -p ceab --pty bash
~$ module load R-bundle-CRAN
Start R,
~$ R
Check whether move2 is installed:
> library(move2)
If not installed (typical on HPCs), install it in your user library:
> install.packages("move2", repos = "https://cloud.r-project.org")
The package will be installed under ~/R/x86_64-pc-linux-gnu-library/.
> library(move2) > movebank_store_credentials(<movebank_user_name>)
You will be prompted once for your Movebank password. Credentials remain valid only for the current R session.
A warning about the env backend may appear. This is expected on this system.
List all accessible studies:
> movebank_download_study_info()
List only studies with download access:
> movebank_download_study_info(i_have_download_access = TRUE)
Query a specific study by ID:
> movebank_download_study_info(id = 2911040)
To avoid repeated warnings about the keyring backend:
suppressWarnings( movebank_download_study_info() )
This does not affect functionality.
Resolve the study ID if you just know the name:
suppressWarnings(
study_id <- movebank_get_study_id(
study_id = "Galapagos Albatrosses"
)
)
Then download data with filters:
suppressWarnings(
data <- movebank_download_study(
study_id,
sensor_type_id = "gps",
timestamp_start = as.POSIXct("2008-08-01 00:00:00"),
timestamp_end = as.POSIXct("2008-08-02 00:00:00")
)
)
data is returned as a move2 object and can be processed directly with the package’s tools.
Because the system is headless, Movebank credentials must be provided via environment variables (lost on shell session exit).
NEVER hard-code passwords in your R scripts !!
Before submitting the job, export your credentials in the shell.
export MOVEBANK_USER="your_movebank_user_name" export MOVEBANK_PASSWORD="your_movebank_user_password"
These variables are inherited by the Slurm job.
Example: myRscript.R
library(move2)
# Get credentials from the env vars and store credentials for this Movebank session
movebank_store_credentials(
Sys.getenv("MOVEBANK_USER"),
Sys.getenv("MOVEBANK_PASSWORD")
)
# Check available studies
studies <- suppressWarnings(
movebank_download_study_info(i_have_download_access = TRUE)
)
# show result
print(studies)
Example: run_myRscript.sbatch
#!/bin/bash #SBATCH --job-name=movebank #SBATCH --time=01:00:00 #SBATCH --mem=4G #SBATCH --cpus-per-task=1 #SBATCH --output=myRscript_%j.out #SBATCH --error=myRscript_%j.err # load R modules module load R-bundle-CRAN # launch R script Rscript myRscript.R
srun_-p ceab run_myRscript.sbatch