Skip to content

Commit

Permalink
Backport fix for different simmilarity heatmap where the same values …
Browse files Browse the repository at this point in the history
…would get different colors
  • Loading branch information
reslp committed Sep 5, 2023
1 parent 2a8a223 commit 85007a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/plot-heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ args <- commandArgs(trailingOnly=TRUE)
wd <- args[1]
matrix_file <- args[2]
treelistfile <- args[3]

verbose <- FALSE

setwd(wd)
Expand All @@ -24,6 +23,7 @@ data$X <- NULL
rownames(data) <- colnames(data)
data <- as.matrix(t(data))
mode(data) <- "numeric"
data <- trunc(data*100)/100 #make sure rounding does not cause same numbers with different colors, here (and below) this is hardcoded two 2 decimal places
#data <- melt(data)
#colnames(data) <- c("First", "Second", "Similarity")
#data$First <- factor(data$First, levels=levels(data$Second))
Expand Down Expand Up @@ -55,6 +55,7 @@ if (treelistfile == "none") {
#data$Second <- treelist$V2[match(data$Second, treelist$V1)]
colnames(data) <- treelist$V2[match(colnames(data), treelist$V1)]
rownames(data) <- treelist$V2[match(rownames(data), treelist$V1)]
if (data > 1) {print("Value too large")}
#p <- ggplot(data, aes(First, Second, fill=Similarity)) + geom_tile() + scale_fill_gradient(low = "red", high = "white") + ggtitle("% similarity of pairs of trees") + geom_text(aes(label = format(round(Similarity, roundb), nsmall=2)))+ theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
p <- pheatmap(data, display_numbers=TRUE, number_format = "%.2f", treeheight_col=0, treeheight_row=0, main=paste0("Similarity (percentage of identical quartets of tips) of pairs of ", nrow(data), " trees"))
pdf(file=paste0("quartet-similarity-heatmap-",nrow(data),"-trees.pdf"), width=pwidth, height=pheight)
Expand Down

0 comments on commit 85007a2

Please sign in to comment.