forked from hackseq/hs19-flu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotClades.R
27 lines (24 loc) · 906 Bytes
/
plotClades.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
plotClades <- function(tree, cladelist, show.tip.label=F,trysize="big") {
# get some colours - get length(myclades$nodes) of them
jColors <- c('chartreuse3', 'cornflowerblue', 'darkgoldenrod1', 'peachpuff3',
'mediumorchid2', 'turquoise3', 'wheat4', 'slategray2')
mycols=sample(jColors, length(cladelist$nodes), replace=TRUE)
# define the groups
# define cols
groups=cladelist$clades
if (trysize=="small") {
ecol= edge.color(tree, groups,col=mycols)
plot(tree, edge.color = ecol,no.margin = TRUE, edge.width = 2, show.tip.label= show.tip.label)
} else {
# for bigger trees
tipcols=rep("grey", length(tree$edge[,1]))
for (k in 1:length(groups)) {
thisgroup=groups[[k]]
for (n in 1:length(thisgroup)) {
thisedge=which(tree$edge[,2] == thisgroup[n])
tipcols[thisedge] = mycols[k]
}
}
plot(tree, edge.color=tipcols, show.tip.label=F)
}
}