r - Highlight tiles with ggplot2 geom_tile() + geom_point() -
i have following plot looks like:
i'm trying add points in layer using according following code found here
my data frame i'm importing looks this:
residue_id residue_num per_ddg pg9_seq_bool 96 0.00437094862845686 false 97 -0.0026333752377897 false 98 -0.00453070737795937 false 99 -0.0130564560942629 true 100 -0.00578979380922636 false 101 -0.0128130535970934 false 102 -0.0264740211311766 false 103 -0.183036342874782 false 104 -0.00550669729238368 false
and uses following code generate plot:
library(ggplot2) input_ddg <-read.table('per_residue_average.txt',header=t,sep="\t",stringsasfactors=true) input_ddg$pg9_seq_bool[input_ddg$pg9_seq == "true"] <- t input_ddg$pg9_seq_bool[input_ddg$pg9_seq == "false"] <- f pdf("output.pdf") ggplot(input_ddg, aes(residue_id,residue_num,fill=per_ddg) ) + theme_bw() + geom_tile() + geom_point(data=input_ddg,aes(size=ifelse(pg9_seq_bool, "dot", "no_dot"))) + scale_size_manual(values=c(dot=6,no_dot=na))+ scale_fill_gradient2(low="blue", mid="white",high="red", midpoint=-.25, na.value="black") + ylab( "residue number" ) + xlab( "mutation identity") + scale_y_continuous(breaks=96:125,expand=c(0,0))+ scale_x_discrete(expand=c(0,0))+ labs(fill=expression(delta*delta*"g(reu)")) + ggtitle(expression("average"~delta*delta*"g mutations cdr3 position")) + theme( panel.background=element_rect(fill="black"), panel.grid.minor=element_blank(), panel.grid.major=element_blank()) dev.off()
i'm getting error:
error in grid.call.graphics(l_setviewport, pvp, true) : non-finite location and/or size viewport calls: print ... lapply -> fun -> push.vp.viewport -> grid.call.graphics in addition: warning message: removed 461 rows containing missing values (geom_point). execution halted
i have feeling due parsing of true , false ifelse, followed post exactly.
first, don't need replace true , false values t , f in data fram input_ddg
. next, column pg9_seq_bool
can used directly in aes()
of geom_point()
. produce 2 types of points according true/false values. scale_size_manual()
set size 0 false , 6 true. if point size shouldn't appear in legend add argument guide="none"
in scale_size_maual()
.
ggplot(input_ddg, aes(residue_id,residue_num,fill=per_ddg) ) + theme_bw() + geom_tile() + geom_point(aes(size=pg9_seq_bool)) + scale_size_manual(values=c(0,6),guide="none")
Comments
Post a Comment