# Extracts Phylogenetic Island Community Data from Phylogenetic Trees

## Documentation for package ‘DAISIEprep’ version 1.0.1

- DESCRIPTION file.
- User guides, package vignettes and other documentation.
- Package NEWS.

## Help Pages

A B C D E F G I M P R S T U W

## -- A --

add_asr_node_states | Fits a model of ancestral state reconstruction of island presence
add_island_colonist | Adds an island colonists (can be either a singleton lineage or an island clade) to the island community (island_tbl).
add_missing_species | Adds a specified number of missing species to an existing island_tbl at the colonist specified by the species_to_add_to argument given. The species given is located within the island_tbl data and missing species are assigned. This is to be used after 'extract_island_species()' to input missing species.
add_multi_missing_species | Calculates the number of missing species to be assigned to each island clade in the island_tbl object and assigns the missing species to them. In the case that multiple genera are in an island clade and each have missing species the number of missing species is summed. Currently the missing species are assigned to the genus that first matches with the missing species table, however a more biologically or stochastic assignment is in development.
add_outgroup | Add an outgroup species to a given phylogeny.
all_descendants_conspecific | Checks whether all species given in the descendants vector are the same species.
all_endemicity_status | All possible endemicity statuses
any_back_colonisation | Detects any cases where a non-endemic species or species not present on the island has likely been on the island given its ancestral state reconstruction indicating ancestral presence on the island and so is likely a back colonisation from the island to the mainland (or potentially different island). This function is useful if using extraction_method = "min" in 'DAISIEprep::extract_island_species()' as it may brake up a single colonist into multiple colonists because of back-colonisation.
any_outgroup | Checks whether the phylogeny has an outgroup that is not present on the island. This is critical when extracting data from the phylogeny so the stem age (colonisation time) is correct.
any_polyphyly | Checks whether there are any species in the phylogeny that have multiple tips (i.e. multiple subspecies per species) and whether any of those tips are paraphyletic (i.e. are their subspecies more distantly related to each other than to other subspecies or species).
as_daisie_datatable | Converts the 'Island_tbl' class to a data frame in the format of a DAISIE data table (see DAISIE R package for details). This can then be input into 'DAISIEprep::create_daisie_data()' function which creates the list input into the DAISIE ML models.

## -- B --

benchmark | Performance analysis of the extract_island_species() function Uses system.time() for timing for reasons explained here: https://radfordneal.wordpress.com/2014/02/02/inaccurate-results-from-microbenchmark/ # nolint
bind_colonist_to_tbl | Takes an existing instance of an 'Island_tbl' class and bind the information from the instance of an 'Island_colonist' class to it

## -- C --

check_island_colonist | Checks the validity of the Island_colonist class
check_island_tbl | Checks the validity of the Island_tbl class
check_multi_island_tbl | Checks the validity of the Multi_island_tbl class
check_phylo_data | Checks whether \linkS4class{phylo4d} object conforms to the requirements of the DAISIEprep package. If the function does not return anything the data is ready to be used, if an error is returned the data requires some pre-processing before DAISIEprep can be used
coccyzus_phylod | A phylogenetic tree of coccyzus species with endemicity status as tip states.
coccyzus_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.
columbiformes_phylod | A phylogenetic tree of columbiformes species with endemicity status as tip states.
columbiformes_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.
count_missing_species | Reads in the checklist of all species on an island, including those that are not in the phylogeny (represented by NA) and counts the number of species missing from the phylogeny each genus
create_daisie_data | This is a wrapper function for DAISIE::DAISIE_dataprep(). It allows the final DAISIE data structure to be produced from within DAISIEprep. For detailed documentation see the help documentation in the DAISIE package (?DAISIE::DAISIE_dataprep).
create_endemicity_status | Creates a data frame with the endemicity status (either 'endemic', 'nonendemic', 'not_present') of every species in the phylogeny using a phylogeny and a data frame of the island species and their endemicity (either 'endemic' or 'nonendemic') provided.
create_test_phylod | Creates phylod objects.

