class: center, middle, inverse, title-slide .title[ # Phase II: Using Our Toolbox ] .subtitle[ ## Module 5: SHARK! ] .author[ ### Dr. Christopher Kenaley ] .institute[ ### Boston College ] .date[ ### 2026/10/14 ] --- # In class today <!-- Add icon library --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"> .pull-left[ Today we'll .... - Review WCR6 - Procrustes PGLS ] .pull-right[  ] --- <!-- slide 1 --> ## WCR6 .pull-left[ - To R studio ] --- # Shark question **Does shark body shape differ among habitats after accounting shared ancestry?** Response: Procrustes-aligned landmark coordinates. Predictors: Habitat. Phylogeny: evolutionary relationships among sampled species. --- # Example: Salamander head shape .pull-left[ The bundled `plethspecies` dataset includes landmarks and a phylogeny. **Question: does head shape covary with habitat?** ``` r data(plethspecies) gpa <- gpagen(plethspecies$land, print.progress = FALSE) ``` ] .pull-right[ **Habitat** ``` r hab <- setNames( c("A","B","B","A","B","A","B","A","B"), plethspecies$phy$tip.label) ``` ] --- # The model The test evaluates the **overall shape response**, across coordinates. - `proc.gpls()` `\(\mathbf{Y}=\mathbf{X}\mathbf{B}+\mathbf{E}\)` - **Y:** species × shape-coordinate matrix. - **X:** intercept and predictor columns. - **B:** coefficients describing predicted shape changes. - **E:** residual shape variation with phylogenetic covariance. The function combines a multivariate GLS fit with permutation tests. --- # Implementation `geomorph.data.frame()` ``` r gdf <- geomorph.data.frame( coords=gpa$coords, habitat=hab, phy=plethspecies$phy #just one tree! ) ``` --- # Implementation `proc.gpls()` .pull-left[ ``` r pgls <- procD.pgls( coords ~ hab, phy = phy, data = gdf, iter = 10000, print.progress = F) ``` ] .pull-right[ ``` r anova(pgls) ``` ``` ## ## Analysis of Variance, using Residual Randomization ## Permutation procedure: Randomization of null model residuals ## Number of permutations: 10001 ## Estimation method: Generalized Least-Squares (via OLS projection) ## Sums of Squares and Cross-products: Type I ## Effect sizes (Z) based on F distributions ## ## Df SS MS Rsq F Z Pr(>F) ## hab 1 0.004381 0.0043808 0.10117 0.7879 0.33226 0.3873 ## Residuals 7 0.038921 0.0055602 0.89883 ## Total 8 0.043302 ## ## Call: procD.lm(f1 = coords ~ hab, iter = iter, seed = seed, RRPP = TRUE, ## SS.type = SS.type, effect.type = effect.type, int.first = int.first, ## Cov = Cov, data = data, print.progress = print.progress) ``` ] --- # Rsq: variation accounted for .pull-left[ In this sequential table: `\(R^2_{\mathrm{habitat}}=SS_{\mathrm{habitat}}/SS_{\mathrm{total}}\)` Habitat accounts for **10% of total variation**. This does not mean that shapes differ by 10%. ] .pull-right[ ``` r anova(pgls) ``` ``` ## ## Analysis of Variance, using Residual Randomization ## Permutation procedure: Randomization of null model residuals ## Number of permutations: 10001 ## Estimation method: Generalized Least-Squares (via OLS projection) ## Sums of Squares and Cross-products: Type I ## Effect sizes (Z) based on F distributions ## ## Df SS MS Rsq F Z Pr(>F) ## hab 1 0.004381 0.0043808 0.10117 0.7879 0.33226 0.3873 ## Residuals 7 0.038921 0.0055602 0.89883 ## Total 8 0.043302 ## ## Call: procD.lm(f1 = coords ~ hab, iter = iter, seed = seed, RRPP = TRUE, ## SS.type = SS.type, effect.type = effect.type, int.first = int.first, ## Cov = Cov, data = data, print.progress = print.progress) ``` ]