Last updated: 2024-01-18

Checks: 7 0

Knit directory: LocksofLineage/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20231117) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version deb8b60. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/
    Ignored:    data/.DS_Store

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/DichromFromDimorph.Rmd) and HTML (docs/DichromFromDimorph.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
html 9daebee Sarah E Taylor 2024-01-18 Build site.
html b40af97 Sarah E Taylor 2024-01-18 Build site.
html 7da692e Sarah E Taylor 2024-01-18 Build site.
html f07be57 Sarah E Taylor 2024-01-18 Build site.
Rmd db6a803 Sarah E Taylor 2024-01-18 Added Dichromatism from Dimorphism regression analysis
html db6a803 Sarah E Taylor 2024-01-18 Added Dichromatism from Dimorphism regression analysis
html 8f37735 Sarah E Taylor 2024-01-18 Build site.
Rmd 3f30aa2 Sarah E Taylor 2024-01-18 Added Dichromatism from Dimorphism regression analysis

Loading in Data


Phylogenetic tree: mammaltree 

  Number of tips: 5987 
  Number of nodes: 5986 
  Branch lengths:
    mean: 2.680715 
    variance: 24.17565 
    distribution summary:
       Min.     1st Qu.      Median     3rd Qu.        Max. 
  0.0000000   0.5284341   1.3073255   2.9454665 106.6007500 
  No root edge.
  First ten tip labels: X_Shuotherium 
                        X_Pseudotribos
                        X_Asfaltomylos
                        X_Obdurodon
                        Zaglossus_bartoni
                        Zaglossus_bruijnii
                        Zaglossus_attenboroughi
                        Tachyglossus_aculeatus
                        Ornithorhynchus_anatinus
                        X_Teinolophos
  No node labels.
#read in the data
Binary_traits <- read_csv("data/Phylo_Project_Data/Masters_Binary_Traits.csv")
Rows: 244 Columns: 12
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): Family, Genus_names, species_name, subspecies
dbl (8): Sexual_Dimorphism, DM_Head, Natal_Coat, ConD, ConM, ConB, Sexual_Di...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(Binary_traits)
# A tibble: 6 × 12
  Family       Genus…¹ speci…² subsp…³ Sexua…⁴ DM_Head Natal…⁵  ConD  ConM  ConB
  <chr>        <chr>   <chr>   <chr>     <dbl>   <dbl>   <dbl> <dbl> <dbl> <dbl>
1 cercopithec… alleno… nigrov… <NA>          0       0       1     0     0     0
2 cheirogalei… alloce… tricho… <NA>          0       0       0     0     0     0
3 cebidae      alouat… caraya  <NA>          1       1       1     1     0     0
4 cebidae      alouat… guariba <NA>          1       1       1     0     0     0
5 cebidae      alouat… pallia… pallia…       1       0       1     0     0     0
6 cebidae      alouat… pigra   <NA>          0       0       1     0     0     0
# … with 2 more variables: Sexual_Dichromatism <dbl>, DC_Head <dbl>, and
#   abbreviated variable names ¹​Genus_names, ²​species_name, ³​subspecies,
#   ⁴​Sexual_Dimorphism, ⁵​Natal_Coat

Format Data

#combine genus and species names and capitalize first letter
Binary_traits_combined = Binary_traits %>% unite("species",`Genus_names`, `species_name`) %>% mutate(species = str_to_title(species))
head(Binary_traits_combined)
# A tibble: 6 × 11
  Family       species subsp…¹ Sexua…² DM_Head Natal…³  ConD  ConM  ConB Sexua…⁴
  <chr>        <chr>   <chr>     <dbl>   <dbl>   <dbl> <dbl> <dbl> <dbl>   <dbl>
1 cercopithec… Alleno… <NA>          0       0       1     0     0     0       0
2 cheirogalei… Alloce… <NA>          0       0       0     0     0     0       0
3 cebidae      Alouat… <NA>          1       1       1     1     0     0       1
4 cebidae      Alouat… <NA>          1       1       1     0     0     0       1
5 cebidae      Alouat… pallia…       1       0       1     0     0     0       0
6 cebidae      Alouat… <NA>          0       0       1     0     0     0       0
# … with 1 more variable: DC_Head <dbl>, and abbreviated variable names
#   ¹​subspecies, ²​Sexual_Dimorphism, ³​Natal_Coat, ⁴​Sexual_Dichromatism
# prune tree for species in data
species_not_in_tree=setdiff(mammaltree$tip.label, Binary_traits_combined$species)
pruned.tree<-drop.tip(mammaltree,species_not_in_tree)
summary(pruned.tree)

Phylogenetic tree: pruned.tree 

  Number of tips: 236 
  Number of nodes: 235 
  Branch lengths:
    mean: 2.860618 
    variance: 17.84922 
    distribution summary:
       Min.     1st Qu.      Median     3rd Qu.        Max. 
 0.04705822  0.88148050  1.69536613  3.05531386 49.61463191 
  No root edge.
  First ten tip labels: Nycticebus_pygmaeus 
                        Nycticebus_coucang
                        Loris_tardigradus
                        Galagoides_thomasi
                        Galago_matschiei
                        Galago_moholi
                        Galago_senegalensis
                        Galago_gallarum
                        Otolemur_garnettii
                        Otolemur_crassicaudatus
  No node labels.
