Hi Sam,
I took a look at your data and I’m not getting the same thing - for the most part the detections are at receivers with IDs and names. When you downloaded the data in R, did the download complete? Or was there a timeout or other error that stopped it early?
I did get 55 hits that were missing recv ID and names (out of a total 174985 hits, so a tiny fraction of the hits), but those were all run lengths of two except for 3 runs of length3 or 4. So I’d be inclined to believe those are false positives that can be removed anyway. Here’s a snippet of my code:
library(motus)
library(tidyverse)
library(lubridate)
# set timezone
Sys.setenv(TZ = "GMT")
# download/update project database and receiver databases (change to new = FALSE after first time downloading)
tagme(projRecv = 434, new = TRUE, update = TRUE, forceMeta = TRUE, dir = "sql-databases/")
# file path to sql database files
path <- "./sql-databases/"
#### pull out metadata for all project 434 tags ####
# in the motus species list NSWO = 7680
# double check species codes
sqldb <- tagme(projRecv = 434, new = FALSE, update = FALSE, dir = path)
sp.list <- c(7680) # nswo
species <- tbl(sqldb, "species") %>%
filter(id %in% sp.list) %>%
collect() %>%
as.data.frame()
# get tag metadata
tagmet <- tbl(sqldb, "tagDeps")
tags.meta <- tagmet %>%
select(deployID, tagID, projectID, tsStart, tsEnd, deferSec, speciesID,
markerNumber, latitude, longitude, fullID, comments) %>%
filter(speciesID %in% sp.list) %>%
collect() %>%
as.data.frame() %>% # once in df format, can format dates with lubridate
mutate(tsStart = as_datetime(tsStart, tz = "UTC", origin = "1970-01-01"),
tsEnd = as_datetime(tsEnd, tz = "UTC", origin = "1970-01-01")) %>%
distinct() %>%
filter(!is.na(longitude)) %>%
group_by(tagID) %>%
mutate(n = n()) %>%
ungroup()
# get ambiguous tag info
allambigs <- tbl(sqldb, "allambigs")
ambig <- allambigs %>%
collect() %>%
as.data.frame()
# check if any tags interested in have ambiguous detections
tags.ambigs <- ambig %>%
group_by(ambigID) %>%
mutate(inds = ifelse(any(motusTagID %in% tags.meta$tagID), "yes","no")) %>%
filter(inds == "yes") %>%
ungroup() %>%
rename(tagID = motusTagID)
# get tag list (includes tags interested in and relevant ambiguous tags)
tag.list <- tags.meta %>%
select(tagID) %>%
bind_rows(., tags.ambigs %>% select(tagID)) %>%
distinct() %>% pull()
# alltags dataset
system.time({
alltag <- tbl(sqldb, "alltags")
tags.detect <- alltag %>%
filter(tagProjID == 434 & motusTagID %in% tag.list) %>%
select(hitID, runID, batchID, ts, sig, port, noise, freqsd, motusTagID,
ambigID, runLen, tagProjID, tagDeployID, tagDeployStart, tagDeployEnd,
tagDepLat, tagDepLon, deviceID, recvDeployID, recv,
speciesSci, markerNumber, mfg, mfgID) %>%
collect() %>%
as.data.frame() %>%
mutate(ts = as_datetime(ts, tz = "UTC", origin = "1970-01-01"),
tagDeployStart = as_datetime(tagDeployStart, tz = "UTC", origin = "1970-01-01"),
tagDeployEnd = as_datetime(tagDeployEnd, tz = "UTC", origin = "1970-01-01"))
})
any(is.na(tags.detect$recvDeployID))
tags.detect.na <- tags.detect %>% filter(is.na(recvDeployID))
tags.detect.na %>% select(runLen) %>% group_by(runLen) %>% summarize(n = n())
You can see I commented out the lines where I usually remove detections at receivers with no ID or coordinates. I’d be curious if this works for you? I can share more code if it does.
Amie