R packages for the behavioral (evolutionary) biologist’s tool kit

 

Marcelo Araya-Salas PhD

Neuroscience Research Center, University of Costa Rica

Common research questions

  • How animal acoustic signals vary in space and time? why?

  • What is their function?

  • What socio-ecological factors favor the evolution of specific features? (e.g. complexity)

Acoustic analysis workflow

 

Installation

 

To run the code in this presentation install this packages:

# from CRAN
install.packages("warbleR")
install.packages("ohun")
install.packages("PhenotypeSpace")
install.packages("baRulho")
install.packages("remotes")

"#35B77933"
# from github
remotes::install_github("maRce10/dynaSpec")  #developmental need ffmpeg
remotes::install_github("maRce10/suwo")  # developmental version

Get recordings

Package suwo

Streamline searching/downloading of nature media files (e.g. audios, photos) from online repositories.

The package offers functions for:

  • Obtaining media metadata from online repositories
  • Downloading associated media files
  • Updating data sets with new records

Get recordings

Package suwo

suwo give access to this repositories:

query_gbif()
query_inaturalist()
query_macaulay()
query_observation()
query_wikiaves()
query_xenocanto()

Get recordings


Search and download recordings from Xeno-Canto

# search without downloading
p_strii <- suwo::query_xenocanto(term = "Phaethornis striigularis")

# check
p_strii

Get recordings

Visualize geographic spread

# create map
suwo::map_locations(p_strii)

Get recordings


Filter recordings and download

# subset
p_strii <- p_strii[grepl("song", p_strii$vocalization.type, ignore.case = TRUE) &
    p_strii$country == "Costa Rica", ]

# check # recordings
nrow(p_strii)
[1] 17

Get recordings

Filter recordings and download

# download
suwo::download_media(metadata = p_strii)

# check files
list.files(pattern = "striigularis")
 [1] "Phaethornis_striigularis-XC107207.mp3"
 [2] "Phaethornis_striigularis-XC154027.mp3"
 [3] "Phaethornis_striigularis-XC154073.mp3"
 [4] "Phaethornis_striigularis-XC154074.mp3"
 [5] "Phaethornis_striigularis-XC15569.mp3" 
 [6] "Phaethornis_striigularis-XC274301.mp3"
 [7] "Phaethornis_striigularis-XC274600.mp3"
 [8] "Phaethornis_striigularis-XC482544.mp3"
 [9] "Phaethornis_striigularis-XC482545.mp3"
[10] "Phaethornis_striigularis-XC518509.mp3"

Get recordings

Larger data sets

# search without downloading
trochilidae <- p_strii <- suwo::query_xenocanto(term = "Trochilidae")

# check
nrow(trochilidae)
[1] 9455
# number of species
length(unique(trochilidae$english.name))
[1] 348

Annotate


2 options:

  • Manual: Raven (GUI) + Rraven (R package)

  • Automatic: ohun

Annotate

Package Rraven

Facilitate the exchange of data between R and Raven

The package offers functions for:

  • Import/export between R and Raven
  • Call Raven commands from terminal
  • Formatting data in a R friendly format

Raven + Rraven

Raven

Raven + Rraven


Rraven: import Raven annotation files

# import into R
annotations <- Rraven::imp_raven()

# check
table(annotations$`Begin File`)

Phae.long1.wav Phae.long2.wav Phae.long3.wav Phae.long4.wav 
             6              4              6              6 

Raven + Rraven


Rraven: import Raven annotation files in warbleR format

# import into R
annotations <- Rraven::imp_raven(warbler.format = TRUE)

# check
check <- warbleR::check_sels(annotations, fix.selec = TRUE)

Syrinx + Rraven


Rraven: import Syrinx annotation files

# import into R
annotations <- Rraven::imp_syrinx()

Annotate

Package ohun

Optimize acoustic signal detection

Main features:

  • Reference annotations for detection diagnostic and optimization
  • The use of signal detection theory indices to evaluate detection performance

Signal detection theory & bioacoustics

  • True positives: signals correctly identified as ‘signal’
  • False positives: background noise incorrectly identified as ‘signal’
  • False negatives: signals incorrectly identified as ‘background noise’
  • True negatives: background noise correctly identified as ‘background noise’

Signal detection theory & bioacoustics

 

  • Recall: proportion of target signals that were detected (a.k.a. true positive rate or recall)
  • Precision: proportion of detected items that correspond to target signals

Diagnosing detection

data("lbh_reference")

lbh_reference

Diagnosing detection

# read wave file
lbh1 <- warbleR::read_wave("lbh1.wav")

# print spectrogram
ohun::label_spectro(wave = lbh1, reference = lbh_reference[lbh_reference$sound.files ==
    "lbh1.wav", ], hop.size = 10, ovlp = 50, flim = c(1, 10))

Diagnosing detection

# subset table
lbh1_reference <- lbh_reference[lbh_reference$sound.files == "lbh1.wav", ]
lbh1_detection <- lbh1_reference[3:9, ]

# print spectrogram
ohun::label_spectro(wave = lbh1, reference = lbh1_reference, detection = lbh1_detection,
    hop.size = 10, ovlp = 50, flim = c(1, 10))

Diagnosing detection

# diagnose
ohun::diagnose_detection(reference = lbh1_reference, detection = lbh1_detection)[,
    c(1:3, 7:8)]

Optimize detection

Template-based detection

# run correlator
correlations <- ohun::template_correlator(templates = lbh1_reference[1, ], files = "lbh1.wav",
    path = getwd())

