%% Sexual dimorphism PLOT % This script plots the mean audiograms (+ SEM) separated per sex for % species, for which we measured > 2 ABRs for each sex. It also % plots call frequency ranges for isolation and echolocation calls. clear all; %% Set data up % Load files and define parameters for calls of each species % set this rootpaths to be the folder where you have the data folder. rootpath=('C:\Users\omawe\Desktop\scripts_and_data\'); load([rootpath 'all_levels.mat']); load([rootpath 'all_freqs.mat']); load([rootpath 'Call_freq_ranges.mat']); % set the species names for the species that are compared species2 = {'Saccopteryx_bilineata';'Desmodus_rotundus';'Glossophaga_soricina';... 'Thyroptera_tricolor'}; % define the sex of the different animals per species (1=male, 0=female) sex = {}; sex{1} = [1 1 1 0 0 0 0 1 0 1 1 1]; %S. bilineata sex{3} = [1 1 1 0 0 0]; %G. soricina sex{2} = [0 1 1 1 0 0]; %D. rotundus sex{4} = [0 0 1 0 0 0 1 0 0 1]; %T. tricolor %% read in the species data and plot figure for n = 1:length(species2) % loop for each species spec = species2(n); % read in species name h = 0; % k = 0; % % set up empty structures for later male = []; female = []; tone_fem = []; tone_mal = []; % read in the data for each species speclabel = char(strrep(spec,'_',' ')); load([rootpath char(spec) '_all_heatmaps.mat']); load([rootpath char(spec) '_overall_threshold.mat']); % separate data for males and females into separate structures/matrices for i = 1:length(sex{1,n}) if sex{1,n}(i) == 1 h = h + 1; male(:,h) = thresholds(:,i+1); tone_mal(:,:,h) = avrgheat(:,:,i); else k = k + 1; female(:,k) = thresholds(:,i+1); tone_fem(:,:,k)= avrgheat(:,:,i); end end % to access mean of the species go to column (+1) female(:,k+1) = nanmean(female(:,1:k),2); male(:,h+1) = nanmean(male(:,1:h),2); tone_fem(:,:,k+1) = nanmean(tone_fem(:,:,1:k),3); tone_mal(:,:,h+1) = nanmean(tone_mal(:,:,1:h),3); % to access STD of the species go to column (+2) female(:,k+2) = nanstd(female(:,1:k),0,2); male(:,h+2) = nanstd(male(:,1:h),0,2); % to access SEM of the species go to column (+3) female(:,k+3) = female(:,k+2)/sqrt(k); male(:,h+3) = male(:,h+2)/sqrt(h); % plot the data subplot(2,length(species2)/2,n), shadedErrorBar(all_freqs,male(:,(h+1)),male(:,(h+3)),'-b',1); hold on, shadedErrorBar(all_freqs,female(:,(k+1)),female(:,(k+3)),'-r',1); set(gca,'xscale','log','xtick',[5 10 20 50 100],'ytick',(20:20:110)); axis ([5 120 20 110]); grid on, title({speclabel,[num2str(h) ' males & ' num2str(k) ' females']},'FontAngle', 'italic') % plot echolocation and isolation call ranges into the plot k = find(strcmp(speciesnames, species)); plot(EC_wholeRange(k,:),[100, 100],'k','LineWidth',4); plot(IC_wholeRange(k,:),[103, 103],'r','LineWidth',4); % label the right x- and y-axes if n == 1 || n == 3 ylabel('Tone pip level (dB peSPL)') end if n == 3 || n == 4 xlabel('Frequency (kHz)'); end end