This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Iterate over go terms in go hierachies "BP", "MF", "CC"

I'd like to do something like the following (example in python, but I'm guessing R is what I'll have to use):

for go_hierarchy in ["BP", "CC", "MF", "KEGG"]:
    for go_category in go_hierarchy:
             pass

The R GOstats package has a function that does almost exactly what I want, namely GOMFCHILDREN

It can be used like shown below to get all child terms for a term:

library("GO.db")

GOMFCHILDREN$"GO:0003700"
        is_a         is_a         is_a         is_a         is_a         is_a
"GO:0000981" "GO:0001010" "GO:0001011" "GO:0001034" "GO:0001073" "GO:0001130"
        is_a         is_a         is_a         is_a
 "GO:0001142" "GO:0001167" "GO:0001199" "GO:0098531"

Problem is, it does not work for hierarchies:

GOMFCHILDREN$"MF"
NULL
GOMFCHILDREN$"GO:MF"
NULL

How do I get all the top level terms in a hierarchy?

gene-ontology go

2 answers

  • GO:0003674 is the MF root.
  • GO:0005575 is the CC root.
  • GO:0008150 is the BP root.

So just use

library("GO.db")

GOBPCHILDREN$"GO:0008150"
       is_a         is_a         is_a         is_a         is_a         is_a
"GO:0009055" "GO:0000988" "GO:0001071" "GO:0003824" "GO:0004872" "GO:0005085"
       is_a         is_a         is_a         is_a         is_a         is_a
"GO:0045735" "GO:0005198" "GO:0005215" "GO:0005488" "GO:0031386" "GO:0016015"
       is_a         is_a         is_a         is_a         is_a         is_a
"GO:0016209" "GO:0016247" "GO:0016530" "GO:0030234" "GO:0030545" "GO:0036370"
       is_a         is_a         is_a         is_a
"GO:0042056" "GO:0045182" "GO:0045499" "GO:0060089"

GOCCCHILDREN$"GO:0005575"
        is_a         is_a         is_a         is_a         is_a         is_a
"GO:0016020" "GO:0005576" "GO:0005581" "GO:0005623" "GO:0009295" "GO:0019012"
        is_a         is_a         is_a         is_a         is_a         is_a
"GO:0030054" "GO:0031012" "GO:0031974" "GO:0032991" "GO:0039679" "GO:0043226"
        is_a         is_a         is_a         is_a         is_a         is_a
"GO:0044420" "GO:0044421" "GO:0044422" "GO:0044423" "GO:0044425" "GO:0044456"
        is_a         is_a         is_a         is_a
"GO:0044464" "GO:0045202" "GO:0055044" "GO:0097423"

etc.

FYI... we have a FREE dedicated search tool called iBioGuide. You can input the GO term or GO ID and it will return all the parent and children terms for easy searching along with diagrams and annotated genes. You might find it useful.

Here is your search query using the GO ID: 0003700: https://ibioguide.advaitabio.com/goterms/43468

Log in to answer this question.