clusterProfiler icon indicating copy to clipboard operation
clusterProfiler copied to clipboard

Error with Enricher function

Open ambikapokhrel opened this issue 1 year ago • 1 comments

Hi,

I have been trying to run enricher with the predefined list of genes and GO terms. Below is my code.

# Read the file
file <- read.table("Necha3_core_GO", header = TRUE)
head (file)
    ProteinID GOterm

1 1000455 GO:0050660 2 1000455 GO:0016491 3 1000455 GO:0003824 4 1000559 GO:0016491 5 1000559 GO:0010181 6 1000559 GO:0016629

geneid <- (file$ProteinID)
goterm<- (file$GOterm)

TERM2GENE <- split(file$ProteinID, file$GOterm)
enrichment_results <- enricher(geneid,
                               TERM2GENE = TERM2GENE,
                               pAdjustMethod = "BH",
                               pvalueCutoff = 0.05,
                               qvalueCutoff = 0.2)

I am getting error in the enricher code. Error that I am getting is this:

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 1, 25, 2, 29, 4, 11, 8, 6, 5, 9, 3, 15, 16, 17, 202, 12, 31, 28, 7, 18, 20, 410, 630, 760, 81, 107, 19, 14, 692, 10, 23, 44, 33, 32, 21, 41, 34, 46, 30, 26, 89, 13, 233, 24, 182, 203, 167, 73, 39, 76, 253, 138, 157, 205, 36, 43, 282, 690, 104, 35, 444, 1043, 164, 102, 264, 484, 47, 454, 792, 27, 159, 37, 209, 227, 48, 115, 103, 416, 80, 55, 70, 78, 971, 1209, 38, 77, 50, 82, 604, 542, 823, 22, 267, 51, 85, 152, 53, 42, 112, 64, 49, 56, 179, 45

Please help, since I am not able to understand what I did wrong.

ambikapokhrel avatar Jun 26 '24 15:06 ambikapokhrel

Without having access to your input file Necha3_core_GO it is difficult to pinpoint what exactly the cause is of the error.

Yet, based on your code I wonder why you use the function split to generate TERM2GENE. AFAIK the outcome of split is a list, whereas TERM2GENE should be a data.frame with 2 columns (see ?enricher).

Moreover, you could directly use file as input for TERM2GENE; make sure the 1st column contains the GOID, and the 2nd column the gene (and in your case protein) id.

So within enricher use: TERM2GENE = file[ ,c("GOterm","ProteinID") ]

guidohooiveld avatar Jul 01 '24 10:07 guidohooiveld