library(magrittr)
library(higana)
# Load 'go.obo' from http://geneontology.org/page/download-ontology
go <- read_obo("go.obo", c("is_a","part_of"))
# Load 'goa_human.gaf' from http://geneontology.org/page/download-go-annotations
anno <- read_gaf("goa_human.gaf", exclude_evidence="IEA")
go <- go %>%
filter_obsolete() %>%
unite_roots() %>%
annotate(anno) %>%
filter_unannotated() %>%
propagate_annotations() %>%
collapse_redundant_terms(threshold=0.9)
covars <- read.table("covars.tsv")
# Test each term
results <- test_terms("terms.pcs", class ~ sex+age+PC1+PC2+PC3+PC4, covars, go, family=binomial("logit"))
# Print top 10 terms
test <- results$test[order(results$test$p.value),]
print(head(test))