# Create a Type I character costmatrix:
constant_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 0,
character_type = "unordered"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = constant_costmatrix,
n_taxa = 10
)
# Create a Type II character costmatrix:
binary_symmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 1,
character_type = "unordered"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = binary_symmetric_costmatrix,
n_taxa = 10
)
# Create a Type III character costmatrix:
unordered_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 2,
character_type = "unordered"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = unordered_costmatrix,
n_taxa = 10
)
# Create a Type IV character costmatrix:
linear_ordered_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 2,
character_type = "ordered"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = linear_ordered_costmatrix,
n_taxa = 10
)
# Create a Type V character costmatrix:
nonlinear_ordered_costmatrix <- convert_adjacency_matrix_to_costmatrix(
adjacency_matrix = matrix(
data = c(
0, 1, 0, 0,
1, 0, 1, 1,
0, 1, 0, 0,
0, 1, 0, 0
),
nrow = 4,
dimnames = list(0:3, 0:3)
)
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = nonlinear_ordered_costmatrix,
n_taxa = 10
)
# Create a Type VI character costmatrix:
binary_irreversible_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 1,
character_type = "irreversible"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = binary_irreversible_costmatrix,
n_taxa = 10
)
# Create a Type VII character costmatrix:
multistate_irreversible_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 2,
character_type = "irreversible"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = multistate_irreversible_costmatrix,
n_taxa = 10
)
#' # Create a Type VIII character costmatrix:
binary_dollo_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 1,
character_type = "dollo"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = binary_dollo_costmatrix,
n_taxa = 10
)
# Create a Type IX character costmatrix:
multistate_dollo_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 2,
character_type = "dollo"
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = multistate_dollo_costmatrix,
n_taxa = 10
)
# Create a Type X character costmatrix:
multistate_symmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 5,
character_type = "ordered"
)
multistate_symmetric_costmatrix$type <- "custom"
multistate_symmetric_costmatrix$costmatrix <- matrix(
data = c(
0, 1, 2, 3, 2, 3,
1, 0, 3, 2, 1, 2,
2, 3, 0, 3, 2, 1,
3, 2, 3, 0, 1, 2,
2, 1, 2, 1, 0, 1,
3, 2, 1, 2, 1, 0
),
nrow = multistate_symmetric_costmatrix$size,
ncol = multistate_symmetric_costmatrix$size,
byrow = TRUE,
dimnames = list(
multistate_symmetric_costmatrix$single_states,
multistate_symmetric_costmatrix$single_states
)
)
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = multistate_symmetric_costmatrix,
n_taxa = 10
)
# Create a Type XI character costmatrix:
binary_asymmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 1,
character_type = "ordered"
)
binary_asymmetric_costmatrix$type <- "custom"
binary_asymmetric_costmatrix$costmatrix <- matrix(
data = c(
0, 1,
10, 0
),
nrow = binary_asymmetric_costmatrix$size,
ncol = binary_asymmetric_costmatrix$size,
byrow = TRUE,
dimnames = list(
binary_asymmetric_costmatrix$single_states,
binary_asymmetric_costmatrix$single_states
)
)
binary_asymmetric_costmatrix$symmetry <- "Asymmetric"
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = binary_asymmetric_costmatrix,
n_taxa = 10
)
# Create a Type XII character costmatrix:
multistate_asymmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 2,
character_type = "ordered"
)
multistate_asymmetric_costmatrix$type <- "custom"
multistate_asymmetric_costmatrix$costmatrix <- matrix(
data = c(
0, 1, 1,
1, 0, 1,
10, 10, 0
),
nrow = multistate_asymmetric_costmatrix$size,
ncol = multistate_asymmetric_costmatrix$size,
byrow = TRUE,
dimnames = list(
multistate_asymmetric_costmatrix$single_states,
multistate_asymmetric_costmatrix$single_states
)
)
multistate_asymmetric_costmatrix$symmetry <- "Asymmetric"
# Calculate gmax for ten tips:
calculate_gmax(
costmatrix = multistate_asymmetric_costmatrix,
n_taxa = 10
)
Run the code above in your browser using DataLab