Skip to content

Commit

Permalink
update comments, readme, Fig 4, supplemental file naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jzeyl committed Nov 13, 2022
1 parent 334d017 commit f7cb8bd
Show file tree
Hide file tree
Showing 20 changed files with 452 additions and 596 deletions.
Binary file modified .RData
Binary file not shown.
682 changes: 341 additions & 341 deletions .Rhistory

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions Audiograms linked to anatomy.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#run up until line 185, proceed to pgls_resids re headmass
#otherwise unadjusted for head mass proceed past line 185
#For analysis which is adjusted for head mass, run up until line 180,
#then proceed to 'pgls_resids re headmass.R'
#Otherwise, analysis unadjusted for head mass proceeds past line 185

library(ggrepel)
library(ggplot2)
Expand Down Expand Up @@ -151,12 +152,6 @@ limits$binomial[limits$Species=="Mallard duck"]<-"Anas_georgica_georgica"
limits$binomial[limits$Species=="Rock dove"]<-"Columba_livia"#
limits$binomial[limits$Species=="Zebra finch"]<-"Taeniopygia_guttata"

#limits$binomial[limits$Species=="Orange fronted conure"]<-"Aratinga_canicularis"
#limits$binomial[limits$Species=="Lesser scaup"]<-"Aythya_affinis"
#limits$binomial[limits$Species=="Japanese quail"]<-"Coturnix_japonica"
#limits$binomial[limits$Species=="Blue Jay"]<-"Cyanocitta_cristata"
#limits$binomial[limits$Species=="Kea parrot"]<-"Nestor_notabilis"


##################add anatomical data from anatomy df############
limits$TM<-avgdf$TM[match(limits$binomial,avgdf$Binomial)]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Start with _**"Set up data_scl.R".**_ This loads the data and phylogeny. This al

## **To run the pgls between ear structures and audiometric measurements:**

First, _**"Set up data_scl.R"**_ also has to be run to get the data prepared (minus the pgls from those scripts). Next, the scripts in _**"Audiograms linked to anatomy.R"**_ can be run. This creates a 'limits' dataframe with the audiogram metrics, which will be joined with the anatomy dataframes for analysis. Once the limits df is created the _**"pgls_resids re headmass.R"**_ can be used to run the pgls analyses with head mass-corrected values.
First, _**"Set up data_scl.R"**_ also has to be run (up to line 70) to get the data prepared. Next, the scripts in _**"Audiograms linked to anatomy.R"**_ can be run to create a dataframe ('limits') containing the audiogram metrics which will be joined with the morphological data. Once the dataframe is created is created, _**"pgls_resids re headmass.R"**_ can be used to run the pgls analyses with head mass-corrected values. Note that for running analyses at different cut-off levels (35 or 60 dB), the cutoff is specified in the 'Audiograms linked to anatomy.R' file. When switching cut-off levels it is recommended to to empty the environment, modify the cut-off level, and re-rerun all relevant scripts with updated cut-off

<br>

Expand Down
2 changes: 1 addition & 1 deletion Set up data_scl.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ library(tidyr)
library(purrr)


#########Line 73 - scaling intraear##########
#########Line 73 - scaling between ear structures##########
#########Line 173 - scaling vs head mass########

################Set up data############
Expand Down
56 changes: 0 additions & 56 deletions pgls_audiogram.R

This file was deleted.

59 changes: 0 additions & 59 deletions pgls_audiogram_audiom.R

This file was deleted.

14 changes: 1 addition & 13 deletions pgls_audiogram_bh.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#modellist<-pgls_todo_hm
pgls_models_list_bh<-lapply(modellist_bh,pgls_models)#run pgls



