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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| library(ggtree) library(ggtreeExtra) library(ggplot2) library(ggnewscale) library(dplyr) library(tidytree) library(ggstar)
dat <- read.csv("data/microreact/Candida_auris/microreact-project-Candidaauris-data.csv") tr <- read.tree("data/microreact/Candida_auris/microreact-project-Candidaauris-tree.nwk")
countries <- c("Canada", "United States", "Colombia", "Panama", "Venezuela", "France", "Germany", "Spain", "UK", "India", "Israel", "Pakistan", "Saudi Arabia", "United Arab Emirates", "Kenya", "South Africa", "Japan", "South Korea", "Australia")
dat1 <- dat %>% select(c("ID", "COUNTRY", "COUNTRY__colour")) dat1$COUNTRY <- factor(dat1$COUNTRY, levels=countries) COUNTRYcolors <- dat1[match(countries,dat$COUNTRY),"COUNTRY__colour"]
dat2 <- dat %>% select(c("ID", "FCZ", "AMB", "MCF")) dat2 <- reshape2::melt(dat2,id="ID", variable.name="Antifungal", value.name="type") dat2$type <- paste(dat2$Antifungal, dat2$type) dat2$type <- unlist(lapply(dat2$type, function(x)ifelse(grepl("Not_", x), "Susceptible", x))) dat2$Antifungal <- factor(dat2$Antifungal, levels=c("FCZ", "AMB", "MCF")) dat2$type <- factor(dat2$type, levels=c("FCZ Resistant", "AMB Resistant", "MCF Resistant", "Susceptible"))
dat3 <- dat %>% select(c("ID", "ERG11", "FKS1")) %>% reshape2::melt(id="ID", variable.name="point", value.name="mutation") dat3$mutation <- paste(dat3$point, dat3$mutation) dat3$mutation <- unlist(lapply(dat3$mutation, function(x)ifelse(grepl("WT",x), NA,x))) dat3$mutation <- factor(dat3$mutation, levels=c("ERG11 Y132F", "ERG11 K143R", "ERG11 F126L", "FKS1 S639Y/P/F"))
dat4 <- dat %>% select(c("ID", "CLADE")) dat4 <- aggregate(.~CLADE, dat4, FUN=paste, collapse=",") clades <- lapply(dat4$ID, function(x){unlist(strsplit(x,split=","))}) names(clades) <- dat4$CLADE
tr <- groupOTU(tr, clades, "Clade") Clade <- NULL p <- ggtree(tr=tr, layout="fan", open.angle=15, size=0.2, aes(colour=Clade)) + scale_colour_manual( values=c("black","#69B920","#9C2E88","#F74B00","#60C3DB"), labels=c("","I", "II", "III", "IV"), guide=guide_legend(keywidth=0.5, keyheight=0.5, order=1, override.aes=list(linetype=c("0"=NA, "Clade1"=1, "Clade2"=1, "Clade3"=1, "Clade4"=1 ) ) ) ) + new_scale_colour()
p1 <- p %<+% dat1 + geom_tippoint(aes(colour=COUNTRY), alpha=0) + geom_tiplab(aes(colour=COUNTRY), align=TRUE, linetype=3, size=1, linesize=0.2, show.legend=FALSE ) + scale_colour_manual( name="Country labels", values=COUNTRYcolors, guide=guide_legend(keywidth=0.5, keyheight=0.5, order=2, override.aes=list(size=2,alpha=1)) )
p2 <- p1 + geom_fruit( data=dat2, geom=geom_tile, mapping=aes(x=Antifungal, y=ID, fill=type), width=0.1, color="white", pwidth=0.1, offset=0.15 ) + scale_fill_manual( name="Antifungal susceptibility", values=c("#595959", "#B30000", "#020099", "#E6E6E6"), na.translate=FALSE, guide=guide_legend(keywidth=0.5, keyheight=0.5, order=3 ) ) + new_scale_fill()
p3 <- p2 + geom_fruit( data=dat3, geom=geom_star, mapping=aes(x=mutation, y=ID, fill=mutation, starshape=point), size=1, starstroke=0, pwidth=0.1, inherit.aes = FALSE, grid.params=list( linetype=3, size=0.2 )
) + scale_fill_manual( name="Point mutations", values=c("#329901", "#0600FF", "#FF0100", "#9900CC"), guide=guide_legend(keywidth=0.5, keyheight=0.5, order=4, override.aes=list(starshape=c("ERG11 Y132F"=15, "ERG11 K143R"=15, "ERG11 F126L"=15, "FKS1 S639Y/P/F"=1), size=2) ), na.translate=FALSE, ) + scale_starshape_manual( values=c(15, 1), guide="none" ) + theme( legend.background=element_rect(fill=NA), legend.title=element_text(size=7), legend.text=element_text(size=5.5), legend.spacing.y = unit(0.02, "cm") ) p3
|