一、直接安装
install.packages("package name")
二、BiocManager安装--
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("package name")
注意:有时候可根据回显添加force = TRUE
三、git_hub安装
library(devtools)
devtools::install_github("包创作者/package name")
library(remotes)
remotes::install_github("包创作者/package name")
四、https://anaconda.org 搜索包安装方法
五:本地安装
download.file("https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz","rvcheck_0.1.8.tar.gz")
install.packages(rvcheck_0.1.8.tar.gz, repos = NULL, type="source")
六:找到R包下载地址后安装
url <- "https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz"
install.packages(url,repos = NULL,type = "source")
七、命令行安装
在shell的终端
sudo R CMD INSTALL package.tar.gz
八、在CRAN中检索R包:CRAN Packages By Name (r-project.org)
九、其他操作
1.packageVersion("包“)
2.install.packages("包“,upgrade=TRUE)
3.remove.packages("包")
4.installed.packages()
5.
自己遇到的一些难搞的包安装方法:
1.scater
if(!require(scater))
devtools::install_github("davismcc/scater",build_vignettes=TRUE)
2.metap
conda install -c conda-forge r-metap
3.scRNA.seq.funcs
install_github("hemberg-lab/scRNA.seq.funcs")
安装不成功问题总结:
1.依赖的其它包没有安装
2.和R/conda版本不兼容
3.和系统不兼容
4.各种安装方法均试一遍,看哪种合适
5.删除包后重新安装
6.服务器卡
现成安装代码(不一定成,需要多试,里面有一些是其它包的依赖包)
1、install.packages
install.packages("stringi")
install.packages("ggplot2")
install.packages("pls")
install.packages("ggthemes")
install.packages("ggrepel")
install.packages("readxl")
install.packages("writexl")
install.packages("reshape2")
install.packages("pheatmap")
install.packages("RColorBrewer")
install.packages("remotes")
install.packages("ggpubr")
install.packages("corrplot")
install.packages("ggcorrplot")
install.packages("xml2")
install.packages("https://cran.r-project.org/src/contrib/Archive/xml2/xml2_1.3.2.tar.gz",repos = NULL,type = "source")
install.packages("nloptr")
install.packages("hrbrthemes")
install.packages("curl")
install.packages("https://cran.r-project.org/src/contrib/curl_4.3.2.tar.gz",repos = NULL,type = "source")
install.packages("httr")
install.packages("openssl") # https://github.com/openssl/openssl
install.packages("ComplexHeatmap")
install.packages("formattable")
install.packages("rstan")
install.packages("optparse")
install.packages("tidyverse")
install.packages("rvest")
install.packages("multiUS", repos="http://R-Forge.R-project.org")
install.packages("https://cran.r-project.org/src/contrib/Archive/locfit/locfit_1.5-9.4.tar.gz",repos = NULL,type = "source")
install.packages("https://cran.r-project.org/src/contrib/Archive/ArgumentCheck/ArgumentCheck_0.10.2.tar.gz",repos = NULL,type = "source")
install.packages("RCircos") # 环形图
install.packages("https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz",repos = NULL,type = "source")
install.packages("ggalt") # 平滑折线图
install.packages ("githubinstall")
install.packages ("pacman")
install.packages("showtext") # 更改字体
install.packages("shadowtext") # 更改字体
install.packages("googleway") # 地图
install.packages("lubridate") # 日期转换
install.packages("networkD3") # 3D网络图
install.packages("IDPmisc") # https://www.rdocumentation.org/packages/IDPmisc/versions/1.1.20
install.packages("do")
install.packages("plotly") # 交互式绘图
install.packages("dygraphs")
install.packages("DT")
install.packages("echarts4r") # 版本可能存在问题
install.packages("WGCNA")
install.packages("psych") # 计算相关性
install.packages("AnnoProbe") # 用于下载GEO数据集并注释
install.packages("argparser")
install.packages("umap")
install.packages("survival")
install.packages("survminer")
install.packages("emmeans")
install.packages("factoextra") # https://github.com/kassambara/factoextra
install.packages("NMF") # 非负矩阵分解(nonnegative matrix factorization)
install.packages("chemometrics")
install.packages("compositions")
install.packages("msigdbr")
install.packages("gProfileR") # ID转换
install.packages("fdrci") # p值校正
install.packages("maxstat")
install.packages("fpc") # 计算K-means聚类推荐聚类数
install.packages("mice") # 多重插补
install.packages("ggdendro")
install.packages("svglite") # 保存图片为sv
2、BiocManager::install
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("clusterProfiler")
BiocManager::install("impute")
BiocManager::install("limma")
BiocManager::install("DEP")
BiocManager::install("SummarizedExperiment",force = TRUE)
BiocManager::install("edgeR")
BiocManager::install("DESeq2")
BiocManager::install("org.Hs.eg.db")
BiocManager::install("pathview")
BiocManager::install("AnnotationDbi")
BiocManager::install("IPO")
BiocManager::install("xcms")
BiocManager::install("KEGGREST",force = TRUE)
BiocManager::install("fmcsR")
BiocManager::install("Cairo")
BiocManager::install("ComplexHeatmap")
BiocManager::install("DLBCL")
BiocManager::install("BioNet")
BiocManager::install("RSQLite")
BiocManager::install("DirichletMultinomial",force = TRUE)
BiocManager::install("chimeraviz") # 融合基因分析结果可视化
BiocManager::install("ballgown") # 分析转录组差异表达
BiocManager::install("genefilter",force = T) # methods for filtering genes from high-throughput experiments
BiocManager::install("ChIPpeakAnno")
BiocManager::install("RMassBank")
BiocManager::install("ChIPseeker")
BiocManager::install("GSVA") # 基因集变异分析(Gene Set Variation Analysis,GSVA)
BiocManager::install("ConsensusClusterPlus") # 一致性聚类
BiocManager::install("statTarget") # 质控
BiocManager::install("cmapR") # https://bioconductor.org/packages/release/bioc/html/cmapR.html
BiocManager::install("TCGAbiolinks") # 下载TCGA数据
3、devtools::install_github
devtools::install_github("strengejacke/sjmisc")
devtools::install_github("kassambara/ggpubr")
devtools::install_github("cran/nloptr@1.2.2.3")
devtools::install_github("jokergoo/ComplexHeatmap")
devtools::install_github("https://github.com/cran/RbioRXN.git")
devtools::install_github('cytoscape/r-cytoscape.js@v0.0.7') # 提示更新相关包选项时我选择了3: None
devtools::install_github("xia-lab/OptiLCMS", build = TRUE, build_vignettes = FALSE, build_manual =TRUE)
devtools::install_github("kumine/myplot")
devtools::install_github("stan-dev/rstantools")
devtools::install_github("davidaknowles/leafcutter/leafcutter") # 可变剪切分析
devtools::install_github("alyssafrazee/RSkittleBrewer") # 颜色主题
devtools::install_github("kendomaniac/docker4seq", ref="master")
devtools::install_github("ropensci/magick")
devtools::install_github("schymane/ReSOLUTION")
devtools::install_github("dkahle/ggmap") # 绘制地图 https://github.com/dkahle/ggmap
devtools::install_github("ropensci/rnaturalearth") # 世界地图 https://github.com/ropensci/rnaturalearth
devtools::install_github("outbreak-info/R-outbreak-info") # https://github.com/outbreak-info/R-outbreak-info
devtools::install_github("ramnathv/rCharts") # 交互式绘图
devtools::install_github("yihui/recharts") # 交互式绘图
devtools::install_github("ropensci/plotly") # 交互式绘图
devtools::install_github("timelyportfolio/d3treeR")
devtools::install_github("liamgilbey/ggwaffle") # 方块图/热图
devtools::install_github("https://github.com/CDK-R/rcdklibs")
devtools::install_github("https://github.com/CDK-R/cdkr", subdir="rcdk")
devtools::install_github("seandavi/GEOquery") # https://github.com/seandavi/GEOquery
devtools::install_github("therneau/survival") # https://github.com/therneau/survival
devtools::install_github("dgrapov/CTSgetR") # https://github.com/dgrapov/CTSgetR 化合物ID转换
devtools::install_github("adam-sam-brown/ksRepo") # https://github.com/adam-sam-brown/ksRepo
devtools::install_github("cBioPortal/cgdsr") # https://github.com/cBioPortal/cgdsr/blob/master/README.md
4、 remotes::install_github
remotes::install_github("YuLab-SMU/ggtree")
remotes::install_github("SVA-SE/kilde") # sample_data函数
remotes::install_github("SymbolixAU/googlePolylines")
remotes::install_github("SymbolixAU/googleway")
remotes::install_github("rvlenth/emmeans", dependencies = TRUE, build_opts = "") # https://github.com/rvlenth/emmeans
remotes::install_github("YuLab-SMU/createKEGGdb")
5、MetaboAnalystR
Step 1. Install package dependencies
================== Option 1 ==================
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.
metanr_packages <- function(){
metr_pkgs <- c("impute", "pcaMethods", "globaltest", "GlobalAncova", "Rgraphviz", "preprocessCore", "genefilter", "SSPA", "sva", "limma", "KEGGgraph", "siggenes","BiocParallel", "MSnbase", "multtest", "RBGL", "edgeR", "fgsea", "devtools", "crmn")
list_installed <- installed.packages()
new_pkgs <- subset(metr_pkgs, !(metr_pkgs %in% list_installed[, "Package"]))
if(length(new_pkgs)!=0){if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(new_pkgs)
print(c(new_pkgs, " packages added..."))
}
if((length(new_pkgs)<1)){
print("No new packages added...")
}
}
metanr_packages()
================== Option 2 ==================
Use the pacman R package (for those with >R 3.5.1).
install.packages("pacman")
library(pacman)
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
================== Option A) Install the package directly from github using the devtools package.==================
# Step 1: Install devtools
install.packages("devtools")
library(devtools)
# Step 2: Install MetaboAnalystR without documentation
devtools::install_github("xia-lab/MetaboAnalystR", build = TRUE, build_vignettes = FALSE)
# Step 2: Install MetaboAnalystR with documentation
devtools::install_github("xia-lab/MetaboAnalystR", build = TRUE, build_vignettes = TRUE, build_manual =T)
================== Option B) Install from a pre-built source package ==================
install.packages("https://www.dropbox.com/s/pp9vziji96k5z5k/MetaboAnalystR_3.2.0.tar.gz", repos = NULL, method = "wget")
================== Option C) Clone Github and install locally ==================
git clone https://github.com/xia-lab/MetaboAnalystR.git
R CMD build MetaboAnalystR
R CMD INSTALL MetaboAnalystR_3.2.0.tar.gz
-------------------------单细胞分析包安装----------------------
1.harmony
install.packages('harmony')
#or
library(devtools)
install_github("immunogenomics/harmony")