Skip to content
Snippets Groups Projects
Commit 4691eaae authored by CARDENAS GWENDAELLE's avatar CARDENAS GWENDAELLE
Browse files

change of the cophenetic vector

parent e3c33a93
No related branches found
No related tags found
No related merge requests found
......@@ -48,12 +48,12 @@ treediff <- function(trees1, trees2, replicats){
stop("The number of clusters is different between conditions or `replicats' is uncorrect")
}
# Extract the number of pair of the trees
tree_order <- lapply(trees1, "[[", "order")
leaves <- sapply(tree_order, length)
# Get unique values of the number of leaves
leaves <- unique(leaves)
# # Extract the number of pair of the trees
# tree_order <- lapply(trees1, "[[", "order")
# leaves <- sapply(tree_order, length)
#
# # Get unique values of the number of leaves
# leaves <- unique(leaves)
# Merge trees from both conditions
trees <- c(trees1, trees2)
......@@ -66,14 +66,15 @@ treediff <- function(trees1, trees2, replicats){
adist <- as.matrix(adist)
return(adist[upper.tri(adist)])
})
# Fill the cophenetic vector with NA if the number of leaves is different from the max.
if (length(leaves) != 1){
len_max <- choose(max(leaves), 2)
coph_vect <- sapply(coph_vect, FUN = function(col) {
c(col, rep(NA, len_max - length(col)))
})
}
# # Fill the cophenetic vector with NA if the number of leaves is different from the max.
# if (length(leaves) != 1){
# len_max <- choose(max(leaves), 2)
#
# coph_vect <- sapply(coph_vect, FUN = function(col) {
# c(col, rep(NA, len_max - length(col)))
# })
# }
# Compute squeeze factor
outs <- compute_squeeze(coph_vect, replicats)
......@@ -101,6 +102,13 @@ treediff <- function(trees1, trees2, replicats){
compute_squeeze <- function(dist_coph, replicats){
if (class(dist_coph) == "list"){
max_pr <- as.numeric(max(summary(dist_coph)[,1]))
dist_coph <- sapply(dist_coph, FUN = function(col) {
c(col, rep(NA, max_pr - length(col)))
})
}
# Calculate number of clusters
nb_cluster <- ncol(dist_coph)/sum(replicats)
......@@ -172,7 +180,7 @@ compute_pvalue <- function(average_coph, squeezed_var, replicats){
# Calculate the t-statistic
statistics <- numerator / sqrt(denominator)
# Extract the degrees of freedom for the t-distribution
# Extract the degrees of freedom
d0 <- squeezed_var$df.prior
# Calculate the p-value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment