TopGO question
1
0
Entering edit mode
Hannah • 0
@4ac6e978
Last seen 3 months ago
United Kingdom

May I have some assistance please? I have performed topGO analysis on a GeoMx DSP dataset. I set the parameters for the significance value and estimate in the code for differentially expressed genes in the topGO analysis, but when I look at the list go 'significant' genes in the TopGO output, some of the genes included aren't actually differentially expressed and are outside of the parameters I set out.

topGO top • 1.1k views
ADD COMMENT
0
Entering edit mode

You need to provide some example code and output that shows what you are seeing.

ADD REPLY
0
Entering edit mode

df <- data.frame( Gene = results2$Gene, PV = results2$Pr(>|t|), Estimate = results2$Estimate ) rownames(df) <- df$Gene

valid_genes <- rownames(df) %in% keys(org.Hs.eg.db, keytype = "SYMBOL") df_filtered <- df[valid_genes, ] cat("Dimensions of filtered data frame:", dim(df_filtered), "\n")

p_values <- df_filtered$PV scores <- df_filtered$Estimate significant_condition <- p_values < 0.05 & abs(scores) > 0.5

filtered_genes <- rownames(df_filtered)[significant_condition] filtered_scores <- scores[significant_condition] filtered_pvalues <- p_values[significant_condition]

filtered_results <- data.frame( Gene = filtered_genes, Score = filtered_scores, PValue = filtered_pvalues ) head(filtered_results)

all_genes <- rownames(df_filtered) geneList <- rep(0, length(all_genes)) names(geneList) <- all_genes geneList[filtered_genes] <- 1

geneSelectionFun <- function(geneList) { return(geneList == 1) }

GOdata <- new("topGOdata", description = "GO Enrichment for Significant Genes", ontology = "BP", allGenes = geneList, geneSelectionFun = geneSelectionFun, annot = annFUN.org, mapping = "org.Hs.eg.db", ID = "SYMBOL")

result <- runTest(GOdata, algorithm = "classic", statistic = "fisher")

enriched_terms <- GenTable(GOdata, classicFisher = result, topNodes = 10)

enriched_terms$classicFisher <- as.character(enriched_terms$classicFisher) enriched_terms$classicFisher[enriched_terms$classicFisher == "< 1e-30"] <- "1e-30" enriched_terms$log_p_value <- -log10(as.numeric(enriched_terms$classicFisher))

go_terms <- AnnotationDbi::select( GO.db, keys = enriched_terms$GO.ID, columns = c("TERM"), keytype = "GOID" )

enriched_terms_full <- merge(enriched_terms, go_terms, by.x = "GO.ID", by.y = "GOID") head(enriched_terms_full)

library(ggplot2)

enriched_terms_full$classicFisher <- as.numeric(enriched_terms_full$classicFisher) enriched_terms_full$log_p_value <- -log10(enriched_terms_full$classicFisher)

genes_in_term <- genesInTerm(GOdata, whichGO = "GO:0002181")[[1]]

interesction<-intersect(filtered_genes,genes_in_term)

ADD REPLY
0
Entering edit mode
@james-w-macdonald-5106
Last seen 14 hours ago
United States

Please note that genesInTerm provides exactly what one might expect a function with that name might provide - the genes that are annotated to a term. You instead want the genes in that node that are also significant. I don't see a function intended to do that directly (under the hood, topGO just uses intersect between the significant genes and the genes in the term). Here is a self-contained example.

> library(topGO)
> example("genesInTerm")
> term.genes <- genesInTerm(GOdata, "GO:0032446")
> term.genes
$`GO:0032446`
 [1] "1651_at"    "1720_at"   
 [3] "1721_g_at"  "1925_at"   
 [5] "1996_s_at"  "31877_at"  
 [7] "33136_at"   "34762_at"  
 [9] "35907_at"   "37228_at"  
[11] "37282_at"   "38414_at"  
[13] "38480_s_at" "38687_at"  
[15] "39855_at"   "40404_s_at"
[17] "40591_at"   "40727_at"  
[19] "41614_at"   "41623_s_at"
[21] "41624_r_at" "838_s_at"  

> sapply(term.genes, function(x) intersect(x, sigGenes(GOdata)))
     GO:0032446  
[1,] "38687_at"  
[2,] "40404_s_at"

> termStat(GOdata, "GO:0032446")
           Annotated Significant
GO:0032446        22           2
           Expected
GO:0032446     3.48

Login before adding your answer.

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