#prune data for species in tree
data_pruned = Binary_traits_combined %>% filter(species %in% pruned.tree$tip.label)
head(data_pruned)
# A tibble: 6 × 11
  Family       species subsp…¹ Sexua…² DM_Head Natal…³  ConD  ConM  ConB Sexua…⁴
  <chr>        <chr>   <chr>     <dbl>   <dbl>   <dbl> <dbl> <dbl> <dbl>   <dbl>
1 cercopithec… Alleno… <NA>          0       0       1     0     0     0       0
2 cheirogalei… Alloce… <NA>          0       0       0     0     0     0       0
3 cebidae      Alouat… <NA>          1       1       1     1     0     0       1
4 cebidae      Alouat… <NA>          1       1       1     0     0     0       1
5 cebidae      Alouat… pallia…       1       0       1     0     0     0       0
6 cebidae      Alouat… <NA>          0       0       1     0     0     0       0
# … with 1 more variable: DC_Head <dbl>, and abbreviated variable names
#   ¹​subspecies, ²​Sexual_Dimorphism, ³​Natal_Coat, ⁴​Sexual_Dichromatism
#put data into useful form for phylolm
colnames(data_pruned) = gsub(" ", "_", colnames(data_pruned))
data_pruned_rownames = column_to_rownames(data_pruned, var = "species")
head(data_pruned_rownames)
                                     Family subspecies Sexual_Dimorphism
Allenopithecus_nigroviridis cercopithecidae       <NA>                 0
Allocebus_trichotis          cheirogaleidae       <NA>                 0
Alouatta_caraya                     cebidae       <NA>                 1
Alouatta_guariba                    cebidae       <NA>                 1
Alouatta_palliata                   cebidae   palliata                 1
Alouatta_pigra                      cebidae       <NA>                 0
                            DM_Head Natal_Coat ConD ConM ConB
Allenopithecus_nigroviridis       0          1    0    0    0
Allocebus_trichotis               0          0    0    0    0
Alouatta_caraya                   1          1    1    0    0
Alouatta_guariba                  1          1    0    0    0
Alouatta_palliata                 0          1    0    0    0
Alouatta_pigra                    0          1    0    0    0
                            Sexual_Dichromatism DC_Head
Allenopithecus_nigroviridis                   0       0
Allocebus_trichotis                           0       0
Alouatta_caraya                               1       0
Alouatta_guariba                              1       0
Alouatta_palliata                             0       0
Alouatta_pigra                                0       0

Sexual Dichromatism from Sexual Dimorphism Regression

# run phylolm and get summary
SDCfromSDM <- phyloglm(Sexual_Dichromatism ~ Sexual_Dimorphism, data_pruned_rownames, phy = pruned.tree,method="logistic_MPLE")
summary(SDCfromSDM)

Call:
phyloglm(formula = Sexual_Dichromatism ~ Sexual_Dimorphism, data = data_pruned_rownames, 
    phy = pruned.tree, method = "logistic_MPLE")
       AIC     logLik Pen.logLik 
     250.7     -122.4     -119.8 

Method: logistic_MPLE
Mean tip height: 66.17414
Parameter estimate(s):
alpha: 0.1804632 

Coefficients:
                  Estimate   StdErr z.value   p.value    
(Intercept)       -1.48652  0.26220 -5.6694 1.433e-08 ***
Sexual_Dimorphism  2.16530  0.35478  6.1032 1.040e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Note: Wald-type p-values for coefficients, conditional on alpha=0.1804632

sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.2 forcats_1.0.0   stringr_1.5.0   dplyr_1.1.0    
 [5] purrr_1.0.1     readr_2.1.4     tidyr_1.3.0     tibble_3.1.8   
 [9] ggplot2_3.4.1   tidyverse_2.0.0 phylolm_2.6.2   ape_5.7        
[13] workflowr_1.7.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.11         lattice_0.20-45     listenv_0.9.0      
 [4] getPass_0.2-2       ps_1.7.2            rprojroot_2.0.4    
 [7] digest_0.6.30       utf8_1.2.2          parallelly_1.36.0  
[10] R6_2.5.1            evaluate_0.20       httr_1.4.4         
[13] pillar_1.8.1        rlang_1.0.6         rstudioapi_0.14    
[16] whisker_0.4.1       callr_3.7.3         jquerylib_0.1.4    
[19] rmarkdown_2.20      bit_4.0.5           munsell_0.5.0      
[22] compiler_4.2.1      httpuv_1.6.11       xfun_0.41          
[25] pkgconfig_2.0.3     globals_0.16.2      htmltools_0.5.4    
[28] tidyselect_1.2.0    codetools_0.2-18    fansi_1.0.3        
[31] future_1.33.0       crayon_1.5.2        tzdb_0.3.0         
[34] withr_2.5.0         later_1.3.1         grid_4.2.1         
[37] nlme_3.1-160        jsonlite_1.8.4      gtable_0.3.1       
[40] lifecycle_1.0.3     git2r_0.32.0        magrittr_2.0.3     
[43] scales_1.2.1        vroom_1.6.1         future.apply_1.11.0
[46] cli_3.6.0           stringi_1.7.8       cachem_1.0.6       
[49] fs_1.6.1            promises_1.2.1      bslib_0.4.2        
[52] ellipsis_0.3.2      vctrs_0.5.2         generics_0.1.3     
[55] tools_4.2.1         bit64_4.0.5         glue_1.6.2         
[58] hms_1.1.2           processx_3.8.0      parallel_4.2.1     
[61] fastmap_1.1.0       yaml_2.3.7          timechange_0.2.0   
[64] colorspace_2.0-3    knitr_1.42          sass_0.4.5