2
高亮的瓷磚,我有以下情節,看起來像:與GGPLOT2 geom_tile()+ geom_point()
我試圖使用根據下面的代碼在另一層加點發現here
我的數據幀我正在進口看起來像這樣:
residue_id residue_num per_ddg pg9_seq_bool
A 96 0.00437094862845686 FALSE
A 97 -0.0026333752377897 FALSE
A 98 -0.00453070737795937 FALSE
A 99 -0.0130564560942629 TRUE
A 100 -0.00578979380922636 FALSE
A 101 -0.0128130535970934 FALSE
A 102 -0.0264740211311766 FALSE
A 103 -0.183036342874782 FALSE
A 104 -0.00550669729238368 FALSE
,並使用下面的代碼來生成情節:
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 for Mutations by CDR3 Position")) +
theme( panel.background=element_rect(fill="black"), panel.grid.minor=element_blank(), panel.grid.major=element_blank())
dev.off()
我得到一個錯誤:
Error in grid.Call.graphics(L_setviewport, pvp, TRUE) :
Non-finite location and/or size for 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
我有一種感覺自己應有的與我的真假的解析與ifelse,但我跟着正好後。
感謝偉大的答案和簡化。 – jwillis0720 2013-05-03 06:39:09
對不起,我必須今天開始工作,以確保它確實工作:) – jwillis0720 2013-05-03 16:31:34