#make list of dataframes with the PGLS outputs.
tbllist_audiogram<-list()
for (i in seq_along(pgls_models_list_bh)){#change th 'Model' colume in this as appropriate
Expand All @@ -26,18 +24,8 @@ for(i in seq_along(tbllist_audiogram)){
#identify numeric cols and character cols to apply the significant digits function
character_cols<-unlist(lapply(tbllist_audiogram[[i]], is.character))
numeric_cols <- unlist(lapply(tbllist_audiogram[[i]], is.numeric))# Identify numeric columns
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 2))
#tbllist_audiogram[[i]] <- tbllist_audiogram[[i]][, c(6,11,8:10,7,5,1:4)]#change order of columns
#dplyr::select_if(tbllist_audiogram[[i]], is.numeric)#select only numeric data
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 3))
colnames(tbllist_audiogram[[i]])[6]<-"P.val"#rename b/c flextable doesn't work will with the '>' sign
#tbllist_audiogram[[i]]$Fstat[2:nrow(tbllist_audiogram[[i]])]<-""
#tbllist_audiogram[[i]]$Fstat_numdf[2:nrow(tbllist_audiogram[[i]])]<-""
#tbllist_audiogram[[i]]$Fstat_dendf[2:nrow(tbllist_audiogram[[i]])]<-" "
#tbllist_audiogram[[i]]$Model[2:nrow(tbllist_audiogram[[i]])]<-""
#tbllist_audiogram[[i]]$Lambda[2:nrow(tbllist_audiogram[[i]])]<-""
#tbllist_audiogram[[i]]$Adj_Rsquared[2:nrow(tbllist_audiogram[[i]])]<-""
#tbllist_audiogram[[i]]$AICc[2:nrow(tbllist_audiogram[[i]])]<-""
#row.names(tbllist_audiogram[[i]])<-c()#remove row names
print(tbllist_audiogram[[i]])
}

Expand Down
5 changes: 2 additions & 3 deletions pgls_audiogram_bs.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#Head mass only
#modellist<-pgls_todo_hm

options(scipen = 1000)
pgls_models_list_bs<-lapply(modellist_bs,pgls_models)#run pgls


Expand All @@ -27,7 +26,7 @@ for(i in seq_along(tbllist_audiogram)){
#identify numeric cols and character cols to apply the significant digits function
character_cols<-unlist(lapply(tbllist_audiogram[[i]], is.character))
numeric_cols <- unlist(lapply(tbllist_audiogram[[i]], is.numeric))# Identify numeric columns
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 2))
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 3))
colnames(tbllist_audiogram[[i]])[6]<-"P.val"#rename b/c flextable doesn't work will with the '>' sign
row.names(tbllist_audiogram[[i]])<-c()#remove row names
print(tbllist_audiogram[[i]])
Expand All @@ -42,7 +41,7 @@ flexall<-flextable(audiogrampgls_bs) %>% add_header_lines(
values = "Table X. Models for selection") %>%
bold(i = ~ P.val < 0.05) %>% # select columns add: j = ~ Coefficients + P.val
autofit()
flexall
flexall

#pgls diagnostics

Expand Down
2 changes: 1 addition & 1 deletion pgls_audiogram_hf.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for(i in seq_along(tbllist_audiogram)){
#identify numeric cols and character cols to apply the significant digits function
character_cols<-unlist(lapply(tbllist_audiogram[[i]], is.character))
numeric_cols <- unlist(lapply(tbllist_audiogram[[i]], is.numeric))# Identify numeric columns
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 2))
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 3))
#tbllist_audiogram[[i]] <- tbllist_audiogram[[i]][, c(6,11,8:10,7,5,1:4)]#change order of columns
#dplyr::select_if(tbllist_audiogram[[i]], is.numeric)#select only numeric data
colnames(tbllist_audiogram[[i]])[6]<-"P.val"#rename b/c flextable doesn't work will with the '>' sign
Expand Down
2 changes: 1 addition & 1 deletion pgls_audiogram_lf.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for(i in seq_along(tbllist_audiogram)){
#identify numeric cols and character cols to apply the significant digits function
character_cols<-unlist(lapply(tbllist_audiogram[[i]], is.character))
numeric_cols <- unlist(lapply(tbllist_audiogram[[i]], is.numeric))# Identify numeric columns
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 2))
tbllist_audiogram[[i]]<-cbind(tbllist_audiogram[[i]][,which(character_cols)],signif(tbllist_audiogram[[i]][,which(numeric_cols)], digits = 3))
#tbllist_audiogram[[i]] <- tbllist_audiogram[[i]][, c(6,11,8:10,7,5,1:4)]#change order of columns
#dplyr::select_if(tbllist_audiogram[[i]], is.numeric)#select only numeric data
colnames(tbllist_audiogram[[i]])[6]<-"P.val"#rename b/c flextable doesn't work will with the '>' sign
Expand Down
6 changes: 4 additions & 2 deletions pgls_resids re headmass.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
###Note the dataframe 'limits', created from 'Audiograms linked to anatomy.R'
###is required to run this code


