s.phylo: Species phylogeny generator

View source: R/s.phylo.R

s.phyloR Documentation

Species phylogeny generator

Description

This function generates the phylogeny of species and plots the phylogenetic tree. In particular, given a species-by-site matrix (community), s.phylo:

  • uses the tax_name function to obtain (from the NCBI or ITIS online databases) the genus and family taxa levels of species in the community. If NCBI is used, getting an API key is recommended. See tax_name for more information. NCBI is used as default in this function;

  • uses the phylo.maker function to obtain the phylogeny (an object of class: "phylo") of species in the community using taxa obtained above;

  • computes the phylogenetic distance matrix using the cophenetic.phylo function and the phylogeny obtained above as input;

  • plots the phylogenetic tree using the phylogeny obtained above.

Usage

s.phylo(
  s.data,
  p.d.mat,
  database = "ncbi",
  obs.taxa = FALSE,
  taxa.levels = NULL,
  Obs.data = FALSE,
  phy.d.mat = TRUE,
  phylo.plot = TRUE
)

Arguments

s.data

A species-by-site presence/absence data.frame with entries indicating occurrence (1) and non-occurrence (0) of species in a site. The rows should have species' scientific names following binomial nomenclature, with no initials.

p.d.mat

As for gbsm.

database

The online database used to obtain the taxonomic names (species, genus and family) for a given rank (species list in this function). The options are "ncbi" (default) or "itis".

obs.taxa

A Boolean indicating if taxa.levels should be included in the returned list.

taxa.levels

Species taxa (i.e. a data.frame with species, genus, and family as colnames) used in extracting phylogenetic distance matrix between species. If supplied, taxa.levels won't be computed from online repositories. Taxa provision is highly recommended.

Obs.data

A Boolean indicating if s.data should be included in the returned list.

phy.d.mat

A Boolean indicating if phylogenetic distance matrix should be in the returned list.

phylo.plot

Boolean value indicating if the phylogenetic tree (cluster dendrogram) should be plotted.

Value

Returns a list with the following outputs:

  • s.data:  A data.frame with sites as columns and species as rows.

  • taxa.levels:  A data.frame with the following columns:

    • species:  Species names in s.data.

    • genus:  Genus names of species in s.data.

    • family:  Family names of species in s.data.

  • p.d.matrix:  A symmetric matrix with dimension names as species and entries indicating the phylogenetic distance between any two of them (species).

  • phylo.plot:  A phylogenetic tree (cluster dendrogram) of species in s.data

References

  1. Binomial nomenclature' (2020) Wikipedia. Available at: https://en.wikipedia.org/wiki/Binomial_nomenclature (Accessed: 09 November 2020).

  2. Lagat, V. K., Latombe, G. and Hui, C., 2021b. Dissecting the effects of random encounter versus functional trait mismatching on multi-species co-occurrence and interference with generalised B-spline modelling. DOI: ⁠<To be added>⁠.

Examples

## Not run: 

remotes::install_github("jinyizju/V.PhyloMaker", force = TRUE)
library(V.PhyloMaker)
my.path <- system.file("extdata/gsmdat", package = "msco")
setwd(my.path)
s.data <- get(load("s.data.csv"))
taxa <- get(load("taxa.levels.csv"))

my.s.phylo <- msco::s.phylo(s.data, p.d.mat = NULL, database = "ncbi", obs.taxa=TRUE,
 taxa.levels = taxa, Obs.data=TRUE, phy.d.mat=TRUE, phylo.plot = TRUE)

my.s.data <- my.s.phylo$s.data
my.s.data

my.taxa <- my.s.phylo$taxa.levels
my.taxa

my.p.d.mat <- my.s.phylo$phylogenetic.distance.matrix
my.p.d.mat


## End(Not run)

vitaliskim/msco documentation built on Sept. 29, 2023, 9:22 p.m.