R学习资源及R包安装

转自生信师兄

生信必备技巧之R语言基础教程

1. 学习资源

  • 推荐书籍:R语言实战,R数据科学等等;

    这两本书在公众号【生信师兄】都有pdf版,有需要的可以关注公众号【生信师兄】并回复:“R语言”,即可获得免费电子版书籍。

  • 遇见bug怎么办

    • R语言初学者必备-cheatsheet大全:https://www.rstudio.com/resources/cheatsheets/

    • R语言菜鸟教程:https://www.runoob.com/r/r-tutorial.html

    • 简书、知乎等各大平台都会提供很多生信分析常见的教程,一定要利用好这些资源;

    • 报错怎么办:度娘来帮忙;一定要学会百度!一定要学会百度!一定要学会百度!

2. 了解并安装R, Rstudio 及R包

  • 下载R语言的软件: https://cran.r-project.org/bin

  • 下载Rstudio这个R编辑器: https://www.rstudio.com/products/rstudio/download/

  • 安装一些必要的包

    • 什么是R包:包是 R 函数、实例数据、预编译代码的集合,包括 R 程序,注释文档、实例、测试数据等;

    • 安装包 install.packages(" xxxxxx ")

      对于生物信息学常用的包,可以使用:BiocManager::install(“xxxx”)函数进行安装

    • 加载包 library( xxxxx )

    • 查看包的帮助文档help(“xxxxx”) 或?xxxxx

# 生物信息学分析必备的一些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

# 方法一:
options()$repos
install.packages('WGCNA')
install.packages(c("FactoMineR", "factoextra"))
install.packages(c("ggplot2", "pheatmap","ggpubr"))
library("FactoMineR")
library("factoextra")

# 方法二:
if (!requireNamespace("BiocManager", quietly = TRUE))
 install.packages("BiocManager")
BiocManager::install("KEGG.db",ask = F,update = F)
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)

# 方法三:从github中安装

# 所有的R包都提交上传到CRAN,如Github,需要通过一定的渠道进行安装
# R安装devtools包
install.packages("devtools")
library(devtools)
# 安装github上的R包(需翻墙或改hosts)
devtools::install_github('lchiffon/REmap')
# 前为github的用户名,后为包名

# 测试--加载R包;
library(REmap)
library(GSEABase)
library(GSVA)
library(clusterProfiler)
library(ggplot2)
library(ggpubr)
library(hgu133plus2.db)
library(limma)
library(org.Hs.eg.db)
library(pheatmap)
  • 获取当前工作区间getwd()

  • 更改工作区间setwd( “xxxxxx”)

  • 清除当前对象rm(xx)

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东方-教育技术博主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值