library(patchwork)
library(ggrepel)

###note the dataframe 'limits', created from 'Audiograms linked to anatomy.R'
###is required to run this code

#ensure phylogeny matches dataframe
#remake comparative data frame object with averaged congeners
Expand Down
66 changes: 2 additions & 64 deletions plots/Fig 3. phylogeny all species plot.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#run 'set up data_scl.R up to line 70 before running this script

library(ggplot2)
library(RColorBrewer)
library(ggtree)
Expand Down Expand Up @@ -104,9 +106,6 @@ avgdf %>% dplyr::select(aud_rel) %>%
scale_fill_manual(values = c("white","grey","black"), na.value = "#FFFFFF")


#order level plot




#open up the circle
Expand All @@ -115,64 +114,3 @@ l

ggsave("D:/Analysis_plots/ecolcircle.pdf", width=10, height=10)


#############plot heatmap showing sampling of all auditory traits (supplemental materials)#####333
avgdf$Binomial2<-avgdf$Binomial

avgdf$Binomial3<-gsub("_"," ",avgdf$Binomial2)


library(ggtext)
a<-ggtree(birdtreels) %<+% avgdf + ###########, layout = "circular"
geom_tiplab(aes(label= aud_rel), linesize = 0.01, offset = 30)+
#geom_tiplab(aes(label=paste0('italic(', Binomial2,')')),
# parse=TRUE, linesize = 0.01, offset = 30)+
#geom_text(aes(label = node))+
xlim(NA, 160) +
ylim(NA,140)
a



avgdf$IACN<-ifelse(avgdf$IAC_detail=="",0,1)
avgdf$IBPN<-ifelse(avgdf$IBP_detail=="",0,1)
names(avgdf)

sampled<-avgdf[,c("Head.mass..g.",
"TMtotalarea" ,
"FPtotalarea" ,
"dis_coltip_TMcentroid",
"meanTMangle" ,
"Umbo_distancetoTMplane",
"CAtotalarea" ,
"RWtotalarea" ,
"totalEClength",
"Columella.length.mm" ,
"Columella.volume.mm3" ,
"Behind.TM" ,
"IACN","IBPN" )]/avgdf[,c("Head.mass..g.",
"TMtotalarea" ,
"FPtotalarea" ,
"dis_coltip_TMcentroid",
"meanTMangle" ,
"Umbo_distancetoTMplane",
"CAtotalarea" ,
"RWtotalarea" ,
"totalEClength",
"Columella.length.mm" ,
"Columella.volume.mm3" ,
"Behind.TM" ,
"IACN","IBPN" )]
colnames(sampled)
colnames(sampled)<-seq(1:length(colnames(sampled)))
#current sampling
k2<-gheatmap(a,sampled,
width = 0.4, offset = 0,
color = "black",
low = "white", high = "blue",
colnames = T,
colnames_position = "top",
colnames_angle = 0,
colnames_offset_x = 0,
colnames_offset_y = 5)
k2
Loading

0 comments on commit f7cb8bd

Please sign in to comment.