我有以下情节,如下所示:
我正在尝试根据此处找到的以下代码在另一层中添加点
我正在导入的数据框如下所示:
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 解析了 TRUE 和 FALSE,但我完全按照帖子进行了操作。