CollapseDuplicateTaxonMRP: Collapses an MRP matrix with duplicate taxa

Description Usage Arguments Details Author(s) See Also Examples

View source: R/CollapseDuplicateTaxonMRP.R

Description

Collapses an MRP matrix with duplicate taxa until all taxa are unique.

Usage

1

Arguments

MRPMatrix

An MRP matrix in the format imported by Claddis::read_nexus_matrix.

Details

Duplicate taxon names are problematic for downstream analysis. Generally speaking users should ensure all OTU names are unique. However, in some cases it might make more sense to collapse the matrix until all taxa are unique. Typically this will involve reducing the row count (unique taxa means fewer taxa), but increasing the character count (duplicate taxa means more unique codings).

This function automates this process and is used internally by the Metatree function, but is also made available for individual use here.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

See Also

For another means by which MRP matrices require collapsing see PisaniMRPPrune.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Build an example matrix:
ExampleMRP <- Claddis::build_cladistic_matrix(
  character_taxon_matrix = matrix(as.character(c(0, 0,
  0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)),
  nrow = 6, dimnames = list(LETTERS[1:6], c()), byrow = TRUE)
)

# Show taxon names are currently unique by inspection:
rownames(ExampleMRP$matrix_1$matrix)

# Now rename taxon F as taxon E:
rownames(ExampleMRP$matrix_1$matrix)[6] <- "E"

# Show taxon E is duplicated by inspection:
rownames(ExampleMRP$matrix_1$matrix)

# Now collapse to just unique taxa using function:
ExampleMRP <- CollapseDuplicateTaxonMRP(ExampleMRP)

# Confirm that matrix has now been collapsed to five unique taxa
# (and four unique characters) by inspection:
ExampleMRP$matrix_1$matrix

graemetlloyd/metatree documentation built on April 29, 2021, 2:32 a.m.