当前位置:   article > 正文

R包安装方法汇总_r语言安装包

r语言安装包

一、直接安装

install.packages("package name")


二、BiocManager安装--

  1. if (!requireNamespace("BiocManager", quietly = TRUE))
  2. install.packages("BiocManager")
  3. BiocManager::install("package name")
  4. 注意:有时候可根据回显添加force = TRUE

三、git_hub安装

  1. library(devtools)
  2. devtools::install_github("包创作者/package name")
  1. library(remotes)
  2. remotes::install_github("包创作者/package name")

四、https://anaconda.org  搜索包安装方法

五:本地安装

  1. download.file("https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz","rvcheck_0.1.8.tar.gz")
  2. install.packages(rvcheck_0.1.8.tar.gz, repos = NULL, type="source")

六:找到R包下载地址后安装

  1. url <- "https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz"
  2. install.packages(url,repos = NULL,type = "source")

七、命令行安装

  1. 在shell的终端
  2. sudo R CMD INSTALL package.tar.gz

八、在CRAN中检索R包:CRAN Packages By Name (r-project.org)

自己遇到的一些难搞的包安装方法:

1.scater

if(!require(scater))

devtools::install_github("davismcc/scater",build_vignettes=TRUE)

2.metap

conda install -c conda-forge r-metap

安装不成功问题总结:

1.依赖的其它包没有安装

2.和R/conda版本不兼容

3.和系统不兼容

4.各种安装方法均试一遍,看哪种合适

5.删除包后重新安装

6.服务器卡

现成安装代码(不一定成,需要多试,里面有一些是其它包的依赖包)

1、install.packages

  1. install.packages("stringi")
  2. install.packages("ggplot2")
  3. install.packages("pls")
  4. install.packages("ggthemes")
  5. install.packages("ggrepel")
  6. install.packages("readxl")
  7. install.packages("writexl")
  8. install.packages("reshape2")
  9. install.packages("pheatmap")
  10. install.packages("RColorBrewer")
  11. install.packages("remotes")
  12. install.packages("ggpubr")
  13. install.packages("corrplot")
  14. install.packages("ggcorrplot")
  15. install.packages("xml2")
  16. install.packages("https://cran.r-project.org/src/contrib/Archive/xml2/xml2_1.3.2.tar.gz",repos = NULL,type = "source")
  17. install.packages("nloptr")
  18. install.packages("hrbrthemes")
  19. install.packages("curl")
  20. install.packages("https://cran.r-project.org/src/contrib/curl_4.3.2.tar.gz",repos = NULL,type = "source")
  21. install.packages("httr")
  22. install.packages("openssl") # https://github.com/openssl/openssl
  23. install.packages("ComplexHeatmap")
  24. install.packages("formattable")
  25. install.packages("rstan")
  26. install.packages("optparse")
  27. install.packages("tidyverse")
  28. install.packages("rvest")
  29. install.packages("multiUS", repos="http://R-Forge.R-project.org")
  30. install.packages("https://cran.r-project.org/src/contrib/Archive/locfit/locfit_1.5-9.4.tar.gz",repos = NULL,type = "source")
  31. install.packages("https://cran.r-project.org/src/contrib/Archive/ArgumentCheck/ArgumentCheck_0.10.2.tar.gz",repos = NULL,type = "source")
  32. install.packages("RCircos") # 环形图
  33. install.packages("https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz",repos = NULL,type = "source")
  34. install.packages("ggalt") # 平滑折线图
  35. install.packages ("githubinstall")
  36. install.packages ("pacman")
  37. install.packages("showtext") # 更改字体
  38. install.packages("shadowtext") # 更改字体
  39. install.packages("googleway") # 地图
  40. install.packages("lubridate") # 日期转换
  41. install.packages("networkD3") # 3D网络图
  42. install.packages("IDPmisc") # https://www.rdocumentation.org/packages/IDPmisc/versions/1.1.20
  43. install.packages("do")
  44. install.packages("plotly") # 交互式绘图
  45. install.packages("dygraphs")
  46. install.packages("DT")
  47. install.packages("echarts4r") # 版本可能存在问题
  48. install.packages("WGCNA")
  49. install.packages("psych") # 计算相关性
  50. install.packages("AnnoProbe") # 用于下载GEO数据集并注释
  51. install.packages("argparser")
  52. install.packages("umap")
  53. install.packages("survival")
  54. install.packages("survminer")
  55. install.packages("emmeans")
  56. install.packages("factoextra") # https://github.com/kassambara/factoextra
  57. install.packages("NMF") # 非负矩阵分解(nonnegative matrix factorization)
  58. install.packages("chemometrics")
  59. install.packages("compositions")
  60. install.packages("msigdbr")
  61. install.packages("gProfileR") # ID转换
  62. install.packages("fdrci") # p值校正
  63. install.packages("maxstat")
  64. install.packages("fpc") # 计算K-means聚类推荐聚类数
  65. install.packages("mice") # 多重插补
  66. install.packages("ggdendro")
  67. install.packages("svglite") # 保存图片为sv