# detect
detection <- ohun::template_detector(template.correlations = correlations, threshold = 0.3)

Optimize detection

# run optimization
optimization <- ohun::optimize_template_detector(template.correlations = correlations,
    reference = lbh1_reference, threshold = seq(0.1, 0.5, 0.1))

optimization
5 thresholds will be evaluated:

Optimize detection

Optimal detection

detection <- ohun::template_detector(template.correlations = correlations, threshold = 0.4)

Measure structure

Package warbleR

Quantify signal structure

Main features:

  • Measures of acoustic structure
  • Iterates tasks through acoustic signals referenced in selection tables
  • The production of spectrograms to allow users organize data and verify acoustic analyses

Measure structure

warbleR: Measure spectral/spectrographic features

spec_feat <- warbleR::spectro_analysis(X = detection, bp = c(0, 11), wl = 100)
sound.files selec duration meanfreq sd freq.median freq.Q25 freq.Q75 freq.IQR time.median time.Q25 time.Q75 time.IQR skew kurt sp.ent time.ent entropy sfm meandom mindom maxdom dfrange modindx startdom enddom dfslope meanpeakf
lbh1.wav 1 0.147887 5.95906 1.71932 5.98709 4.94526 7.01537 2.07011 0.056322 0.030508 0.091524 0.061016 1.83210 6.59354 0.917532 0.915261 0.839781 0.397435 6.20156 0.11025 8.26875 8.1585 6.13514 6.94575 0.11025 -46.22121 6.06375
lbh1.wav 2 0.147887 5.97920 1.77904 6.02091 5.06027 7.16421 2.10394 0.063382 0.035212 0.100942 0.065729 1.84044 6.58704 0.916973 0.916176 0.840109 0.399523 6.55643 4.29975 8.48925 4.1895 6.94737 6.50475 6.50475 0.00000 7.38675
lbh1.wav 3 0.147887 5.85998 1.75503 5.85855 4.79643 7.08303 2.28659 0.058687 0.030517 0.100942 0.070424 1.79608 6.56891 0.918401 0.916101 0.841348 0.412145 6.17400 4.07925 8.26875 4.1895 8.68421 6.72525 6.50475 -1.49101 7.38675
lbh1.wav 4 0.147887 5.86993 1.67064 5.77060 5.04674 6.81242 1.76568 0.065709 0.035201 0.098564 0.063362 2.61666 12.45642 0.906144 0.915839 0.829882 0.379067 6.20501 4.07925 8.26875 4.1895 11.00000 6.50475 7.60725 7.45503 5.40225
lbh1.wav 5 0.147887 5.79418 1.66810 5.62177 4.78967 6.88684 2.09717 0.056339 0.028170 0.086857 0.058687 2.03709 7.60290 0.908137 0.914979 0.830927 0.377063 5.95525 0.11025 8.26875 8.1585 7.62162 6.72525 0.11025 -44.73020 5.18175
lbh1.wav 6 0.147887 6.05977 1.81091 6.01415 5.05351 7.24539 2.19188 0.061034 0.030517 0.098594 0.068077 1.96168 7.60945 0.921289 0.916108 0.844000 0.422040 6.49786 4.29975 8.48925 4.1895 7.15789 6.28425 7.60725 8.94604 5.62275
lbh1.wav 7 0.147887 5.88742 1.70393 5.79090 4.85732 7.09656 2.23924 0.065729 0.032865 0.103289 0.070424 2.23650 10.43028 0.912695 0.916198 0.836209 0.371971 6.11543 4.07925 8.48925 4.4100 10.75000 4.52025 5.62275 7.45503 6.06375
lbh1.wav 8 0.147887 6.11484 1.71571 6.02768 5.19557 7.15068 1.95511 0.065729 0.035212 0.100942 0.065729 2.24300 8.96966 0.910388 0.916266 0.834157 0.389885 6.48063 4.07925 8.48925 4.4100 8.25000 6.72525 7.82775 7.45503 5.40225
lbh1.wav 9 0.147887 5.96862 1.69006 5.79090 4.93850 6.98832 2.04982 0.058687 0.030517 0.107984 0.077467 1.88807 6.22741 0.908423 0.916289 0.832378 0.398026 6.31870 4.07925 8.26875 4.1895 11.57895 4.74075 6.50475 11.92805 5.40225
lbh1.wav 10 0.147887 5.82763 1.68282 5.68942 4.91820 6.89360 1.97540 0.065729 0.035212 0.105637 0.070424 2.20855 8.63458 0.909687 0.916784 0.833986 0.413549 6.29803 4.29975 8.26875 3.9690 8.33333 6.50475 5.18175 -8.94604 5.40225

Measure structure

warbleR: Mel-frequency cepstral coefficients

