YuLab-SMU / clusterProfiler

:bar_chart: A universal enrichment tool for interpreting omics data
https://yulab-smu.top/biomedical-knowledge-mining-book/
1.02k stars 256 forks source link

"400 Bad Request" using enrichKEGG function from the clusterProfiler #706

Open RouaPopescu opened 3 months ago

RouaPopescu commented 3 months ago

Hello, I am encountering an error when using the enrichKEGG function from the clusterProfiler package with my own created library for Klebisella pneumoniae subsp. pneumoniae HS11286 (taxid: 1125630). Below is an example demonstrating the issue: `library(clusterProfiler) ids<-bitr(names(original_gene_list), fromType = "SYMBOL", toType = "ENTREZID", OrgDb=organism) # remove duplicate IDS (here I use "ENSEMBL", but it should be whatever was selected as keyType) dedup_ids = ids[!duplicated(ids[c("SYMBOL")]),] df2 = pstexp2[pstexp2$Gene.symbol %in% dedup_ids$SYMBOL,] df2$Y = dedup_ids$ENTREZID kegg_gene_list <- df2$logFC names(kegg_gene_list) <- df2$Y kegg_gene_list<-na.omit(kegg_gene_list) kegg_gene_list = sort(kegg_gene_list, decreasing = TRUE) kegg_sig_genes_df = subset(df2, df2$adj.P.Val < 0.05) kegg_genes <- kegg_sig_genes_df$logFC names(kegg_genes) <- kegg_sig_genes_df$Y kegg_genes <- na.omit(kegg_genes) kegg_genes <- names(kegg_genes)[abs(kegg_genes) > 0.05]

kegg_organism = "kpm" kk <- enrichKEGG(gene=kegg_genes, universe=names(kegg_gene_list),organism=organism, pvalueCutoff = 0.05, keyType = "ncbi-geneid")`

The following is my error message: Reading KEGG annotation online: "https://rest.kegg.jp/link/org.Kpm.eg.db/pathway"... Error in file(con, "r") : cannot open the connection to 'https://rest.kegg.jp/link/org.Kpm.eg.db/pathway' In addition: Warning message: In file(con, "r") : cannot open URL 'https://rest.kegg.jp/link/org.Kpm.eg.db/pathway': HTTP status was '400 Bad Request'

Some one could help me here please?

Best, Roua Popescu

guidohooiveld commented 3 months ago

There is a lot of (non-reproducible) code in your post, but to me it seems that when calling the enrichKEGG function the argument organism should be kegg_organism (and not organism).

Note that the URL you posted contains the OrgDb, but it should rather be the kegg organism...

To check: Doesn't work in browser: https://rest.kegg.jp/link/org.Kpm.eg.db/pathway

Does work in browser: https://rest.kegg.jp/link/kpm/pathway

RouaPopescu commented 3 months ago

Thank you for the suggestions! Now the enrichKEGG function works. It seems that the problem was due to the fact that the ENTREZID column had a '.0' at the end of each ENTREZ ID (I don't understand why). But, after I cleaned the ENTREZID column, the enricKEGG function worked.