- converts Z to binary - removes empty columns from Z - confirms tree is a phylo object when using full or distance models - removes tree tips that do not exist in the rows of Z - removes the rows of Z with no corresponding tips in the tree - orders the rows of Z according to the cophenetic function

network_clean(Z, tree = NULL, model.type = c("full", "distance", "affinity"))

Arguments

Z

bipartite interaction matrix. Rows should correspond to species in the tree. There should be no empty columns.

tree

'phylo' object

model.type

Indicate model to use: one of 'full', 'distance', 'affinity'

Value

Returns a list of the cleaned Z and tree objects

Examples

# Simluate a tree and Z matrix
# NOT RUN { tree <- rcoal(50) Z <- matrix(rbinom(50*200, 1, 0.01), nrow=50, ncol=200) Z <- Z[,colSums(Z)>0] rownames(Z) <- tree$tip.label # Clean the network and tree out <- network_clean(Z, tree, model='full') str(out) # }