mfcc_feat <- warbleR::mfcc_stats(X = detection, bp = c(0, 11))
sound.files selec min.cc1 min.cc2 min.cc3 min.cc4 min.cc5 min.cc6 min.cc7 min.cc8 min.cc9 min.cc10 min.cc11 min.cc12 min.cc13 min.cc14 min.cc15 min.cc16 min.cc17 min.cc18 min.cc19 min.cc20 min.cc21 min.cc22 min.cc23 min.cc24 min.cc25 max.cc1 max.cc2 max.cc3 max.cc4 max.cc5 max.cc6 max.cc7 max.cc8 max.cc9 max.cc10 max.cc11 max.cc12 max.cc13 max.cc14 max.cc15 max.cc16 max.cc17 max.cc18 max.cc19 max.cc20 max.cc21 max.cc22 max.cc23 max.cc24 max.cc25 median.cc1 median.cc2 median.cc3 median.cc4 median.cc5 median.cc6 median.cc7 median.cc8 median.cc9 median.cc10 median.cc11 median.cc12 median.cc13 median.cc14 median.cc15 median.cc16 median.cc17 median.cc18 median.cc19 median.cc20 median.cc21 median.cc22 median.cc23 median.cc24 median.cc25 mean.cc1 mean.cc2 mean.cc3 mean.cc4 mean.cc5 mean.cc6 mean.cc7 mean.cc8 mean.cc9 mean.cc10 mean.cc11 mean.cc12 mean.cc13 mean.cc14 mean.cc15 mean.cc16 mean.cc17 mean.cc18 mean.cc19 mean.cc20 mean.cc21 mean.cc22 mean.cc23 mean.cc24 mean.cc25 var.cc1 var.cc2 var.cc3 var.cc4 var.cc5 var.cc6 var.cc7 var.cc8 var.cc9 var.cc10 var.cc11 var.cc12 var.cc13 var.cc14 var.cc15 var.cc16 var.cc17 var.cc18 var.cc19 var.cc20 var.cc21 var.cc22 var.cc23 var.cc24 var.cc25 skew.cc1 skew.cc2 skew.cc3 skew.cc4 skew.cc5 skew.cc6 skew.cc7 skew.cc8 skew.cc9 skew.cc10 skew.cc11 skew.cc12 skew.cc13 skew.cc14 skew.cc15 skew.cc16 skew.cc17 skew.cc18 skew.cc19 skew.cc20 skew.cc21 skew.cc22 skew.cc23 skew.cc24 skew.cc25 kurt.cc1 kurt.cc2 kurt.cc3 kurt.cc4 kurt.cc5 kurt.cc6 kurt.cc7 kurt.cc8 kurt.cc9 kurt.cc10 kurt.cc11 kurt.cc12 kurt.cc13 kurt.cc14 kurt.cc15 kurt.cc16 kurt.cc17 kurt.cc18 kurt.cc19 kurt.cc20 kurt.cc21 kurt.cc22 kurt.cc23 kurt.cc24 kurt.cc25 mean.d1.cc var.d1.cc mean.d2.cc var.d2.cc
lbh1.wav 1 90.2129 -25.5996 0.805501 3.488302 -13.5567 -1.112234 -16.4161 -4.19924 -17.6167 -12.44548 -17.76328 -13.41737 -22.6941 -8.71681 -8.64918 -4.571500 -5.40916 -20.49385 -8.53938 -14.30254 -12.51024 -7.37043 -4.39387 -7.03990 -5.91958 99.4991 -17.8560 14.46593 9.26725 -1.990946 16.62131 1.781405 17.4127 -0.304340 11.22007 10.7334 25.2248 10.35732 11.75696 8.08490 6.71083 6.85102 11.39718 26.64625 10.30795 11.50016 8.31319 5.54028 0.902970 5.521211 93.8721 -22.0565 7.90590 6.56839 -7.35217 4.44463 -2.98563 6.25871 -6.35980 3.456931 1.945456 0.025953 -6.66967 2.003085 0.082016 -0.126238 -2.075117 6.13335 1.072004 -4.943429 0.721676 2.210167 1.974995 -1.724333 -0.077543 95.0412 -22.1408 7.76184 6.16043 -8.50716 5.36741 -5.62303 6.31273 -6.94455 1.571467 0.363687 4.280110 -5.22331 2.218757 -0.351147 0.456766 -0.738497 2.109091 3.29118 -4.047650 0.958590 1.918053 0.244803 -2.730620 -0.416306 12.13725 6.33972 14.10205 2.93762 16.62648 24.02488 41.6026 58.8361 36.3432 70.2226 69.8215 132.6657 87.2650 31.6489 23.7278 10.65491 17.1644 98.5761 106.2045 64.8248 55.2044 19.8990 12.90306 8.84151 10.98102 0.037929 0.321762 -0.194624 -0.006975 0.136656 0.829546 -0.366800 0.102187 -0.527895 -0.490759 -0.749272 0.276491 -0.205870 -0.166511 -0.032470 0.417196 0.385867 -0.987714 0.838060 0.471102 -0.243787 -0.552905 -0.057541 -0.270744 0.040638 1.07696 1.60248 2.38476 2.00631 1.28555 2.99940 1.44760 1.42809 1.85980 1.65827 2.53146 1.80144 2.17653 2.21488 2.03143 2.24018 1.53986 2.75328 2.78452 1.95754 1.86686 2.41606 1.20012 1.31561 1.93355 -148.528 101671.0 2206.68 11741556
lbh1.wav 2 88.5648 -24.2117 4.968126 3.033494 -12.7254 -3.350429 -15.4275 -2.23558 -12.6859 -13.72864 -21.76081 -7.48815 -22.6190 -4.94643 -5.61556 -4.348397 -14.60882 -17.07365 -3.45772 -15.47859 -15.25942 -7.93937 -5.33024 -5.89953 -8.23582 98.6583 -18.7407 14.35674 9.81922 0.168918 10.96352 0.159090 20.3962 6.699007 10.55306 14.6666 23.1736 9.36455 13.38731 9.68901 12.95817 12.25174 15.08400 21.77864 8.30159 9.43519 11.93261 4.75119 6.343295 7.140148 93.4055 -21.0815 8.46591 5.83323 -10.24566 4.78771 -4.74502 9.38818 -1.80740 3.611036 -6.533159 9.209532 -4.70109 2.904760 4.644595 3.015472 -2.586634 -3.51535 6.074550 -5.967829 -1.376674 -2.513669 0.386842 -2.735051 -1.908388 93.3346 -21.5296 8.23528 6.28861 -7.49229 5.27929 -5.87033 8.58697 -2.48974 0.775415 -3.560049 6.950878 -5.40873 3.749961 3.761848 4.075771 -1.612448 -0.194968 5.99751 -4.417604 -0.894304 1.497577 0.551711 -2.100930 -0.983651 11.10910 3.41737 8.01842 5.30581 23.74940 17.23034 23.5216 78.3759 42.2981 71.2054 137.5110 85.3759 106.9552 45.3229 22.1622 26.74489 55.0318 76.7686 80.5815 66.2927 59.3652 51.9734 7.88970 9.91341 19.59806 0.123884 -0.088635 0.662088 0.123098 0.336598 -0.452601 -0.622217 0.093990 -0.301334 -0.291956 0.066636 0.057455 -0.234002 0.149876 -0.756059 0.238559 0.321387 -0.099773 0.330961 0.374882 -0.227317 0.162671 -0.445903 1.567396 0.233312 1.43548 1.45882 2.39261 1.36199 1.22424 2.27529 1.97264 1.16522 1.57498 1.41944 1.44454 1.73351 1.71542 1.27395 2.33725 1.98448 2.37228 2.23331 1.46427 1.54300 1.87081 1.19687 2.48987 4.93087 1.99805 -146.833 96496.6 2155.79 11292257
lbh1.wav 3 90.4902 -24.8651 3.113221 5.077249 -12.0392 -1.838020 -17.1330 -5.64541 -17.7511 -13.33633 -11.11703 -12.30617 -17.1301 -4.11249 -7.12145 -2.961179 -6.85779 -16.75956 -5.30513 -9.37453 -12.84312 -5.93525 -7.33820 -9.72184 -4.90685 98.5297 -20.2855 10.83829 9.59259 -3.116308 11.78174 0.720599 20.7948 -0.173445 7.16004 11.1625 22.4373 5.72582 15.52108 6.39283 8.43330 18.17907 9.31267 19.11297 12.13091 9.53918 18.38206 4.98410 9.659717 5.888749 93.7131 -22.7086 7.92611 7.44393 -10.92316 2.22250 -4.93000 8.23076 -5.34937 -1.552035 -4.585128 3.987570 -3.90079 0.071477 -0.245560 4.072519 -1.428221 -0.99502 6.301782 -1.179608 -0.894276 0.061811 0.283991 -0.452755 -0.835479 93.7260 -22.7752 7.26886 7.23110 -8.96879 3.40510 -6.07393 7.02995 -6.54645 -1.396147 -1.394491 4.498826 -4.61437 1.978292 -0.210165 3.315016 -0.276413 -1.196653 5.87814 -0.776806 -1.338151 3.351700 -0.243671 -0.026803 0.439522 7.88190 2.06746 6.47756 1.72497 11.95588 17.36527 40.2956 74.7931 28.6523 43.0546 68.3518 87.7657 58.8750 31.9018 13.1266 12.11919 48.4214 54.9845 50.9721 43.9552 49.5005 53.3475 11.99907 28.14201 16.04733 0.435424 0.350225 -0.256637 0.036780 0.722163 0.568977 -0.587643 0.035725 -0.676783 -0.539204 0.291862 0.181436 -0.333834 1.036217 -0.072091 -0.353641 1.529991 -0.540041 0.301412 0.504038 -0.069071 0.623413 -0.478190 0.105853 0.114944 1.56804 1.83244 1.48950 2.09191 1.62651 2.12269 1.72721 1.47734 2.26746 1.98106 1.29238 2.42308 1.70749 3.31491 2.36671 1.89551 4.65329 2.42613 1.98052 1.97926 1.69138 2.13365 2.33476 2.27187 1.23268 -143.793 100495.3 2200.21 11324727
lbh1.wav 4 90.2578 -25.0639 2.842731 4.551090 -14.5472 -3.681339 -16.4850 -3.05836 -11.7766 -13.39487 -12.82152 -12.35989 -19.1458 -4.13009 -7.92866 -5.721921 -10.82868 -10.73809 -5.03697 -8.68568 -14.61562 -7.32429 -5.15353 -4.58642 -4.29872 99.2656 -18.0745 10.51268 8.89965 -4.071075 11.28372 1.075019 17.7107 6.281737 9.60899 13.0561 24.9468 7.32285 11.61847 6.39486 6.29053 9.64016 17.32751 8.49234 15.84367 7.25066 12.15283 3.26556 4.348399 4.999716 93.7032 -22.1153 8.61496 5.96290 -11.19258 5.56654 -4.21973 8.06001 -4.91877 -1.320584 -1.150037 6.690278 -5.44001 -0.121516 0.396508 3.772761 2.595399 2.06191 0.155841 -0.564320 -2.642061 -1.509695 -0.097372 1.938836 -1.605216 94.5747 -21.9815 7.23251 6.26057 -10.11095 5.87007 -5.98528 8.11641 -4.13114 -1.349572 -0.710598 4.945205 -4.42497 1.598342 -0.689642 3.015734 -0.013378 1.942309 1.74866 1.449388 -1.993465 0.216198 0.206771 1.019885 -0.792287 9.77595 4.02258 7.97783 1.92739 11.84128 19.32589 35.2691 59.9177 35.5116 44.8535 82.7216 112.6722 63.0710 27.2892 17.4657 11.37199 48.0923 72.4155 24.4092 68.6235 37.8492 34.5013 6.34233 6.90916 7.45959 0.187842 0.289244 -0.541749 0.331441 0.454638 -0.592451 -0.418977 -0.097669 0.343295 -0.273963 0.030288 0.065711 -0.096598 0.749304 -0.199941 -1.446713 -0.180070 0.031517 0.073919 0.389044 -0.254891 0.565851 -0.553689 -0.687199 0.806391 1.41009 2.10243 1.49546 1.81724 1.57787 2.51707 1.58965 1.19778 1.68512 1.99839 1.22442 2.11664 1.95842 2.05116 1.92832 4.26402 1.73124 1.93269 1.30990 1.44403 2.40381 2.09768 2.34575 2.37907 2.37257 -147.241 100738.1 2218.17 11681580
lbh1.wav 5 90.6031 -24.9371 3.508748 3.725429 -16.5527 -0.560785 -12.7775 -5.15894 -18.4958 -7.77388 -9.87359 -10.90998 -14.1271 -2.56515 -7.19806 1.052037 -8.59144 -13.60587 -1.97708 -7.81405 -4.88712 -9.61995 -5.93121 -4.89385 -11.28697 103.0327 -19.3876 10.50503 9.24160 -6.743129 9.27842 -0.671722 16.6568 0.617492 9.21390 12.9617 16.1150 4.54716 10.44566 6.68312 10.18821 4.66290 10.83665 12.76393 7.25455 11.05301 8.02644 5.90640 3.352272 2.682402 95.8891 -22.0605 8.21944 7.67301 -12.31571 6.47451 -5.44357 4.07826 -4.55842 0.366777 -6.159990 4.609272 -8.77012 2.893195 0.632995 4.453322 -1.542082 4.97523 1.471562 0.256352 0.161108 -2.007258 1.766114 -0.904474 -0.364558 95.4796 -21.9825 7.55724 6.73012 -12.15803 5.45749 -6.10594 4.85777 -5.40424 -0.305290 -1.825756 5.141901 -6.61433 3.147221 0.163579 4.773602 -1.663664 2.698598 2.94953 -0.501293 1.032139 -0.755448 1.109543 -0.692102 -2.391069 18.20947 2.60276 4.99645 4.28298 13.30524 12.25154 16.8844 48.5598 29.1020 26.2717 60.3755 60.8963 32.4542 22.1280 17.2190 10.04074 16.3032 62.1448 27.6535 18.7650 23.2332 29.5563 13.61225 7.28203 23.61819 0.175462 -0.092094 -0.364681 -0.191828 0.351356 -0.418036 -0.398895 0.342405 -1.052382 0.126385 0.774328 -0.483022 0.455546 0.347008 -0.363366 0.499895 -0.109111 -0.615701 0.815549 -0.008381 0.492548 0.282652 -0.361539 0.216075 -0.658139 1.54649 1.93968 1.64720 1.13377 1.42690 1.46721 1.58655 1.61953 3.47386 1.95193 2.03171 2.21253 1.96877 1.47878 1.99429 1.75815 1.70000 2.09352 2.10647 1.93580 2.19375 1.92125 1.88593 1.60599 1.78415 -151.932 104821.4 2200.49 12444723
lbh1.wav 6 89.9008 -26.0484 3.616199 -0.649120 -16.6176 -0.953274 -12.6780 -4.11894 -16.6830 -14.53874 -18.86829 -8.75192 -12.8893 -3.67732 -6.58086 0.112482 -8.16861 -16.06722 -6.73741 -10.61024 -10.90376 -8.77813 -8.26205 -8.79598 -8.11360 98.6294 -19.2680 12.17619 9.16426 -3.045819 11.46143 1.617721 17.7484 2.046696 11.35535 11.2540 19.7886 6.13657 11.35554 6.62364 9.30909 15.66822 10.03604 19.66442 6.03691 10.09713 6.61620 11.31311 0.777775 0.552999 95.3921 -22.9706 8.86392 5.84046 -8.47400 4.99760 -3.09145 2.17767 -7.14939 -0.930770 -2.090865 2.775282 -4.56671 2.071833 1.765321 4.687462 -3.609251 1.32671 3.373781 -2.324122 1.471658 -2.076504 0.264439 -5.576171 -2.615810 94.7115 -22.9839 8.44796 5.82526 -9.17115 4.61437 -5.04646 5.03806 -7.38511 -0.294270 -1.920793 4.038776 -3.97687 2.386958 1.567675 4.344462 -0.984386 1.184168 4.88763 -1.746876 -0.723910 -1.525909 0.899008 -4.808405 -3.096713 11.28983 3.89515 9.66885 8.02368 12.45571 18.42036 22.4212 68.4323 29.6843 56.4839 74.5719 90.6418 36.0513 25.2735 16.0978 8.74542 51.6750 47.0503 65.2081 30.7173 43.0148 31.6863 26.76381 8.40130 6.60060 -0.268107 0.046548 -0.327553 -0.795056 -0.416129 0.239968 -0.374398 0.289208 -0.114678 -0.262651 -0.335499 0.004944 0.035844 0.326408 -0.767571 0.173343 0.911660 -1.167152 0.255700 -0.150533 -0.035544 0.207630 0.250717 0.261163 -0.558334 1.26515 2.07260 1.38725 2.89035 2.75285 1.43943 1.63795 1.26315 2.04048 2.09875 2.14067 1.52786 1.64145 1.66512 2.39295 1.57558 2.91361 4.00075 1.67234 1.63018 1.59892 1.38111 2.52571 1.94267 2.06555 -153.240 100447.1 2170.16 11866218
lbh1.wav 7 89.8210 -24.9751 1.391577 3.106512 -15.5836 -3.914367 -12.7109 -6.21251 -18.7856 -11.56309 -16.69842 -14.40264 -12.8286 -8.84062 -5.17965 -1.329436 -9.71046 -17.18853 -2.67292 -12.28715 -19.98365 -9.25499 -5.93049 -8.67216 -7.60953 97.9465 -19.9355 12.68316 10.33170 -6.603383 10.24475 3.559919 19.5414 2.737400 8.36880 10.5966 14.4799 5.75326 10.92314 8.92082 10.26510 12.02221 13.70293 13.19529 6.83013 9.23960 9.66137 8.42477 0.775471 4.758940 93.5846 -23.1237 8.65550 6.26739 -11.97838 2.80497 -5.33001 4.64841 -4.58244 1.903511 -2.299522 6.899955 -7.78235 2.401106 1.695973 4.130296 -4.540777 -1.54500 3.053603 -5.237232 -1.973249 -0.410622 2.784947 -2.429366 0.132682 94.1198 -23.2119 7.54281 6.47846 -11.87321 3.40157 -5.56841 6.49312 -5.69170 -1.765637 -0.764344 4.764010 -6.00767 1.680705 1.591341 4.093047 -2.724936 0.756711 3.92707 -3.537328 -1.836119 0.653489 2.170752 -3.240975 -0.248579 7.06324 2.29858 10.65759 3.73457 8.43231 16.50790 24.7004 74.5168 43.6115 41.2693 62.9188 76.1955 47.4122 40.6519 18.2476 13.00779 44.5622 82.1294 32.0552 46.2515 65.7245 29.3694 13.38530 6.43581 18.81654 0.128404 0.633985 -0.512450 0.311620 0.450751 -0.100848 0.058241 0.463938 -0.440931 -0.126451 -0.366360 -0.774500 0.437779 -0.317436 0.127648 0.150140 0.804896 -0.228535 0.239391 0.159467 -0.637198 0.037115 -0.582090 -0.556500 -0.444645 1.72386 2.44762 2.22113 2.45359 1.83975 1.95864 1.88904 1.69106 2.12174 1.43494 2.16242 2.55036 1.38679 1.71573 1.77537 1.63779 2.58990 2.11082 1.28241 1.43185 2.81587 2.05945 3.08106 2.61406 1.66365 -146.236 102936.3 2244.38 11878825
lbh1.wav 8 91.6083 -26.5663 5.130964 1.715904 -14.8359 -0.878920 -14.8550 -3.22011 -18.4844 -16.01779 -13.21262 -16.56935 -22.8756 -3.27030 -6.55338 -5.770311 -10.42608 -22.76911 -3.95617 -17.50750 -8.50283 -10.66419 -8.07736 -6.46884 -5.78327 97.4482 -18.5478 11.73117 5.86628 -2.386622 10.24575 -0.305895 18.3725 4.081701 12.32374 11.3725 24.6633 5.24853 15.78048 7.27130 8.03407 8.62464 15.34066 26.13291 8.05207 12.17658 8.26951 5.64873 1.390727 3.619755 94.2916 -23.2418 8.12363 4.65032 -10.16867 3.39470 -4.40447 6.71589 -5.50350 2.409759 3.754447 5.478231 -2.97284 3.526187 0.212617 3.135942 -3.179155 1.03081 3.914791 -7.324113 1.979189 0.638580 2.112428 -0.691224 -1.849694 94.5212 -22.4249 8.21084 4.30631 -9.37124 3.55536 -5.61382 6.76644 -6.11931 0.582149 0.662651 2.694813 -4.93947 4.300329 1.193327 1.415057 -2.093322 0.509191 5.48034 -5.417365 2.205793 0.352119 0.774166 -1.695469 -0.858584 4.01531 6.52491 3.61347 2.44552 15.32320 11.76106 28.1982 62.6250 38.9400 68.2095 68.3225 134.0582 83.5518 33.9289 16.6390 23.25965 31.2705 88.1792 73.3500 54.8816 46.4227 35.0050 18.28010 9.35288 10.51217 0.105899 0.196969 0.145539 -0.462967 0.276913 0.377864 -0.610344 0.172670 -0.450863 -0.543572 -0.468976 0.158185 -0.895461 0.330364 -0.258236 -0.479210 0.294433 -0.977488 1.074925 0.246481 0.029208 -0.258371 -0.708398 -0.396951 0.080467 1.39031 1.70695 1.99608 1.43475 1.66683 2.08101 1.74206 1.30221 2.40533 2.19007 1.69078 2.10998 2.35637 2.03031 1.94225 1.60040 2.04684 4.04841 3.33260 1.88589 1.52915 1.75309 2.20741 1.30271 1.35864 -147.860 102364.3 2202.43 12094509
lbh1.wav 9 95.9272 -25.8456 2.362699 0.546532 -11.6548 0.715787 -14.9249 -1.71180 -14.1993 -12.68833 -15.68986 -13.11013 -15.5785 -5.45818 -6.28157 -3.176199 -10.48578 -9.81833 -2.77559 -17.93121 -4.33479 -6.76071 -5.60528 -6.93987 -5.17938 103.8010 -19.7003 10.61810 6.54328 -1.461361 13.89200 -1.210616 15.6541 7.045336 11.75910 12.4018 13.1242 5.66806 9.50007 6.86772 5.28056 6.15726 9.84183 19.98462 6.69475 17.47028 6.07563 3.34457 2.821428 2.468843 101.3890 -21.9983 6.21208 4.44554 -10.02818 7.52094 -6.66265 4.28544 -1.85558 2.574107 1.254918 -1.739348 -1.32886 0.968793 -1.260141 1.580352 -4.261752 2.90550 2.021466 -1.907220 0.006315 0.390865 -0.603091 -1.912544 -1.188485 100.2296 -22.0203 6.69342 4.49673 -8.72351 7.40381 -7.25813 5.43827 -2.81749 1.084274 0.025482 0.321975 -2.41211 0.861625 -0.721843 0.890199 -2.314275 0.505413 3.73707 -3.232220 3.581995 -0.615591 -0.161946 -1.728867 -1.388505 10.18302 3.06419 6.95909 3.52007 12.70954 20.05137 18.6121 33.1877 30.2907 50.4218 71.1096 83.2824 53.9695 25.4241 14.9258 8.32243 29.0352 53.4700 50.7755 66.4519 50.0295 17.4897 8.06031 12.26384 5.02012 -0.222114 -0.585576 -0.189635 -0.757540 1.181120 -0.149563 -0.205971 0.513031 -0.332417 -0.629224 -0.390195 -0.091712 -0.382068 0.228387 0.453000 0.130539 0.161371 -0.195927 0.995448 -0.468111 0.514071 0.028851 -0.366313 -0.104206 -0.118194 1.14737 2.60832 1.62433 2.32789 2.71407 1.45448 1.73754 1.72081 2.71962 2.33508 1.88482 1.32998 1.57855 1.65091 2.15278 1.42032 1.53051 1.24711 2.76586 1.74294 1.78015 1.49040 1.86682 1.57066 1.93483 -158.022 112518.0 2309.24 13246727
lbh1.wav 10 93.3355 -24.8724 0.692077 5.760192 -11.5486 -0.303201 -16.1887 1.32595 -12.4401 -10.43471 -10.47491 -12.68905 -17.8353 -5.35401 -4.00581 -6.850363 -14.07159 -16.83385 -9.94816 -17.00440 -5.67841 -6.66373 -5.43530 -5.62285 -3.70291 104.2901 -20.7329 8.34961 9.94321 -2.647227 9.48397 0.001321 14.5827 1.869875 7.26941 11.5559 17.8175 12.01608 11.62062 4.68186 6.15581 8.21563 12.02903 14.30628 7.89099 12.67194 10.08147 3.67604 5.658888 3.365225 100.6913 -23.1432 4.69164 6.43346 -9.55104 4.22645 -9.29356 7.05487 -4.25636 -1.202077 -0.303564 2.330734 -6.08170 2.887573 0.943856 -0.075106 -0.474184 1.59595 1.409787 -5.549999 -1.664398 1.294159 -0.761100 -1.252776 -1.554433 100.2019 -23.0248 4.85163 7.21343 -8.64316 4.76264 -8.19094 7.50558 -4.54672 -1.054832 0.730137 3.175242 -4.64405 2.846943 0.378998 0.406688 -2.424311 0.413264 3.23265 -4.533966 2.092914 1.834635 -0.366325 -0.794420 -0.571371 11.62852 2.60316 5.98101 2.03206 9.13023 9.93226 28.8733 21.1915 23.6112 41.6878 43.4176 124.3982 94.9461 17.6109 10.8917 13.49424 49.6353 72.1462 51.1521 42.7684 48.9107 28.8604 8.32559 12.91703 7.02162 -0.495728 0.073927 -0.202207 0.598045 0.751301 0.112719 0.109789 0.198649 -0.395480 -0.075487 0.039773 0.051895 0.347889 0.158006 -0.064208 -0.103040 -0.116980 -0.439665 -0.114474 0.062927 0.426621 0.024626 -0.167290 0.581292 0.391391 2.01096 1.24609 1.54807 1.73100 2.04424 1.68957 1.40804 1.44509 1.64339 1.39687 1.86451 1.36262 1.59633 3.13262 1.08780 2.41386 1.62191 2.11899 1.91130 2.53521 1.26783 1.62545 1.69013 1.92450 1.46384 -155.556 113823.1 2327.49 13279795

