Lets say i have the following graph:
And i only want to select the 2nd graph of the first row. How can i do this with ggplot function as below:
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, colour=fam), 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())
}
So can i say somewhere in the code, select only the 2nd of 1st row? or is it more easy to just extract the data frame out of the function and than plot 1 separate? I know that this function is inappropriate for reproducing my question, if this really is neccecary i will provide the .tsv and dput the data.