GO.db: why does GOCCCHILDREN$"GO:0005575" work, but not GOCCCHILDREN$go when go="GO:0005575"
2
0
Entering edit mode
9.4 years ago
library("GO.db")
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"
go <- "GO:0005575"
GOCCCHILDREN$go
NULL

If this isn't due to a inane mistake on my part this is absolutely insane behavior.

I need to use a variable to make a general script that extracts the children for every node, like so:

get_hierarchy_data <- function(ontology, root_node, outfile){
  parent_offspring_map <- get_correct_offspring_list(ontology)
  for (node in parent_offspring_map$root_node) {
    print(node)
   # actual code omitted
  }
}

get_correct_offspring_list <- function(ontology){
  if (ontology == "CC"){
    return(GOCCOFFSPRING)
  } else if (ontology == "MF") {
    return(GOMFOFFSPRING)
  } else {
    return(GOBPOFFSPRING)
  }
}
r GO.db • 2.2k views
ADD COMMENT
3
Entering edit mode
9.4 years ago

I guess I'm not sure why you're surprised that this doesn't work, it won't in many languages. You can get around this if you really need to with GOCCCHILDREN[[eval(go)]].

Edit: BTW, you might find this to be informative.

ADD COMMENT
0
Entering edit mode

I kinda had an inkling that that was the problem, and that I had to evaluate the char-vector at runtime, but I thought it couldn't be, since R is supposedly so high level. I guess I have been spoiled by non-blub languages:

Ended up using pyper which pipes to R through Python:

command_template = 'all_children <- GO{ontology}OFFSPRING$"{node}"'
command = command_template.format(ontology=ontology, node=root_node)
r_session(command)
ADD REPLY
0
Entering edit mode
9.4 years ago
library(GO.db)
gmo = as.list(GOMFOFFSPRING)
term = "GO:1903763"

gmo[term]
$`GO:1903763`
[1] "GO:0086020" "GO:0086075" "GO:0086076" "GO:0086077" "GO:0086078"
[6] "GO:0086079"

Must have been some GO.db object strangeness...

ADD COMMENT

Login before adding your answer.

Traffic: 1335 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