Measure structure

warbleR: time-frequency cross-correlation

xcor_feat <- warbleR::cross_correlation(X = detection, bp = c(0, 11), wl = 100)
lbh1.wav-1 lbh1.wav-2 lbh1.wav-3 lbh1.wav-4
lbh1.wav-1 1.000000 0.727906 0.758759 0.727756
lbh1.wav-2 0.727906 1.000000 0.767084 0.789050
lbh1.wav-3 0.758759 0.767084 1.000000 0.782094
lbh1.wav-4 0.727756 0.789050 0.782094 1.000000

Measure structure

warbleR: Dynamic time-warping distances

dtw_feat <- warbleR::freq_DTW(X = detection, bp = c(0, 11), wl = 100)
lbh1.wav-1 lbh1.wav-2 lbh1.wav-3 lbh1.wav-4
lbh1.wav-1 0.0000 21.2264 26.0197 28.0962
lbh1.wav-2 21.2264 0.0000 11.3383 12.2436
lbh1.wav-3 26.0197 11.3383 0.0000 17.7677
lbh1.wav-4 28.0962 12.2436 17.7677 0.0000

Extended selection tables

warbleR’s self contained annotation tables

detect_est <- warbleR::selection_table(X = detection, extended = TRUE)
all selections are OK 
detect_est
Object of class 'extended_selection_table'
* The output of the following call:
warbleR::selection_table(X = detection, extended = TRUE)

