PS 写在前面,R语言环境搭建
由于国内的网络直连CRAN有点慢,为了加速首先建立一个加速的启动文件,
file.edit('~/.Rprofile')
在打开的启动文件输入
.libPaths('你想把包安装在什么地方')
options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")
options(repos=structure(c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")))
个人建议把包不要装在C盘,不然Rstudio安装包的时候会提示c盘写入权限不够,需要以管理员身份运行太麻烦了
第一题
library(BiocManager)
BiocManager::install(c('ALL','CLL', 'pasilla', 'airway'))
BiocManager::install(c('limma','DESeq2','clusterProfiler' ))
installed.packages('reshape2')
第二题
library("CLL")
data(sCLLex)
# 注意一下data的用法
Expression_Matirx = exprs(sCLLex)
str(Expression_Matirx)
head(Expression_Matirx)
help(Expression_Matirx)
第三题
BiocManager::install('hgu95av2.db')
library(hgu95av2.db)
ls("package:hgu95av2.db")
第四题
library(hgu95av2.db)
ls("package:hgu95av2.db")
b = head(toTable(hgu95av2SYMBOL))
show(hgu95av2.db)
summary(hgu95av2.db)
a = toTable(hgu95av2SYMBOL)
library(dplyr)
c = a %>% filter(symbol == 'TP53')
# 计算基因数量
Counting_GENE =
a %>%
count(symbol,sort = TRUE,name = 'the number of ')
head(Counting_GENE)
tail(Counting_GENE)
这里的问题我遇到的有几个,
- 为什么这个包要用ls packages
原因就在帮助文档里面
Examples
## select() interface:
## Objects in this package can be accessed using the select() interface
## from the AnnotationDbi package. See ?select for details.
columns(hgu95av2.db)
## Bimap interface:
## The 'old style' of interacting with these objects is manipulation as
## bimaps. While this approach is still available we strongly encourage the
## use of select().
ls("package:hgu95av2.db")
- %>%
这个符号很有意思,希望大家能去搜一下dplyr包里面的这个内容,能帮助你理解好逻辑思路。