2、BiocManager::install

  1. if (!requireNamespace("BiocManager", quietly = TRUE))
  2. install.packages("BiocManager")
  3. BiocManager::install("clusterProfiler")
  4. BiocManager::install("impute")
  5. BiocManager::install("limma")
  6. BiocManager::install("DEP")
  7. BiocManager::install("SummarizedExperiment",force = TRUE)
  8. BiocManager::install("edgeR")
  9. BiocManager::install("DESeq2")
  10. BiocManager::install("org.Hs.eg.db")
  11. BiocManager::install("pathview")
  12. BiocManager::install("AnnotationDbi")
  13. BiocManager::install("IPO")
  14. BiocManager::install("xcms")
  15. BiocManager::install("KEGGREST",force = TRUE)
  16. BiocManager::install("fmcsR")
  17. BiocManager::install("Cairo")
  18. BiocManager::install("ComplexHeatmap")
  19. BiocManager::install("DLBCL")
  20. BiocManager::install("BioNet")
  21. BiocManager::install("RSQLite")
  22. BiocManager::install("DirichletMultinomial",force = TRUE)
  23. BiocManager::install("chimeraviz") # 融合基因分析结果可视化
  24. BiocManager::install("ballgown") # 分析转录组差异表达
  25. BiocManager::install("genefilter",force = T) # methods for filtering genes from high-throughput experiments
  26. BiocManager::install("ChIPpeakAnno")
  27. BiocManager::install("RMassBank")
  28. BiocManager::install("ChIPseeker")
  29. BiocManager::install("GSVA") # 基因集变异分析(Gene Set Variation Analysis,GSVA)
  30. BiocManager::install("ConsensusClusterPlus") # 一致性聚类
  31. BiocManager::install("statTarget") # 质控
  32. BiocManager::install("cmapR") # https://bioconductor.org/packages/release/bioc/html/cmapR.html
  33. BiocManager::install("TCGAbiolinks") # 下载TCGA数据

3、devtools::install_github

  1. devtools::install_github("strengejacke/sjmisc")
  2. devtools::install_github("kassambara/ggpubr")
  3. devtools::install_github("cran/nloptr@1.2.2.3")
  4. devtools::install_github("jokergoo/ComplexHeatmap")
  5. devtools::install_github("https://github.com/cran/RbioRXN.git")
  6. devtools::install_github('cytoscape/r-cytoscape.js@v0.0.7') # 提示更新相关包选项时我选择了3: None
  7. devtools::install_github("xia-lab/OptiLCMS", build = TRUE, build_vignettes = FALSE, build_manual =TRUE)
  8. devtools::install_github("kumine/myplot")
  9. devtools::install_github("stan-dev/rstantools")
  10. devtools::install_github("davidaknowles/leafcutter/leafcutter") # 可变剪切分析
  11. devtools::install_github("alyssafrazee/RSkittleBrewer") # 颜色主题
  12. devtools::install_github("kendomaniac/docker4seq", ref="master")
  13. devtools::install_github("ropensci/magick")
  14. devtools::install_github("schymane/ReSOLUTION")
  15. devtools::install_github("dkahle/ggmap") # 绘制地图 https://github.com/dkahle/ggmap
  16. devtools::install_github("ropensci/rnaturalearth") # 世界地图 https://github.com/ropensci/rnaturalearth
  17. devtools::install_github("outbreak-info/R-outbreak-info") # https://github.com/outbreak-info/R-outbreak-info
  18. devtools::install_github("ramnathv/rCharts") # 交互式绘图
  19. devtools::install_github("yihui/recharts") # 交互式绘图
  20. devtools::install_github("ropensci/plotly") # 交互式绘图
  21. devtools::install_github("timelyportfolio/d3treeR")
  22. devtools::install_github("liamgilbey/ggwaffle") # 方块图/热图
  23. devtools::install_github("https://github.com/CDK-R/rcdklibs")
  24. devtools::install_github("https://github.com/CDK-R/cdkr", subdir="rcdk")
  25. devtools::install_github("seandavi/GEOquery") # https://github.com/seandavi/GEOquery
  26. devtools::install_github("therneau/survival") # https://github.com/therneau/survival
  27. devtools::install_github("dgrapov/CTSgetR") # https://github.com/dgrapov/CTSgetR 化合物ID转换
  28. devtools::install_github("adam-sam-brown/ksRepo") # https://github.com/adam-sam-brown/ksRepo
  29. devtools::install_github("cBioPortal/cgdsr") # https://github.com/cBioPortal/cgdsr/blob/master/README.md