Contains: 
*  A selection table data frame with 10 row(s) and 6 columns:
|sound.files | selec|  start|    end|template    | scores|
|:-----------|-----:|------:|------:|:-----------|------:|
|lbh1.wav_1  |     1| 0.0931| 0.2410|lbh1.wav-10 | 0.7403|
|lbh1.wav_2  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.8300|
|lbh1.wav_3  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.7688|
|lbh1.wav_4  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.7234|
|lbh1.wav_5  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.6378|
|lbh1.wav_6  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.6768|
... and 4 more row(s)

* 10 wave object(s) (as attributes): 
lbh1.wav_1, lbh1.wav_2, lbh1.wav_3, lbh1.wav_4, lbh1.wav_5, lbh1.wav_6
... and 4 more

* A data frame (check.results) with 10 rows generated by check_sels() (as attribute)

The selection table was created by element (see 'class_extended_selection_table')
* 1 sampling rate(s) (in kHz): 22.05
* 1 bit depth(s): 16
* Created by warbleR 1.1.32
print(detect_est)
Object of class 'extended_selection_table'
* The output of the following call:
warbleR::selection_table(X = detection, extended = TRUE)

Contains: 
*  A selection table data frame with 10 row(s) and 6 columns:
|sound.files | selec|  start|    end|template    | scores|
|:-----------|-----:|------:|------:|:-----------|------:|
|lbh1.wav_1  |     1| 0.0931| 0.2410|lbh1.wav-10 | 0.7403|
|lbh1.wav_2  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.8300|
|lbh1.wav_3  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.7688|
|lbh1.wav_4  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.7234|
|lbh1.wav_5  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.6378|
|lbh1.wav_6  |     1| 0.1000| 0.2479|lbh1.wav-10 | 0.6768|
... and 4 more row(s)