## -- D --

default_params_doc | Documentation for function in the DAISIEprep package

## -- E --

endemicity_to_sse_states | Convert endemicity to SSE states
extract_asr_clade | Extracts an island clade based on the ancestral state reconstruction of the species presence on the island, therefore this clade can contain non-endemic species as well as endemic species.
extract_biogeobears_ancestral_states_probs | Extract ancestral state probabilities from BioGeoBEARS output
extract_clade_name | Creates a name for a clade depending on whether all the species of the clade have the same genus name or whether the clade is composed of multiple genera, in which case it will create a unique clade name by concatinating the genus names
extract_endemic_clade | Extracts the information for an endemic clade (i.e. more than one species on the island more closely related to each other than other mainland species) from a phylogeny (specifically 'phylo4d' object from 'phylobase' package) and stores it in an 'Island_colonist' class
extract_endemic_singleton | Extracts the information for an endemic species from a phylogeny (specifically 'phylo4d' object from 'phylobase' package) and stores it in in an 'Island_colonist' class
extract_island_species | Extracts the colonisation, diversification, and endemicty data from phylogenetic and endemicity data and stores it in an 'Island_tbl' object
extract_multi_tip_species | Extracts the information for a species (endemic or non-endemic) which has multiple tips in the phylogeny (i.e. more than one sample per species) from a phylogeny (specifically 'phylo4d' object from 'phylobase' package) and stores it in an 'Island_colonist' class
extract_nonendemic | Extracts the information for a non-endemic species from a phylogeny (specifically 'phylo4d' object from 'phylobase' package) and stores it in in an 'island_colonist' class
extract_species_asr | Extracts the colonisation, diversification, and endemicty data from phylogenetic and endemicity data and stores it in an 'Island_tbl' object using the "asr" algorithm that extract island species given their ancestral states of either island presence or absence.
extract_species_min | Extracts the colonisation, diversification, and endemicty data from phylogenetic and endemicity data and stores it in an 'Island_tbl' object using the "min" algorithm that extract island species as the shortest time to the present.
extract_stem_age | Extracts the stem age from the phylogeny when the a species is known to belong to a genus but is not itself in the phylogeny and there are members of the same genus are in the phylogeny. The stem age can either be for the genus (or several genera) in the tree ('stem = "genus"') or use an extraction algorithm to find the stem of when the species colonised the island (stem = "island_presence), either 'min' or 'asr' as in extract_island_species(). When 'stem = "island_presence"' the reconstructed node states are used to determine the stem age.
extract_stem_age_asr | Extracts the stem age from the phylogeny when the a species is known to belong to a genus but is not itself in the phylogeny and there are members of the same genus are in the phylogeny using the 'asr' extraction method
extract_stem_age_genus | Extracts the stem age from the phylogeny when the a species is known to belong to a genus but is not itself in the phylogeny and there are members of the same genus are in the phylogeny
extract_stem_age_min | Extracts the stem age from the phylogeny when the a species is known to belong to a genus but is not itself in the phylogeny and there are members of the same genus are in the phylogeny using the 'min' extraction method

## -- F --

finches_phylod | A phylogenetic tree of finches species with endemicity status as tip states.
finches_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.

## -- G --

GalapagosTrees | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.
get_branching_times | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_branching_times-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_clade_name | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_clade_name-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_clade_type | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_clade_type-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_col_max_age | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_col_max_age-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_col_time | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_col_time-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_extracted_species | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
get_extracted_species-method | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
get_island_tbl | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
get_island_tbl-method | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
get_min_age | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_min_age-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_missing_species | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_missing_species-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_num_phylo_used | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
get_num_phylo_used-method | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
get_species | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_species-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_sse_tip_states | Extract tip states from a phylod object
get_status | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
get_status-method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class

## -- I --

island_colonist | Constructor for Island_colonist
Island_colonist-class | Defines the 'island_tbl' class which is used when extracting information from the phylogenetic and island data to be used for constructing a 'daisie_data_tbl'
island_tbl | Constructor function for 'Island_tbl' class
Island_tbl-class | Defines the 'island_tbl' class which is used when extracting information from the phylogenetic and island data to be used for constructing a 'daisie_data_tbl'
is_back_colonisation | Checks whether species has undergone back-colonisation from
is_duplicate_colonist | Determines if colonist has already been stored in 'Island_tbl' class. This is used to stop endemic clades from being stored multiple times in the island table by checking if the endemicity status and branching times are identical.
is_identical_island_tbl | Checks whether two 'Island_tbl' objects are identical. If they are different comparisons are made to report which components of the 'Island_tbls' are different.

## -- M --

mimus_phylod | A phylogenetic tree of mimus species with endemicity status as tip states.
mimus_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.
multi_extract_island_species | Extracts the colonisation, diversification, and endemicty data from multiple 'phylod' ('phylo4d' class from 'phylobase') objects (composed of phylogenetic and endemicity data) and stores each in an 'Island_tbl' object which are stored in a 'Multi_island_tbl' object.
multi_island_tbl | Constructor function for 'Multi_island_tbl' class
Multi_island_tbl-class | Defines the 'Multi_island_tbl' class which is multiple 'Island_tbl's.
myiarchus_phylod | A phylogenetic tree of myiarchus species with endemicity status as tip states.
myiarchus_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.

## -- P --

plant_phylo | A phylogenetic tree of plant species.
plot_colonisation | Plots a dot plot (cleveland dot plot when include_crown_age = TRUE) of the stem and potentially crown ages of a community of island colonists.
plot_performance | Plots performance results for a grouping variable (prob_on_island or prob_endemic).
plot_phylod | Plots the phylogenetic tree and its associated tip and/or node data
progne_phylod | A phylogenetic tree of progne species with endemicity status as tip states.
progne_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.
pyrocephalus_phylod | A phylogenetic tree of pyrocephalus species with endemicity status as tip states.
pyrocephalus_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.

## -- R --

rm_island_colonist | Removes an island colonist from an 'Island_tbl' object
rm_multi_missing_species | Loops through the genera that have missing species and removes the ones that are found in the missing genus list which have phylogenetic data. This is useful when wanting to know which missing species have not been assigned to the island_tbl using 'add_multi_missing_species()'.
round_up | Rounds numbers using the round up method, rather than the round to the nearest even number method used by the base function 'round'.

## -- S --

select_endemicity_status | Select endemicity status from ancestral states probabilities
sensitivity | Runs a sensitivity analysis to test the influences of changing the data on the parameter estimates for the DAISIE maximum likelihood inference model
setophaga_phylod | A phylogenetic tree of setophaga species with endemicity status as tip states.
setophaga_tree | Phylogenetic trees of the Galapagos bird lineages and sister species on the mainland.
set_branching_times<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_branching_times<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_clade_name<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_clade_name<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_clade_type<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_clade_type<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_col_max_age<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_col_max_age<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_col_time<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_col_time<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_extracted_species<- | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
set_extracted_species<--method | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
set_island_tbl<- | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
set_island_tbl<--method | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
set_min_age<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_min_age<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_missing_species<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_missing_species<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_num_phylo_used<- | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
set_num_phylo_used<--method | Accessor functions for the data (slots) in objects of the 'Island_tbl' class
set_species<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_species<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_status<- | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
set_status<--method | Accessor functions for the data (slots) in objects of the 'Island_colonist' class
sse_states_to_endemicity | Convert SSE states back to endemicity status

## -- T --

translate_status | Takes a string of the various ways the island species status can be and returns a uniform all lower-case string of the same status to make handling statuses easier in other function

## -- U --

unique_island_genera | Determines the unique endemic genera that are included in the island clades contained within the island_tbl object and stores them as a list with each genus only occuring once in the first island clade it appears in

## -- W --

write_biogeobears_input | Write input files for BioGeoBEARS
write_newick_file | Write tree input file for BioGeoBEARS
write_phylip_biogeo_file | Write biogeography input file for BioGeoBEARS