我制作了以下图表:
现在我的问题是上方和左侧灰色区域中的名称使图形混乱,因此我需要删除它们。有没有简单的方法可以做到这一点?像 ylab() 或 xlab()。
我使用的数据如下所示:
structure(list(Mash_pear = c(0.328239947270445, 0.752207607551684,
0.812118104861163, 0.640824971449627, 0.615568052052443, 0.546635339103089,
0.557460706464288, 0.650480192893698, 0.418044504894929, 0.52962586938499,
0.727805116980878, 0.457751406173336, 0.429785015765779, 0.395830424689082,
0.442222743260579, 0.296983456365718, 0.80883682959008, 0.81208596690244,
0.710216015384062, 0.773625942359682), tRap_pear = c(0.0350096175177328,
0.234255507711743, 0.23714999195134, 0.185536020521134, 0.191585098617356,
0.201402054387186, 0.220911538536031, 0.216072802572045, 0.132247101763063,
0.172753098431029, 0.280795579672784, 0.188134155907737, 0.217454200485912,
0.0696965676717436, 0.233870791415384, 0.0544299934337156, 0.226678897883402,
0.128806853122092, 0.117478493999246, 0.161184511733104), Beeml_pear = c(0.179209909971615,
0.79129167285928, 0.856908302056589, 0.729078080521886, 0.709346164378725,
0.669599784720647, 0.585348196746785, 0.639355942917055, 0.544909349368496,
0.794652394149651, 0.863422091668162, 0.595508977637756, 0.533923256060852,
0.843786110234149, 0.402095177866003, 0.293984533306754, 0.867067527220569,
0.883565060756018, 0.727331622602897, 0.860485005688852), Mash_pear50 = c(0.192474082559755,
0.679726904159742, 0.778564545349054, 0.573745352397321, 0.56633658385284,
0.472559997318901, 0.462635414367878, 0.562128414492567, 0.354624921832056,
0.64532681437697, 0.699503386816393, 0.384318378224603, 0.366299448984722,
0.46938310547208, 0.282831366512569, 0.227004236832775, 0.754840213343737,
0.763285417222461, 0.638421127411269, 0.719475286983103)), .Names = c("Mash_pear",
"tRap_pear", "Beeml_pear", "Mash_pear50"), row.names = c("Aft1",
"Alx3_3418.2", "Alx4_1744.1", "Arid3a_3875.1_v1_primary", "Arid3a_3875.1_v2_primary",
"Arid3a_3875.2_v1_primary", "Arid3a_3875.2_v2_primary", "Arid5a_3770.2_v1_primary",
"Arid5a_3770.2_v2_primary", "Aro80", "Arx_1738.2", "Ascl2_2654.2_v1_primary",
"Ascl2_2654.2_v2_primary", "Asg1", "Atf1_3026.3_v1_primary",
"Atf1_3026.3_v2_primary", "Bapx1_2343.1", "Barhl1_2590.2", "Barhl2_3868.1",
"Barx1_2877.1"), class = "data.frame")
以及我用于绘图的功能:
plotAll<-function(data,size=2, alpha=0.4){
combs <- expand.grid(names(data), names(data))
out <- do.call(rbind, apply(combs, 1, function(x) {
tt <- data[, x]; names(tt) <- c("V1", "V2")
tt <- cbind(tt, id1 = x[1], id2 = x[2])
}))
library(plyr)
df.text=ddply(out[out$id1==out$id2,],.(id1,id2),summarise,
pos=max(V1)-(max(V1)-min(V1))/2)
out[out$id1==out$id2,c("V1","V2")]<-NA
out$labels <- rownames(out)
out$labels<-sapply(out$labels, function(x){
strsplit(x, "_")[[1]][1]
})
fam<-read.table('input/genomic_info_subset.tsv', sep='\t')
idx<-match(out$labels,fam$V1)
newcol<-fam$V4[idx]
newcol<-as.character(newcol)
out$fam<-newcol
ggplot(data = out, aes(x = V2, y = V1)) +
geom_text(data = out[!is.na(out$V1),], aes(label = labels), size=size, alpha=alpha) +
facet_grid(id1 ~ id2,scales="fixed")+
geom_text(data=df.text,aes(pos,pos,label=id1)) + geom_abline( slope=1 ) +
ggtitle("Corralation between measured & calculated affinities") +
ylab("") + xlab("") + theme(panel.grid.minor.x=element_blank(), panel.grid.major.x=element_blank())
#return(out)
}
也许它有facet_grid()
但无法弄清楚我想要的结果要改变什么。