Error with package clusterProfiler: "Error in abs(stats) : non-numeric argument to mathematical function"
0
0
Entering edit mode
María • 0
@María-24490
Last seen 3.3 years ago

Hi, this is my first post here I was trying to search for some GO terms with clusterProfile (Bioconductor) for my gene list but this happened (My gene list consists of only log2 fold change values with gene names associated)

BiocManager::install("clusterProfiler")
BiocManager::install("pathview")
BiocManager::install("enrichplot")
library(clusterProfiler)
library(enrichplot)
df = read.table("MiTabla.xls", header=TRUE)

# we want the log2 fold change 
original_gene_list <- df$logFC

# name the vector
names(original_gene_list) <- df$Gene.symbol

# omit any NA values 
gene_list<-na.omit(original_gene_list)

# sort the list in decreasing order (required for clusterProfiler)
gene_list = sort(gene_list, decreasing = TRUE)
MisGO <- gseGO(geneList=gene_list, 
             ont ="BP", 
             keyType = "SYMBOL", 
             minGSSize = 3, 
             maxGSSize = 800, 
             pvalueCutoff = 0.05, 
             verbose = TRUE, 
             OrgDb = organism, 
             pAdjustMethod = "none")
#Error in abs(stats) : non-numeric argument to mathematical function
Bioconductor BIOCOND clusterProfiler • 2.7k views
ADD COMMENT
0
Entering edit mode

What is the result of:

class(gene_list)

It is possible that when the table was loaded the logFC values were read as characters.

ADD REPLY
0
Entering edit mode

Hello,

I had the same problem, you were right, the logFC was for some reason read as characters. This happen in a code I used for months, but after I updated Rstudio and some packages, for some reason the logFC was seen as characters.

To solve it I simply used the as.numeric() function. From your "X" DESeq2/limma table containing your logFC, convert the logFC column to a numeric with the following:

Y <- as.numeric(X$log2FoldChange)

In your code (line 8) it's should be something like:

original_gene_list <- as.numeric(df$logFC)

Good luck, Yann F.

ADD REPLY

Login before adding your answer.

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