Goterm enrichment analysis
#Preparing the GO frame
annot.vd <- read.csv("/Users/nuriteliash/Documents/GitHub/varroa-virus-networks/data/VdesGOready2.csv")
annot.vd2 <- annot.vd %>%
mutate(evidence = "IEA") %>%
dplyr::select(go_id = GO.ids, evidence, gene = Gene.id)
head(annot.vd2)
## go_id evidence gene
## 1 GO:0005515 IEA 111242787
## 2 GO:0005576 IEA 111242789
## 3 GO:0008061 IEA 111242789
## 4 GO:0006030 IEA 111242789
## 5 GO:0005887 IEA 111242790
## 6 GO:0004872 IEA 111242790
goFrame.vd <-GOFrame(annot.vd2, organism = "Vd")
goAllFrame.vd <-GOAllFrame(goFrame.vd)
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning: Factors converted to character
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning: Factors converted to character
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning: Factors converted to character
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
## Warning in result_fetch(res@ptr, n = n): SQL statements must be issued with
## dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().
gsc.vd <-GeneSetCollection(goAllFrame.vd, setType = GOCollection())
universe.vd <- unique(annot.vd2$gene)
head(universe.vd)
## [1] 111242787 111242789 111242790 111242792 111242797 111242798
# Load the expression and trait data saved in the first part
lnames <- load(file = "/Users/nuriteliash/OneDrive - OIST/Repos/varroa-virus-networks-Local/results/varroa_virus-01-dataInput.RData");
lnames
## [1] "for_modules" "b_viruses_load"
# Load network data saved in the second part.
lnames = load(file = "/Users/nuriteliash/OneDrive - OIST/Repos/varroa-virus-networks-Local/results/Varroa_modules_networkConstruction-auto.RData")
lnames
## [1] "MEs" "moduleLabels" "moduleColors" "geneTree"
# change "salmon" to the name of the desired module, in the first line: [moduleColors=="salmon"], and in the final "write.csv(file = "GO_term_enrichment_**salmon**BP.csv")
ME <- names(for_modules)[moduleColors=="salmon"]
ME_df <- data.frame(gene = ME)
#or change "ME_df" to any table of sets of genes, that i wish to do GO-enrichment analysis:
genes.vd <- unique(ME_df$gene)
head(genes.vd)
## [1] 111242842 111243014 111243199 111244901 111245833 111245960
## 37 Levels: 111242842 111243014 111243199 111244901 111245833 ... 111255254
params.vd <- GSEAGOHyperGParams(name = "Vd_GO_enrichment",
geneSetCollection = gsc.vd,
geneIds = genes.vd,
# when im changing universeGeneIds = *NULL*, then i dont get the warning
universeGeneIds = universe.vd,
ontology = "BP", # change with MF, CC to test all
pvalueCutoff = 0.05,
conditional = F,
testDirection = "over")
## Warning in makeValidParams(.Object): removing geneIds not in universeGeneIds
over.vd <- hyperGTest(params.vd)
#summary(over.vd)
GO_enrich.vd <- as.data.frame(summary(over.vd))
GO_enrich.vd %>%
arrange(Pvalue) %>%
write.csv(file = "/Users/nuriteliash/OneDrive - OIST/Repos/varroa-virus-networks-Local/results/GO_term_magenta_1.csv")