Skip to content

Instantly share code, notes, and snippets.

@timcdlucas
Created March 22, 2016 15:00
Show Gist options
  • Save timcdlucas/781a9c2d03eb144748fa to your computer and use it in GitHub Desktop.
Save timcdlucas/781a9c2d03eb144748fa to your computer and use it in GitHub Desktop.
colourstrips in ggtree
t <- read.nexus('data/Chapter3/fritz2009geographical.tre')
tr1 <- t[[1]]
mat <- data.frame(name = tr1$tip.label)
mat$col1 = 'a'
mat$col1[1:300] <- 'b'
mat$col2 = 'a'
mat$col2[200:300] <- 'b'
mat$col2[300:500] <- 'c'
rownames(mat) <- tr1$tip.label
vec <- mat[,2]
p <- ggtree(tr1)
gheatmap(p, mat[, 2:3], width = 0.03, offset = -1, high = 'red', low = 'blue', colnames = FALSE, color = '00000000')
ggsave('~/Desktop/bars.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment