R包安装方法汇总

一、直接安装

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")

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

### 使用R语言进行单细胞代谢定量分析 在单细胞水平上研究代谢活动对于理解细胞异质性和功能至关重要。为了实现这一目标,可以利用一系列生物信息学工具和方法来处理和解释来自单细胞实验的数据。 #### 数据预处理 通常情况下,在开始任何类型的定量之前,需要先对原始数据进行质量控制(QC),过滤低质量读数以及去除潜在污染[^2]。这一步骤可以通过`Seurat`或`Scanpy`(Python库)完成初步QC工作;然而,当专注于代谢特征时,则可能需要用到特定于代谢物检测平台的软件如XCMS或MZmine来进行峰检出与校正操作[^1]。 #### 整合多组学数据集 由于单独依靠转录本无法全面反映实际发生的生理过程变化,因此建议采用联合分析策略——即把mRNA表达谱(scRNA-seq)同液相色谱-质谱联用(LC-MS)/气相色谱-质谱联用(GC-MS)获得的小分子浓度测量结合起来考虑。这种做法有助于更准确地描绘出不同条件下个体细胞内部复杂的生化反应网络状况[^3]。 #### 应用统计模型评估差异丰度 一旦获得了经过清理后的高质量计数值矩阵之后,就可以运用线性回归或其他高级机器学习算法(例如随机森林、支持向量机等),通过比较对照组vs. 实验组间各靶标物质平均含量是否存在显著区别从而找出具有生物学意义的关键调控因子[^4]。在此过程中,`limma`提供了方便易用的功能接口用于执行两样本t检验/ANOVA测试并计算p值调整后的FDR得分。 ```r library(limma) design <- model.matrix(~0 + group, data=colData) fit <- lmFit(counts_matrix, design) contrast.matrix <- makeContrasts( levels=design, Treat_vs_Control = Treatment-Control ) fit2 <- contrasts.fit(fit, contrast.matrix) eb <- eBayes(fit2) topTable(eb, adjust="fdr", number=nrow(counts_matrix)) ``` 上述代码片段展示了如何构建零假设下的广义线性模型(GLM), 并基于此框架内实施多重假设检验矫正程序以降低假阳性率的影响程度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值