View source: R/helpers.R View source: R/birdnet_iNEXT.R
birdnet_iNEXT | R Documentation |
TBD
TBD
birdnet_iNEXT(data, confidence.threshold = 0, n.detections = 1)
birdnet_iNEXT(data, confidence.threshold = 0, n.detections = 1)
data |
Data.frame / data.table with.... |
confidence.threshold |
Threshold below which BirdNET results should be excluded. |
n.detections |
Number of detections of a species within a day to conclude presence. |
This function was developed by the National Park Service Natural Sounds and Night Skies Division to support species biodiversity characterization in bioacoustics projects. This function is under development.
This function was developed by the National Park Service Natural Sounds and Night Skies Division Scientists in Parks intern Kayley Dillon to support species biodiversity characterization in bioacoustics projects.
DESCRIBE... additional columns:
insert col name here: tbd
insert col name here: tbd
insert col name here: tbd
DESCRIBE... additional columns:
stuff: tbd
stuff: tbd
stuff: tbd
## Not run:
# Read in example BirdNET data
data(exampleBarchartData)
dat <- add_time_cols(
dt = exampleBarchartData,
recording.id.col = 'recordingID',
tz.recorder = 'America/Los_Angeles',
tz.local = 'America/Los_Angeles'
)
result <- birdnet_iNEXT(
data = dat,
confidence.threshold = 0,
n.detections = 3
)
# We can use this result to plot species rarefaction curves
# Possibly just script this instead of functionizing
# Choose "sized-based" vs "coverage-based"
size.based <- data.table(
Days = result$iNextEst$size_based$t,
Richness = result$iNextEst$size_based$qD,
Lower_95 = result$iNextEst$size_based$qD.LCL,
Upper_95 = result$iNextEst$size_based$qD.UCL,
Method = result$iNextEst$size_based$Method
)
cov.based <- data.table(
Days = result$iNextEst$coverage_based$t,
Richness = result$iNextEst$coverage_based$qD,
Lower_95 = result$iNextEst$coverage_based$qD.LCL,
Upper_95 = result$iNextEst$coverage_based$qD.UCL,
Method = result$iNextEst$coverage_based$Method
)
cov.based[,locationID := 'Rivendell']
size.based[,locationID := 'Rivendell']
cov.based[,Filter := 'Coverage']
size.based[,Filter := 'Size']
dat <- rbind(cov.based, size.based)
# Richness values are essentially the same;
# it's the confidence values that are different
# size.based conf ranges will be much tighter
# Separate out by method
interp <- dat[Method == 'Rarefaction']
extrap <- dat[Method == 'Extrapolation']
obs <- dat[Method == 'Observed']
# Transform data to order plots properly
levs <- c('Coverage', 'Size')
dat$Filter <- factor(dat$Filter, levels = levs)
interp$Filter <- factor(interp$Filter, levels = levs)
extrap$Filter <- factor(extrap$Filter, levels = levs)
obs$Filter <- factor(obs$Filter, levels = levs)
# Graph Results
ggplot() +
facet_grid(cols = vars(Filter), scales = "free_x") +
geom_ribbon(dat, mapping =
aes(x = Days, ymin = Lower_95,
ymax = Upper_95, fill = locationID),
alpha = 0.5) +
geom_point(data = obs, mapping =
aes(x = Days, y = Richness,
color = locationID), size = 3) +
geom_line(data = interp, mapping =
aes(x = Days, y = Richness,
color = locationID,
linetype = "dashed"), size = 1) +
geom_line(data = extrap, mapping =
aes(x = Days, y = Richness,
color = locationID,
linetype = "solid"), size = 1) +
theme_classic() +
scale_fill_manual(name = "locationID",
values = c("#66c2a5", "#fc8d62")) +
scale_color_manual(name = "locationID",
values = c("#66c2a5", "#fc8d62")) +
labs(x = "Days Sampled", y = "Species Richness") +
guides(linetype = "none")
## End(Not run)
## Not run:
# Read in example BirdNET data
data(exampleBarchartData)
dat <- add_time_cols(
dt = exampleBarchartData,
recording.id.col = 'recordingID',
tz.recorder = 'America/Los_Angeles',
tz.local = 'America/Los_Angeles'
)
result <- birdnet_iNEXT(
data = dat,
confidence.threshold = 0,
n.detections = 3
)
# We can use this result to plot species rarefaction curves
# Possibly just script this instead of functionizing
# Not sure if this should be "sized-based" vs "coverage-based"
# Size-based looks more right
size.based <- data.table(
Days = result$iNextEst$size_based$t,
Richness = result$iNextEst$size_based$qD,
Lower_95 = result$iNextEst$size_based$qD.LCL,
Upper_95 = result$iNextEst$size_based$qD.UCL,
Method = result$iNextEst$size_based$Method
)
cov.based <- data.table(
Days = result$iNextEst$coverage_based$t,
Richness = result$iNextEst$coverage_based$qD,
Lower_95 = result$iNextEst$coverage_based$qD.LCL,
Upper_95 = result$iNextEst$coverage_based$qD.UCL,
Method = result$iNextEst$coverage_based$Method
)
cov.based[,locationID := 'Rivendell']
size.based[,locationID := 'Rivendell']
cov.based[,Filter := 'Coverage']
size.based[,Filter := 'Size']
dat <- rbind(cov.based, size.based)
# Okay, so the richness values are essentially the same;
# it's the confidence values that are different
# size.based conf ranges will be much tigher -- why?
# Separate out by method
interp <- dat[Method == 'Rarefaction']
extrap <- dat[Method == 'Extrapolation']
obs <- dat[Method == 'Observed']
# Transform data to order plots properly
levs <- c('Coverage', 'Size')
dat$Filter <- factor(dat$Filter, levels = levs)
interp$Filter <- factor(interp$Filter, levels = levs)
extrap$Filter <- factor(extrap$Filter, levels = levs)
obs$Filter <- factor(obs$Filter, levels = levs)
## Graph ####
ggplot() +
facet_grid(cols = vars(Filter), scales = "free_x") +
geom_ribbon(dat, mapping =
aes(x = Days, ymin = Lower_95,
ymax = Upper_95, fill = locationID),
alpha = 0.5) +
geom_point(data = obs, mapping =
aes(x = Days, y = Richness,
color = locationID), size = 3) +
geom_line(data = interp, mapping =
aes(x = Days, y = Richness,
color = locationID,
linetype = "dashed"), size = 1) +
geom_line(data = extrap, mapping =
aes(x = Days, y = Richness,
color = locationID,
linetype = "solid"), size = 1) +
theme_classic() +
scale_fill_manual(name = "locationID",
values = c("#66c2a5", "#fc8d62")) +
scale_color_manual(name = "locationID",
values = c("#66c2a5", "#fc8d62")) +
labs(x = "Days Sampled", y = "Species Richness") +
guides(linetype = "none")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.