'Can I run the "phylosig()" command in multiple columns and expect one outcome?

In today's episode of total despair we're going to try and define the phylogenetic signal for a bunch of traits. The tricky part is that the data frame consists of presence-absence data (meaning 0s and 1s). To explain it even more, imagine a data frame were you study a morphological trait, like the color of the organism. Each organism can have multiple colors, and we have multiple columns to describe that:

Species Col_Red Col_Blue Col_ Yellow Col_Green
Spp1 0 1 1 0
Spp2 1 0 1 1
Spp3 0 1 0 0

We want to explore the phylogenetic signal of the color as a trait and not the phylogenetic signal of each specific color.

Having said all that, the code used to calculate phylogenetic signal (pagel's λ) is written bellow:

library(tidyverse)
library(phytools)

phylosig <- Trait_Data %>%
  as.list() %>%
  lapply(function(trait) {
    names(trait) <- rownames(Trait_Data)
    res <-
      phylosig(Tree, (trait), method = "lambda", test = TRUE)
    
    list(lambda = res$lambda,
         P = res$P)
  }) %>%
  enframe() %>%
  unnest_auto(value)

provided by @danloo

Any ideas on how to calculate the phylogenetic signal of the whole trait, not for the individual characteristics?

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source