-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added GO aspect convenience methods for #203 #281
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put these in a separate static/non-OO convenience module called something like go_utils
I'd also rename get_ancestors to be something more explicit like get_isa_part_of_ancestors
The logic for any is_X method should be to follow is_a only. Remember there are part-ofs between MF and BP
@cmungall Would |
ontobio/ontol.py
Outdated
""" | ||
### BFO:0000050 = part of | ||
### I assume "subClassOf" = is a? | ||
all_ancestors = self.ancestors(go_term) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call self.ancestors(go_term, reflexive=True)
then you won't have to do all_ancestors.append(go_term)
as the term itself is included in the list of ancestors returned by self.ancestors()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @deepakunni3 ! I'll try that option out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it worked!
ontobio/ontol.py
Outdated
""" | ||
Returns the ancestors from the is_a, part_of relation traversed GO subontology of go_term's ancestors. | ||
|
||
subontology() primarily used here for speed when specifying relations to traverse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a note for discussion - why does calling subontology()
improve speed?
It looks like subontology()
is called every time this method is called. Not sure if there is some caching happening somewhere.
Ideally, the following would achieve the same result:
# for isa_closure
self.ancestors(go_term, relations=['subClassOf'], reflexive=True)
# for isa_partof_closure
self.ancestors(go_term, relations=['subClassOf', 'BFO:0000050'], reflexive=True)
but while testing, I see that the proposed method is more quick at getting ancestors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I figured this out a long time ago so it might've changed (or cache is messing me up), but specifying relations without using subontology
first will calculate the filtered graph using the whole GO ontology rather than just the smaller subset of "all relations" ancestors of a node.
Like, specifiying relations requires looking at edge properties (in ontol.get_filtered_graph()
) whereas not just cares that an edge is there. Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @dustine32
Yes, I see the difference and where the bottleneck is 👍
Cool, thanks for the feedback! I'll reorganize this into a file under I do remember running into the MF-part_of-BP issue for this a while ago, causing MF terms to be erroneously identified as BPs. But I got around it by just asking if it was an MF first, though |
I think these changes are ready to go. I now have this in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Note if you call go_aspect a lot, it could be made more efficient as it does 3 ancestor queries, but we can worry about optimization later
@dustine32 Looks good 👍 Feel free to merge this PR |
Awesome thanks! |
Let me know if these are in the wrong place (
ontol.py
) or they're just, plain wrong.