* 10 wave object(s) (as attributes): 
lbh1.wav_1, lbh1.wav_2, lbh1.wav_3, lbh1.wav_4, lbh1.wav_5, lbh1.wav_6
... and 4 more

* A data frame (check.results) with 10 rows generated by check_sels() (as attribute)

The selection table was created by element (see 'class_extended_selection_table')
* 1 sampling rate(s) (in kHz): 22.05
* 1 bit depth(s): 16
* Created by warbleR 1.1.32

Quantify acoustic spaces

Package PhenotypeSpace

is intended to facilitate the quantification of phenotypic space features.

The package offers functions for:

  • Estimate absolute values of phenotypic spaces
  • Compare trait spaces across groups
  • Modify output formats to facilitate statistical analysis

Quantify acoustic spaces

PhenotypeSpace

# cross correlation
xcor_feat <- warbleR::cross_correlation(X = lbh.est, bp = c(0, 11), wl = 100)

# convert to rectangular matrix
xcor_rect <- PhenotypeSpace::distance_to_rectangular(distance.matrix = as.dist(1 -
    xcor_feat))

# add recording label
xcor_rect$group <- substr(0, 6, x = xcor_rect$labels)

table(xcor_rect$group)

BR2-A1 CCE-I3 LOC-D1 SAT-F1 STR-A2 SUR-E1 SUR-K4 TR1-C2 TR1-C5 TR1-D4 
     5      5      5      5      5      5      5      5      5      5 