4、 remotes::install_github

  1. remotes::install_github("YuLab-SMU/ggtree")
  2. remotes::install_github("SVA-SE/kilde") # sample_data函数
  3. remotes::install_github("SymbolixAU/googlePolylines")
  4. remotes::install_github("SymbolixAU/googleway")
  5. remotes::install_github("rvlenth/emmeans", dependencies = TRUE, build_opts = "") # https://github.com/rvlenth/emmeans
  6. remotes::install_github("YuLab-SMU/createKEGGdb")

5、MetaboAnalystR

​​​​​​​

Step 1. Install package dependencies

  1. ================== Option 1 ==================
  2. Enter the R function (metanr_packages) and then use the function. A printed message will appear informing you whether or not any R packages were installed.
  3. metanr_packages <- function(){
  4. metr_pkgs <- c("impute", "pcaMethods", "globaltest", "GlobalAncova", "Rgraphviz", "preprocessCore", "genefilter", "SSPA", "sva", "limma", "KEGGgraph", "siggenes","BiocParallel", "MSnbase", "multtest", "RBGL", "edgeR", "fgsea", "devtools", "crmn")
  5. list_installed <- installed.packages()
  6. new_pkgs <- subset(metr_pkgs, !(metr_pkgs %in% list_installed[, "Package"]))
  7. if(length(new_pkgs)!=0){if (!requireNamespace("BiocManager", quietly = TRUE))
  8. install.packages("BiocManager")
  9. BiocManager::install(new_pkgs)
  10. print(c(new_pkgs, " packages added..."))
  11. }
  12. if((length(new_pkgs)<1)){
  13. print("No new packages added...")
  14. }
  15. }
  16. metanr_packages()
  17. ================== Option 2 ==================
  18. Use the pacman R package (for those with >R 3.5.1).
  19. install.packages("pacman")
  20. library(pacman)
  21. pacman::p_load(c("impute", "pcaMethods", "globaltest", "GlobalAncova", "Rgraphviz", "preprocessCore", "genefilter", "SSPA", "sva", "limma", "KEGGgraph", "siggenes","BiocParallel", "MSnbase", "multtest", "RBGL", "edgeR", "fgsea"))

Step 2. Install the package

  1. ================== Option A) Install the package directly from github using the devtools package.==================
  2. # Step 1: Install devtools
  3. install.packages("devtools")
  4. library(devtools)
  5. # Step 2: Install MetaboAnalystR without documentation
  6. devtools::install_github("xia-lab/MetaboAnalystR", build = TRUE, build_vignettes = FALSE)
  7. # Step 2: Install MetaboAnalystR with documentation
  8. devtools::install_github("xia-lab/MetaboAnalystR", build = TRUE, build_vignettes = TRUE, build_manual =T)
  9. ================== Option B) Install from a pre-built source package ==================
  10. install.packages("https://www.dropbox.com/s/pp9vziji96k5z5k/MetaboAnalystR_3.2.0.tar.gz", repos = NULL, method = "wget")
  11. ================== Option C) Clone Github and install locally ==================
  12. git clone https://github.com/xia-lab/MetaboAnalystR.git
  13. R CMD build MetaboAnalystR
  14. R CMD INSTALL MetaboAnalystR_3.2.0.tar.gz

参考:R包安装方法及安装记录 - 知乎

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/515978
推荐阅读
相关标签
  

闽ICP备14008679号