Last active
August 29, 2015 14:15
-
-
Save aronlindberg/15b86476feefaf0fc452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setwd("/Users/Aron/Dropbox/Projects/dendrogramming/") | |
library(TraMineR) | |
library(dendextend) | |
library(pvclust) | |
set.seed(1L) | |
generate <- read.csv(file = "MEP_R_Generate.csv", header = TRUE) | |
negotiate <- read.csv(file = "MEP_R_Negotiate.csv", header = TRUE) | |
transfer <- read.csv(file = "MEP_R_Transfer.csv", header = TRUE) | |
validate <- read.csv(file = "MEP_R_Validate.csv", header = TRUE) | |
generate_dendrogram <- function(data, name){ | |
row.names(data) <- data$id | |
data.seq <- seqdef(data[2:ncol(data)], right = "DEL") | |
ccost2 <- seqsubm(data.seq, method = "CONSTANT", cval = 2, with.missing=TRUE) | |
data.dist <- seqdist(data.seq, method = "OM", norm = TRUE, sm = ccost2, with.missing=TRUE) | |
rownames(data.dist) <- gsub(name, "", rownames(data.seq)) | |
colnames(data.dist) <- gsub(name, "", rownames(data.seq)) | |
par(mfrow = c(1,1)) | |
result <- pvclust(data.dist, method.dist = "abscor", method.hclust = "ward", nboot=100) | |
# with pvrect | |
# plot(result, main = name) | |
# pvrect(result) | |
# with a dendrogram of pvrect | |
dend <- as.dendrogram(result, edge.root = FALSE) | |
result %>% as.dendrogram(edge.root = FALSE) %>% | |
plot(main = paste("Cluster dendrogram with AU/BP values (%)\n reproduced plot with dendrogram", name)) | |
result %>% text | |
result %>% pvrect | |
} | |
generate_dendrogram(generate, "Generate") | |
generate_dendrogram(negotiate, "Negotiate") | |
generate_dendrogram(transfer, "Transfer") | |
generate_dendrogram(validate, "Validate") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment