DOI: 10.5061/dryad.76hdr7t1m
title: Sex differences in the song circuit and song acoustic complexity in male and female house wrens

description: In this study, we compared neural song circuit morphology to singing
 behavior recorded in the field for 17 male and 18 female house wrens. The
 acoustic complexity of house wren songs was quantified using a recently
 published machine learning approach. This data set includes recordings of
 all house wren songs used in this analysis along with Raven selection
 tables defining the boundaries of each syllable. This includes 109 female
 songs. R code used to extract acoustic features and estimate element
 diversity and our proxy for song acoustic complexity are included.
 Summaries of acoustic variables for each song and each element are
 provided as well as files necessary to replicate the analysis. For each
 bird, we measured volume, cell number, cell density, and neuron soma size
 for three song circuits, Area X, HVC (used as a proper name), and the
 robust nucleus of the arcopallium (RA), and one control region, the
 nucleus rotundus (Rt). This data set includes these neural morphology
 measurements for each bird as well as R code used to (1) compare males and
 females for each neural measurement and (2) explore the relationship
 between acoustic complexity and neural morphology within each sex.
     
description: Wild house wrens were recorded in the field singing spontaneously
 or in response to playback recordings of male or female house wren songs.
 Songs were clipped from much longer song recordings with 1 second before
 the start and 1 second after the end of the song. No further processing
 occurred. All songs used in this analysis can be found in the
 "songs.zip" file. The start and end of each element in the song
 were defined manually in Raven using both the spectrogram and waveform.
 These boundaries can be found in the .txt file associated with each sound
 file (.wav file) in the "songs.zip" folder.
 Signal-to-noise ratios (SNR) were used to select songs of
 suitable quality for the rest of the analysis. Users can use the
 "snr.and.automatic.frequency.detection.r" script to replicate
 this calculation for all sounds in the "songs.zip" file.  When
 songs with a suitable SNR were selected, we used this same R script to
 automatically detect the frequency boundaries of each element. These were
 then viewed in Raven and corrected for any obvious deviations driven by
 interfering background noise. These final values are included in the .txt
 file for each sound. We then used a machine-learning
 approach to quantify the acoustic complexity of each song. After
 transforming and removing any colinear variables, an unsupervised random
 forest was used to determine which variables best divide the data. This
 results in a dissimilarity matrix for each syllable which was then
 transformed into vectors using classical multidimensional scaling. These
 vectors are "acoustic space" occupied by house wren song
 elements. A 95% minimum convex polygon was then used to determine how much
 acoustic space elements within a single song occupy. Songs that occupy
 more space have a larger range of signal types. This final calculation is
 referred to as element diversity and is our measure of acoustic
 complexity. The "snr.and.automatic.frequency.detection.r" script
 provides the workflow to replicate this acoustic complexity calculation
 starting with the songs and .txt files in the "songs.zip" file.
 Users may also skip earlier steps of this analysis by using the files
 "acoustic.parameters.csv",
 "Transformed.non-colinear.acous.meas.csv" or
 "mds.acoustic.area.points.csv" as described in the
 "README.md" document. 17 male and 18 female
 house wrens were collected, brains were removed, frozen, sectioned, and
 stained, and neural morphology was measured under brightfield microscopy
 to quantify neural morphology in three song control regions, Area X, HVC,
 and RA, and one control region, Rt. Further detailed methods can be found
 in the associated manuscript.  All neural morphology measurements can be
 found in "all.bird.neural.data.csv". The
 "statistics.and.figs.r" script provides the workflow to
 replicate all statistics and figures in the manuscript.  Here we compare
 males and females for each morphology metric and investigate how song
 acoustic complexity relates to neural morphology for each sex
 separately.
description: R can be used to run the code files
 ("acoustic.space.and.ED.calculations",
 "snr.and.automatic.frequency.detection",
 "statistics.and.figs"). These files can also be opened in
 Notepad.  Txt files associated with each sound file can be opened in Raven
 Pro or Raven Lite (free version) to visualize the boundaries of each
 element type. These files can also be opened in any program that can read
 .txt files.  
description: # Sex differences in the song circuit and song acoustic complexity in male
 and female house wrens Wild house wrens were recorded in the field singing
 spontaneously or in response to playback recordings of male or female
 house wren songs. All songs used in this analysis can be found in the
 "songs.zip" file. The start and end of each element in the song
 were defined manually in Raven using both the spectrogram and waveform.
 These boundaries can be found in the .txt file associated with each sound
 file (.wav file) in the "songs.zip" folder. Signal-to-noise
 ratios (SNR) were used to select songs of suitable quality for the rest of
 the analysis. Users can use the
 "snr.and.automatic.frequency.detection.r" script to replicate
 this calculation for all sounds in the "songs.zip" file. When
 songs with a suitable SNR were selected, we used this same R script
 automatically detect the frequency boundaries of each element. These were
 then viewed in Raven and corrected for any obvious deviations driven by
 interfering background noise. These final values are included in the .txt
 file for each sound. We then used a machine learning approach to quantify
 acoustic complexity of each song. After transforming and removing any
 colinear variables, an unsupervised random forest was used to determine
 which variables best divide the data. This results in a dissimilarity
 matrix for each syllable which was then transformed into vectors using
 classical multidimensional scaling. These vectors are "acoustic
 space" occupied by house wren song elements. A 95% minimum convext
 polygon was then used to determine how much acoustic space elements within
 a single song occupy. Songs that occupy more space have a larger range of
 signal types. This final calculation is referred to as element diversity
 and is our measure of acoustic complexity. The
 "snr.and.automatic.frequency.detection.r" script provides the
 workflow to replicate this acoustic complexity calculation starting with
 the songs and .txt files in the "songs.zip" file. Users may also
 skip earlier steps of this analysis by using the files
 "acoustic.parameters.csv",
 "Transformed.non-colinear.acous.meas.csv" or
 "mds.acoustic.area.points.csv" as described below. The
 "song.level.data.csv" provides summary data on all songs used in
 the analysis. 17 male and 18 female house wrens were collected, brains
 were removed, frozen, sectioned, and stained, and neural morphology was
 measured under brightfield microscopy to quantify neural morphology in
 three song control regions, Area X, HVC, and RA, and one control region,
 Rt. Further detailed methods can be found in the associated manuscript.
 All neural morphology measurements can be found in
 "all.bird.neural.data.csv". The
 "statistics.and.figs.r" script provides the workflow to
 replicate all statistics and figures in the mansucript. Here we compare
 males and females for each morphology metric and investigate how song
 acoustic complexity relates to neural morphology for each sex separately.
 ## Description of the data and file structure songs.zip: this zipped
 folder contains songs (.wav files) of each house wren song and selection
 tables (.txt files) used in the analysis. * .wav files: Songs are clipped
 from much longer recordings with 1 second prior to and 1 second after the
 boundaries of each song. No additional modification of the sound files
 occurred. Files are named by song and this notation is used throughout the
 files in this data set. Bird identity is at the beginning of each name
 (e.g. 1B.F.1 is song 1 from bird 1B.F). * .txt files: Each recording has
 an associated .txt file that boundaries of each element in the song. This
 selection table can be opened with the corresponding sound file in Raven
 to visualize these boundaries on the spectrogram and waveform of the
 sound. This file is also needed to run the code below that calculates
 signal-to-noise ratio, automatically detect frequency boundaries, and
 extract other acoustic parameters. \**Begin Time (s): time element begins
 in seconds. Time boundaries were set manually using both the waveform and
 spectrogram with a Hann window with a 50% window overlap and a discrete
 Fourier transform size of 128 samples. \**End Time (s): time element ends
 in seconds. \**Low Freq (Hz): the lowest frequency of the element in Hz.
 These were automatically detected using the
 "snr.and.automatic.frequency.detection.r" code below and then
 visualized in Raven and manually corrected for any deviations driven by
 interfering background noise. \**High Freq (Hz): the highest frequency of
 the element in Hz. Same methods as above. song.level.data.csv: a summary
 document providing information on each song in the data set * Bird: bird
 identity * Sex: bird sex * Year: year bird was recorded and collected *
 Song: individual label for each song. The same labels are used in the
 songs.zip folder and the script files * Recording: label for the original
 recording where each song originated * Start.time: time within this
 recording that the song started * Date: date that each song was recorded *
 Stage.recorded: breeding stage during which song was recorded.\ \** X
 eggs: day that egg was laid.\ \** nest building: stage prior to egg
 laying. Birds may be advertising for mates, engaged in courtship, or
 preparing the nest post-pair-formation.\ \** nestlings: bird has dependent
 nestlings in the nest. post-fledglings: birds has nestlings that recently
 left the nest (fledged) * Context: context during which song was
 recorded.\ \** spontaneous: bird was recorded singing without the use of
 artificial playback recordings\ \** male.play: bird was recorded while a
 male house wren recording was playing \** male.post: bird was recorded
 after it heard male house wren recordings\ \** female.play: bird was
 recorded while a female house wren recording was playing \** female.post:
 bird was recorded after it heard female house wren recordings * Context.2:
 context during which song was recorded.\ \** m: bird was recorded during
 or following playback of male house wren recordings\ \** f: bird was
 recorded during or following playback of female house wren recordings\ \**
 s: bird was recorded singing without the use of artificial playback
 recordings * SNR: signal-to-noise ratio calculated for the song using the
 "snr.and.automatical.frequency.detection.r" script *
 ED.acoustic.space: song element diversity (our proxy for acoustic
 complexity) calculated using the
 "acoustic.space.and.ED.calculation.r" script. This is a measure
 of "acoustic space" occupied by elements in the song
 all.syllable.acoustic.parameters.w.labels.csv: acoustic parameters
 extracted using the 'specan' function in the
 "acoustic.space.and.ED.calculations.r" script with labels added
 to improve the ease of use. * sound.files: the sound file which matches
 the sounds deposited in "song.zip" * sound.files.syll: a unique
 label for each element within each sound file. Used as a label throughout
 the "acoustic.space.and.ED.calculations.r" script workflow *
 song: unique identifier for each song. The same labels are used in the
 "songs.zip" file and throughout the other .csv files * start:
 start time of the element in seconds * end: end time of the element in
 second * top.freq: highest frequency of the element in kHz * bottom.freq:
 lowest frequency of the element in kHz * duration: duration of the element
 in seconds (end-start time) * meanfreq: mean frequency: average requency
 weighted by amplitude in kHz * sd: standard deviation: standard deviation
 of frequency in kHz * freq.median: median frequency: frequency in kHz that
 divides the signal into two intervals of equal energy * freq.Q25: first
 quartile frequency: frequency in kHz that divides the signal into 25% and
 75% energy * freq.Q75: third quartile frequency: frequency in kHz that
 divides the signal in 75% and 25% energy * freq.IQR: interquartile
 frequency range: range in kHz between the first quartile frequency and
 third quartile frequency * time.median: time in seconds that divides the
 signal into two intervals of equal energy * time.Q25: first quartile time:
 time in seconds that divides the signal into 25% and 75% energy *
 time.Q75: third quartile time: time in seconds that divides the signal
 into 75% and 25% energy * time.IQR: interquartile time range: range in
 seconds between the first quartile time and third quartile time * skew:
 asymmetry of the spectrum * kurt: peakedness of the spectrum * sp.ent:
 spectral entropy: the frequency spectrum's energy distribution. Pure
 tones have low values. Noisy sounds have values close to 1 * time.ent:
 time entropy: the time envelop's energy distribution. Pure tones have
 low values. Noisy sounds have values close to 1. * entropy: spectrographic
 entropy: product of time entropy and spectral entopy * sfm: spectral
 flatness: N*(prod(y_i)^(1/N)/sum(y_i)) with y = relative amplitude of the
 i frequency and N = number of frequencies. Similar to spectral entropy.
 Pure tones have low values. Noisy sounds have values close to 1. *
 meandom: average of dominant frequency: average of the frequency of
 highest amplitude measured across the signal * mindom: minimum of dominant
 frequency: lowest value of the frequency of highest amplitude measured
 across the signal * maxdom: maximum of dominant frequency: highest value
 of the frequenc of highest ampliude measured across the signal * dfrange:
 range of dominant frequency: range of the frequency of highest amplitude
 measured across the signal * modindx: modulation index: cumulative
 absolute difference between adjacent measurement of dominant
 frequency/range of the dominant frequency. An unmodulated signal has a
 value of 1. * startdom: start dominant frequency: frequency of highest
 amplitude measured at the start of the signal * enddom: end dominant
 frequency: frequence of highest amplitude measured at the end of the
 signal * dfslope: dominant frequency slope: (end dominant frequency-start
 dominant frequency)/duration (kHz/s) * meanpeakf: mean peak frequency: the
 frequency from the mean frequency specrum that has the highest energy
 acoustic.parameters.csv: data from
 "all.syllable.acoustic.parameters.w.labels.csv" with labels
 removed. Users looking the skip the step that requires uploading sound
 files into R may load this file where prompted in the
 "acoustic.space.and.ED.calculations" and replicate the rest of
 the script. Note that subsequent steps will not work if the file with
 labels is used. Transformed.non-colinear.acous.meas.w.labels.csv:
 extracted acoustic parameters that have been centered, scaled, and Box-Cox
 transformed in preparation for the next step in analysis. Colinear
 variables have also been removed. Labels are included to improve ease of
 use. * same variable labels as
 "all.syllable.acoustic.parameters.w.labels.csv". Values have
 been centered, scaled, and Box-Cox transformed for all variables
 Transformed.non-colinear.acous.meas.csv: data from
 "Transformed.non-colinear.acous.meas.w.labels.csv" with labeled
 removed. Users looking to skip the transformation step may load this file
 where prompted in the "acoustic.space.and.ED.calculations" and
 replicate the rest of the script. Note that subsequent steps will not work
 if the file with labels is used. mds.acoustic.area.points.w.labels.csv:
 Element dissimilarity matrix from the unsupervised random forest
 transformed through class multidimensional scaling. Each element has a set
 of two points that places it in "acoustic space". Elements that
 are closer together in this space are more acoustically similar. Labels
 are included to improve ease of use. Users looking to skip the random
 forest and replicate the element diversity calculations can use this file.
 * id: unique identifier for each element. Elements are listed in the same
 order as they appear in "acoustic.parameters.csv" and
 "Transformed.non-colinear.acous.meas.csv" * labels: sound file
 of the song * bird: bird identity * song: song identity. This column is
 used when calculating average song element diversity. * sex: bird sex *
 X1: first coordinate in acoustic space * X2: second coordinate in acoustic
 space mds.acoustic.area.point.csv: same data as
 "mds.acoustic.area.points.w.labels.csv" without labels. This
 file is produced directly by the script
 "acoustic.space.and.ED.calculations.r" all.bird.neural.data.csv:
 a summary document on each bird in the data set used to perform the
 statistical analyses in the "statistics.and.figs.r" file. *
 Bird: bird identity * Sex: bird sex * Hemisphere: whether the data that
 follow come from the left or right hemisphere of the brain * Year: year
 bird was recorded and collected * Stage.captured: breeding stage during
 which the bird was captured \** prelay: prior to egg laying \** egg:
 female in the pair laid an egg that day \** incub: female in the pair was
 sitting on unhatched eggs. female did not lay a new egg that day \** post
 fledge: offspring from first breeding attempt recently left the nest *
 Date.capture: date bird was collected * Yolking.follicle: whether females
 had yolking follicles when they were collected. This is an indication of
 active breeding condition. * ED.acoustic.space.all.songs: average song
 element diversity for the bird using all songs in the data set. This is
 the response variable used in the manuscript *
 Song.in.acoustic.space.analysis: number of songs from the bird that
 contributed to the formation of acoustic space in the
 "acoustic.space.and.ED.calculation.r". This is the number of
 songs from each bird in the data set. * HVC.volume: estimated volume of
 HVC in mm^3 for that hemisphere * HVC.cell.count: estimated number of
 cells in HVC for that hemisphere * HVC.density: estimated density of cells
 in HVC (cells/mm^3) for that hemisphere * HVC.soma.size: average soma size
 (square micrometers) of 25 neurons for that hemisphere * HVC.avg.vol:
 average of HVC volume for both hemispheres. When one hemisphere was
 missing, just one is used. * HVC.avg.cell.count: average number of HVC
 cells for both hemispheres. When one hemisphere was missing, just one is
 used. * HVC.avg.dens: average density of HVC cells for both hemispheres.
 When one hemisphere was missing, just one is used. * HVC.avg.soma: average
 HVC soma size for both hemispheres. When one hemisphere was missing, just
 one is used. * subsequent columns use the same naming conventions for the
 other regions (Rt, Area X (X), and RA) paired.t.test: data from
 "all.bird.neural.data.csv" re-arranged to facilitate the
 calculation of paired t-tests in the "statistics.and.figs.r" *
 Bird: bird identity * L.HVC.vol: HVC volume (mm^3) in the left hemisphere
 * R.HVC.vol: HVC volume (mm^3) in the right hemisphere * L.HVC.cell:
 number of cells in HVC in the left hemisphere * R.HVC.cell: number of
 cells in HVC in the right hemisphere * L.HVC.dens: density of cells
 (cells/mm^3) in HVC in the left hemisphere * R.HVC.dens: density of cells
 (cells/mm^3) in HVC in the right hemisphere * L.HVC.soma: soma size
 (square micrometers) of cells in HVC in the left hemisphere * R.HVC.soma:
 soma size (square micrometers) of cells in HVC in the right hemisphere *
 subsequent columns use the same naming conventions for the other regions
 (Rt, Area X (X), and RA) ## Sharing/Access information Code in the
 "acoustic.space.and.ED.calculations.r" file was derived code
 previously published under a CC BY 4.0 license: * Keen, Sara (2021):
 Acoustic diversity dataset. figshare. Dataset.
 ## Code/Software
 Script files are listed in the order they were run. Each script includes
 internal annotations further describing details of the workflow.
 snr.and.automatic.frequency.detection.r: R script to calculate
 signal-to-noise ratio (SNR) for each song and automatically detect the
 frequency boundaries of each syllable within the song. *This script was
 run in R version 4.1.2. *required packages: warbleR, Rraven *required
 files: sound file (.wav) and associated .txt selection table for each
 song. Selection tables must share the same name as the .wav files with
 "selection.txt" added to the end (1B.F.1.wav,
 1B.F.1.selections.txt). acoustic.space.and.ED.calculation.r: R script to
 calculate acoustic space and estimate element diversity using an
 unsupervised random forest approach. The resulting measurement is our
 measure of song acoustic complexity in this manuscript. *This script was
 run in R version 4.1.2. *required packages: parallel, vegan, bioacoustics,
 warbleR, Rraven, cluster, Rtsne, randomForest, MASS, fossil, pbapply,
 adehabitatHR, caret, DescTools *required files: users many run the script
 from the beginning by using the sound file (.wav) and associated .txt
 selection table for each song. We have also provided files created during
 the script workflow for users that would like to replicate portions of the
 code (acoustic.parameters.csv, Transformed.non-colinear.acous.meas.csv,
 mds.acoustic.area.points) statistics.and.figs.r: R script to recreate the
 statistical analysis and figures in this manuscript. *This script was run
 in R version 4.1.2. *required packages: car, effsize, Hmisc *required
 files: "all.bird.neural.data.csv",
 "paired.t.test.input.csv"