DAVID functional Analysis and its visualization of GO terms using Bar plot
1
1
Entering edit mode
4.5 years ago

Hello, I have used DAVID tool for the Functional annotation of my data (microarray data) and now i wan to visualize the results of GO term in the form of Bar plots (i have seen the such results from the research paper)reference image from the paper the link contains the image of box plot in the research paper. My question is, 1. Which tools can be used to create such plots or any online tool I have used Revigo tool but it doesn,t give such kind of plots. Any suggestions would be helpful.

Thank you.

DAVID GO term visualization • 6.2k views
ADD COMMENT
2
Entering edit mode
4.5 years ago

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)

tem

------------------------------------------------------------

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)

tempo

ADD COMMENT
0
Entering edit mode

Hello Kevin Blighe,

Thank you sir for the solution. and I'm so sorry that i didn't check your reply. Your answer is very helpful thank so much.

ADD REPLY
0
Entering edit mode

No problem my dear Sir / Madam

ADD REPLY
0
Entering edit mode

Hello,

May I kindly ask you to let me know how can I also add to the above bar chart a vertical red line which shows a threshold (such as for example 0.05 p-value as a threshold of significance). I need to create a bar chart like the attached figure.

I assume that the red line, in the attached image, shows -log10(0.05) threshold which is equal to 1.30103. Am I right? I would highly appreciate if you can let me know how to add this threshold red line to my bar chart. Many thanks.

Bar chart with a red line as threshold

ADD REPLY
0
Entering edit mode

Hey, I presume that you can add a red line via abline(v = ..., col = 'red2', lwd = 2), i.e., after you have already called barplot()

ADD REPLY
0
Entering edit mode

Thank you so much for your guide. As you suggested, I did as below, but faced with the below Error:

A <- barchart(data.matrix(GSEA_data_GO), col="black", xlab="-Log10 (corrected P value)", ylab="", pretty=TRUE, scales=list(x=list(cex=1.0, col="black", fontface="bold"), y=list(cex=0.8, labels=rownames(GSEA_data_GO), col="black", fontface="bold"), xlab=list(cex=2.0), ylab=list(cex=2.0), tck=c(1,0)), aspect="fill")

B <- barchart(data.matrix(GSEA_data_KEGG), col="black", xlab="-Log10 (corrected P value)", ylab="", pretty=TRUE, scales=list(x=list(cex=1.0, col="black", fontface="bold"), y=list(cex=0.8, labels=rownames(GSEA_data_KEGG), 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)

abline(v = 1.30103, col = 'red2', lwd = 2)

Error in barplot.default() : argument "height" is missing, with no default

I would highly appreciate if you can help me what I did wrong and how to solve it to have a vertical line (at 1.30103 x-axis) on both of my bar plots. Many thanks.

ADD REPLY
0
Entering edit mode

Hey, I am not sure... can you paste a sample of data.matrix(GSEA_data_GO)?

I have also tidied my own code in my original answer, which may help for debugging purposes.

ADD REPLY
0
Entering edit mode

Thanks for your reply. I got as below:

    data.matrix(GSEA_data_GO)

      V1  V2
 [1,]  1 128
 [2,] 12   1
 [3,] 23  70
 [4,] 28   6
 [5,] 29  17
 [6,] 30  14
 [7,] 31  18
 [8,] 32   4
 [9,] 33  13
[10,]  2   0
[11,]  3   0
[12,]  4   5
[13,]  5  16
[14,]  6   5
[15,]  7   2
[16,]  8   0
[17,]  9   0
[18,] 10  20
[19,] 11   6
[20,] 13   0
[21,] 14   0
[22,] 15   0
[23,] 16   2
[24,] 17   0
[25,] 18   6
[26,] 19   1
[27,] 20   5
[28,] 21   1
[29,] 22   0
[30,] 24   0
[31,] 25   0
[32,] 26   0
[33,] 27   1

data.matrix(GSEA_data_KEGG)
  V1  V2


[1,]  1  18
 [2,] 12 140
 [3,] 23  30
 [4,] 28   6
 [5,] 29  17
 [6,] 30  55
 [7,] 31  18
 [8,] 32  88
 [9,] 33  13
[10,]  2  40
[11,]  3  30
[12,]  4   5
[13,]  5  24
[14,]  6   5
[15,]  7  10
[16,]  8   0
[17,]  9  10
[18,] 10  20
[19,] 11   6
[20,] 13   0
[21,] 14   0
[22,] 15  20
[23,] 16  33
[24,] 17   0
[25,] 18  60
[26,] 19   1
[27,] 20   5
[28,] 21   1
[29,] 22  10
[30,] 24   0
[31,] 25   5
[32,] 26  68
[33,] 27  18

Thank you.

ADD REPLY
0
Entering edit mode

Oh, but, to what does V1 and V2 relate? If you look at my data-input, I only have a single column of values (the other, comprising the labels Go1, Go2, etc, are set as rownames).

ADD REPLY
0
Entering edit mode

I have a GSEA_data_GO.csv file that has only two columns (without column name). The first column contains the Gene Set Enrichment terms, and second column contains values for each Gene Set Enrichment term. The same for GSEA_data_KEGG.csv file.

I read GSEA_data_GO.csv and GSEA_data_KEGG.csv files into R using:

GSEA_data_GO <- read.csv("GSEA_data_GO.csv", header=FALSE)
GSEA_data_KEGG <- read.csv("GSEA_data_KEGG.csv", header=FALSE)

After loading my datasets into R, when I called for example GSEA_data_GO , I found that R made column names as V1 and V2 for my columns by itself, while I did not have any column names in my csv files.

ADD REPLY
0
Entering edit mode

Okay, then you probably need to do something like:

rownames(GSEA_data_GO) <- GSEA_data_GO[,1]
barchart(GSEA_data_GO[,2], ...)

Also, do you need header=FALSE? Always look inside your files and also look at them after you have read them in. Try to also get into the habit of using the str() function so that you can see how your objects are structured and encoded, which is particularly relevant for data-frames.

ADD REPLY
0
Entering edit mode

Thank you very much for your guide Kevin. I simplified my example as below:

GO <- c("GO10", "GO11", "GO12", "GO13", "GO14", "GO15")
Value <- c(5, 10, 40, 30, 20, 50)
df <- data.frame(GO, Value)
rownames(df1) <- df1[,1]
str(df1)
'data.frame':   6 obs. of  2 variables:
 $ c..GO10....GO11....GO12....GO13....GO14....GO15..: Factor w/ 6 
`levels "GO10","GO11",..: 1 2 3 4 5 6
$ c.5..10..40..30..20..50.                         : num  5 10 40 30 20 50`

A <- barchart(data.matrix(df1[ , 2]), col="black", xlab="-Log10 
(corrected P value)", ylab="", pretty=TRUE, 
scales=list(x=list(cex=1.0, col="black", fontface="bold"), 
y=list(cex=0.8, labels=rownames(GSEA_data_GO), col="black", 
fontface="bold"), xlab=list(cex=2.0), ylab=list(cex=2.0), tck=c(1,0)), 
aspect="fill")

A

and I got the bar chart but in y-axis, instead of having GO10...GO15, I have 1, 2, 3, 4, 5, 6. Also again when I run abline I faced the below error :(

abline(v = 1.30103, col = 'red2', lwd = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new 
has not been called yet

I can not see what is wrong even in a very simple dataset that can not put rownames as y-axis and also can not run abline.

ADD REPLY
0
Entering edit mode

Sorry I sent my reply two times mistakenly.

ADD REPLY

Login before adding your answer.

Traffic: 800 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6