Error when using the showGroupDensity function in topGO
1
1
Entering edit mode
colaneri ▴ 30
@colaneri-7770
Last seen 5.5 years ago
United States

I like to study the distribution of the genes annotated to a GO term of interest. One that is significant enriched in my topGO analysis and for that i use the showGroupDensity function. But I get the following error:

print(showGroupDensity(GOdataUP, goID, ranks = F))
Error in print(showGroupDensity(GOdataUP, goID, ranks = F)) : 
  error in evaluating the argument 'x' in selecting a method for function 'print': Error in factor(group, labels = paste(c("complementary", whichGO), "  (",  : 
  invalid 'labels'; length 2 should be 1 or 0

Can some one help me understand the source of this error?

This is my script:

 

#####resTable is an object with the result of DESeq2 differential expression analysis

algPvalue <-resTable$padj;
names(algPvalue) <- rownames(resTable);
algPvalue <- algPvalue[names(algUP)];

#### algUP is a vector that contain 10,000 genes (background genes and significant genes)

topDiffGenes <- function(algPvalue){
        return(algPvalue < 0.05)
}
GOdataUP <- new( "topGOdata", ontology="BP", allGenes = algUP, geneSel = topDiffGenes, nodeSize=5, annot=annFUN.org, mapping="org.Hs.eg.db", ID = "SYMBOL" )

goID <- topGOResultsUp[80, "GO.ID"]
print(showGroupDensity(GOdataUP, goID, ranks = F))
topGO • 1.5k views
ADD COMMENT
0
Entering edit mode

What happen if you don't use the print(...), do you gt the same error? Which version of topGO are you using?

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

This error is coming from factor, and it is basically saying that this thing called 'group' has no length, and the 'labels' argument has length 2. You can easily replicate this error:

> group <- character(0)
> factor(group, labels = c("a","b"))
Error in factor(group, labels = c("a", "b")) :
  invalid 'labels'; length 2 should be 1 or 0

To track this down we can look at the function body for showGroupDensity:

showGroupDensity <- function(object, whichGO, ranks = FALSE, rm.one = TRUE) {

  groupMembers <- genesInTerm(object, whichGO)[[1]]
 
  allS <- geneScore(object, use.names = TRUE)
  if(rm.one)
    allS <- allS[allS < 0.99]
    
  xlab <- "Gene' score"
  if(ranks) {
    allS <- rank(allS, ties.method = "random")
    xlab <- "Gene's rank"
  }
 
group <- as.integer(names(allS) %in% groupMembers)

And you can easily check this to see where things went wrong, by doing

allS <- geneScore(GOdataUP, use.names = TRUE)
allS <- allS[allS < 0.99]
groupMembers <- genesInTerm(GOdataUP, goID)[[1]]
any(names(allS) %in% groupMembers)

Which I assume will return FALSE, and you can then try to figure out why.

ADD COMMENT

Login before adding your answer.

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