Quantify acoustic spaces

Acoustic space:

Quantify acoustic spaces

PhenotypeSpace

# get space
spc_size <- PhenotypeSpace::space_size(formula = group ~ MDS1 + MDS2, data = xcor_rect,
    type = "mst")

spc_size
    group n        size
1  BR2-A1 5 2.09316e-08
2  CCE-I3 5 2.07122e-07
3  LOC-D1 5 1.39886e-08
4  SAT-F1 5 5.37477e-08
5  STR-A2 5 1.00839e-08
6  SUR-E1 5 1.91592e-07
7  SUR-K4 5 1.60775e-08
8  TR1-C2 5 9.07460e-09
9  TR1-C5 5 1.64963e-08
10 TR1-D4 5 6.75295e-08

Quantify acoustic spaces

PhenotypeSpace

# get space
space_sim <- PhenotypeSpace::space_similarity(formula = group ~ MDS1 + MDS2, data = xcor_rect,
    type = "centroid.distance")

# get triangular matrix
triang_sim <- PhenotypeSpace::rectangular_to_triangular(space_sim)

Quantify acoustic spaces

PhenotypeSpace

triang_sim
lbh1.wav-1 lbh1.wav-2 lbh1.wav-3 lbh1.wav-4
lbh1.wav-1 0.0000 21.2264 26.0197 28.0962
lbh1.wav-2 21.2264 0.0000 11.3383 12.2436
lbh1.wav-3 26.0197 11.3383 0.0000 17.7677
lbh1.wav-4 28.0962 12.2436 17.7677 0.0000

Quantify acoustic spaces

Odom. et al. 2021. Eco & Evol

Quantify acoustic spaces

Odom. et al. 2021. Eco & Evol

Dynamic spectrograms

DynaSpec

Acknowledgements

  • Grace-Smith Vidaurre (warbleR)
  • Jorge Elizondo (suwo)
  • Mattew Wilkins (dynaSpec)
  • Tim Wright
  • Cornell Lab of Ornithology

R packages for the behavioral (evolutionary) biologist’s tool kit

 

Marcelo Araya-Salas PhD

Neuroscience Research Center, University of Costa Rica