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 19 months 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)

# 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,
#Error in abs(stats) : non-numeric argument to mathematical function

Bioconductor BIOCOND clusterProfiler • 909 views
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.

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.