4 months ago by

University College London Cancer Institute

Hi, it is just a simple barchart or bar-plot. First, create a data-frame that has your GO enrichment terms as rows and count values in a single column, like this:

```
input
GO1 128
GO2 1
GO3 70
GO4 6
GO5 17
GO6 14
GO7 18
GO8 4
GO9 13
GO10 0
GO11 0
GO12 5
GO13 16
GO14 5
GO15 2
GO16 0
GO17 0
GO18 20
GO19 6
GO20 0
GO21 0
GO22 0
GO23 2
GO24 0
GO25 6
GO26 1
GO27 5
GO28 1
GO29 0
GO30 0
GO31 0
GO32 0
GO33 1
```

Then, generate separate barcharts with *lattice* and piece them together on the same panel using *grid* / *gridExtra*:

```
require(lattice)
require(RColorBrewer)
require(rasterVis)
require(gridExtra)
require(grid)
A <- barchart(data.matrix(input[1:15,]), col="black", xlab="Total count", ylab="", pretty=TRUE, scales=list(x=list(cex=1.0, col="black", fontface="bold"), y=list(cex=0.8, labels=rownames(input), col="black", fontface="bold"), xlab=list(cex=2.0), ylab=list(cex=2.0), tck=c(1,0)), aspect="fill")
B <- barchart(data.matrix(input2[1:15,]), col="black", xlab="Total count", ylab="", pretty=TRUE, scales=list(x=list(cex=1.0, col="black", fontface="bold"), y=list(cex=0.8, labels=rownames(input2), col="black", fontface="bold"), xlab=list(cex=2.0), ylab=list(cex=2.0), tck=c(1,0)), aspect="fill")
layout <- cbind(c(1,2))
grid.arrange(layout_matrix=layout, arrangeGrob(A, top=textGrob("A", x=unit(0.05,"npc"), y=unit(0.9,"npc"), just=c("left","top"), gp=gpar(fontsize=32))), arrangeGrob(B, top=textGrob("B", x=unit(0.05,"npc"), y=unit(0.9,"npc"), just=c("left","top"), gp=gpar(fontsize=32))), ncol=1)
```

## ------------------------------------------------------------

For side to side, alter the layout and use ncol=2 to grid.arrange

```
A <- barchart(data.matrix(input), col="black", xlab="Total count", ylab="", pretty=TRUE, scales=list(x=list(cex=1.0, col="black", fontface="bold"), y=list(cex=0.8, labels=rownames(input), col="black", fontface="bold"), xlab=list(cex=2.0), ylab=list(cex=2.0), tck=c(1,0)), aspect="fill")
B <- barchart(data.matrix(input2), col="black", xlab="Total count", ylab="", pretty=TRUE, scales=list(x=list(cex=1.0, col="black", fontface="bold"), y=list(cex=0.8, labels=rownames(input2), col="black", fontface="bold"), xlab=list(cex=2.0), ylab=list(cex=2.0), tck=c(1,0)), aspect="fill")
layout <- cbind(c(1),c(2))
grid.arrange(layout_matrix=layout, arrangeGrob(A, top=textGrob("A", x=unit(0.05,"npc"), y=unit(0.9,"npc"), just=c("left","top"), gp=gpar(fontsize=32))), arrangeGrob(B, top=textGrob("B", x=unit(0.05,"npc"), y=unit(0.9,"npc"), just=c("left","top"), gp=gpar(fontsize=32))), ncol=2)
```