R语言自学笔记-1准备工作

#课程b站——生信技能树

#资料#技能树爆款入门(生物信息学)全国巡讲准备工作答疑 (qq.com)

#1.软件安装

#2.环境配置

#3.R包安装

rm(list = ls())

options()$repos

options()$BioC_mirror

#options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")

options(BioC_mirror="http://mirrors.tuna.tsinghua.edu.cn/bioconductor/")

options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))

options()$repos

options()$BioC_mirror

# https://bioconductor.org/packages/release/bioc/html/GEOquery.html

if (!requireNamespace("BiocManager", quietly = TRUE))

  install.packages("BiocManager")

BiocManager::install(c("GSEABase","GSVA","clusterProfiler" ),ask = F,update = F)

BiocManager::install(c("GEOquery","limma","impute" ),ask = F,update = F)

BiocManager::install(c("org.Hs.eg.db","hgu133plus2.db" ),ask = F,update = F)

# 下面代码被我注释了,意思是这些代码不需要运行,因为它过时了,很多旧教程就忽略

# 在代码前面加上 # 这个符号,代码代码被注释,意思是不会被运行

# source("https://bioconductor.org/biocLite.R")

# library('BiocInstaller')

# options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")

# BiocInstaller::biocLite("GEOquery")

# BiocInstaller::biocLite(c("limma"))

# BiocInstaller::biocLite(c("impute"))

# 但是接下来的代码又需要运行啦

options()$repos

install.packages('WGCNA')

install.packages(c("FactoMineR", "factoextra"))

install.packages(c("ggplot2", "pheatmap","ggpubr"))

library("FactoMineR")

library("factoextra")

library(GSEABase)

library(GSVA)

library(clusterProfiler)

library(ggplot2)

library(ggpubr)

library(hgu133plus2.db)

library(limma)

library(org.Hs.eg.db)

library(pheatmap)

#clusterProfiler包不合适,需要加载GO.db包

install.packages("GO.db")

#install.packages 中的警告:包“GO.db”不适用于此版本的 R

#如果所要下载的R包不在R语言官网上,

#那它极有可能在Bioconductor或者Github上

#可以先登录Bioconductor官网(http://www.bioconductor.org/)搜索相关R包

#选择一个合适的版本

#如下

#GO.db

#Bioconductor version: Release (3.13)

#A set of annotation maps describing the entire Gene Ontology assembled using data from GO

#Author: Marc Carlson

#Maintainer: Bioconductor Package Maintainer <maintainer at bioconductor.org>

#Citation (from within R, enter ):citation("GO.db")

#Installation

#要安装此包,请启动 R(版本"4.1")并输入:

if (!requireNamespace("BiocManager", quietly = TRUE))

  install.packages("BiocManager")

BiocManager::install("GO.db")

#R包在Windows可能是需要rtools的安装才能解决报错

#安装完成后,您还需要执行一个步骤才能编译 R 包:您需要将 Rtools make 实用程序(bash、make 等)的位置放在 PATH 中。

#最简单的方法是在您的 Documents 文件夹中创建一个文本文件 .Renviron,其中包含以下行:

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"

#您可以使用文本编辑器或像这样从 R 执行此操作(请注意,在 R 代码中,您需要转义反斜杠):

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

#现在重新启动 R,并验证是否可以找到 make,它应该显示 Rtools 安装的路径。

Sys.which("make")

## "C:\\rtools40\\usr\\bin\\make.exe"

#如果可行,您可以尝试从源代码安装 R 包:

install.packages("jsonlite", type = "source")

#如果这成功了,你就可以开始了! 请参阅以下链接以了解有关 rtools4 和 Windows 构建基础结构的更多信息。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容