R语言解决clusterProfiler enrichKEGG error: "Wrong 'species' or the network is unreachable."

解决方法

  • 更改clusterProfiler包的源码并重新编译
  1. 下载源码: Bioconductor - clusterProfiler

    image.png

  2. 解压后进入 \clusterProfiler\R,找到文件kegg-utilities.R

  3. 将131行和137行的http都改为https

    image.png

  4. 卸载原来的clusterProfiler包

  5. 重新编译新的clusterProfiler包:在RStudio中选择File->New Project -> 选择下载的源码文件夹 ->
    image.png
  6. 重新运行代码,不再报错

环境

  • clusterProfiler版本:4.4.1
  • R语言版本:4.2.0
  • ClusterProfiler包的依赖均为最新版本

报错代码

kk.degene <- enrichKEGG(gene = c('12306','12307'),
                        organism = 'hsa',
                        #universe = gene_all,
                        pvalueCutoff = 0.05,
                        qvalueCutoff = 0.05)

报错信息

"Failed to download KEGG data.",
"Wrong 'species' or the network is unreachable.",
"The 'species' should be one of organisms listed in",
"'https://www.genome.jp/kegg/catalog/org_list.html'"

分析

因为是突然发生的问题,之前一直没有遇到过这个问题,所以考虑到是clusterProfiler包或者R语言的版本问题,于是先采用了更新R语言版本以及clusterProfiler包的方法但是没有能够解决。
进而搜索资料,网上的解决方法“换个网络”或者将“hsa改为human”都不work。通过查看API的更新信息以及源码发现可能出现问题:

  • KEGG的API发生变更,从HTTP to HTTPS


    image.png
  • 源码中download的地址还是使用http

尽管不熟悉网络请求的原理,但是抱着试一试的态度将源码中HTTP改为了HTTPS,发现能够成功请求,十分喜悦,特此记录。

“想到就去试一试”。 -2020602

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容