学习总结

时间:2019.7.4
内容:初级题与中级题

分组
> plate <- as.data.frame(plate)
> e$plate <- plate###将plate加入e中成为plate列
> e1 <- e[e$plate=='0048']
> class(e1)
[1] "character"
> dim(e1) <- c(384,3)
> class(e1)
[1] "matrix"
> e2 <- e[e$plate=='0049']
> dim(e2) <- c(384,3)
> e1 <- e1[,-2]
> e2 <- e2[,-2]
> e1 <- as.numeric(e1)
> dim(e1 ) <- c(384,2)
> class(e1[,1])
[1] "numeric"
> colnames(e1) <- c('MBases','plate')
> e2 <- as.numeric(e2)
> dim(e2) <- c(384,2)
> colnames(e2) <- c('MBases','plate')
频数图
> hist(e1[,1])
image.png
> hist(e2[,1])
image.png
使用ggplot2画图
箱图
library(ggplot2)
class(e1)
e1 <- as.data.frame(e1)
e2 <- as.data.frame(e2)
> ggplot(e1,aes(x=plate,y=MBases))+geom_boxplot()
> ggplot(e2,aes(x=plate,y=MBases))+geom_boxplot()
image.png
image.png
频数图
> ggplot(e1,aes(x=MBases))+geom_histogram(bins = 40,color="blue")
> ggplot(e2,aes(x=MBases))+geom_histogram(bins = 40,color="blue")
image.png
> ggplot(e2,aes(x=MBases))+geom_histogram(bins = 40,color="blue")
image.png
密度图
> ggplot(e1,aes(x=MBases))+geom_density()
image.png
> ggplot(e2,aes(x=MBases))+geom_density()
image.png
使用ggpubr作图
library(ggpubr)
箱图
> ggboxplot(e1,x = 'plate',y = 'MBases')
image.png
> ggboxplot(e2,x = 'plate',y = 'MBases')
image.png
频数图
> gghistogram(e1,x='MBases',bins=30)
image.png
> gghistogram(e2,x='MBases',bins=30)
image.png
密度图
> ggdensity(e1,x='MBases')
image.png
> ggdensity(e2,x='MBases')
image.png
随机取384个MBases信息,跟前面的两个plate的信息组合成新的数据框,第一列是分组,第二列是MBases,总共是384*3行数据。
> a1 <- e$MBases[1:384]
> a2 <- e$Title[1:384]
> a <- data.frame(a1,a2)
> a$plate <- as.data.frame(plate[,1][1:384])
> colnames(a) <- c('MBases','Title','plate')

中级题

作业 1

根据R包org.Hs.eg.db找到下面ensembl 基因ID 对应的基因名(symbol)

> g2s <- toTable(org.Hs.egSYMBOL)
> g2e <- toTable(org.Hs.egENSEMBL)
> ensemble_id <- c('ENSG00000000003.13','ENSG00000000005.5','ENSG00000000419.11','ENSG00000000457.12','ENSG00000000460.15','ENSG00000000938.11')
> #批量取基因名
> library(stringr)
> unlist(str_split(ensemble_id,'[.]'))
 [1] "ENSG00000000003" "13"              "ENSG00000000005" "5"              
 [5] "ENSG00000000419" "11"              "ENSG00000000457" "12"             
 [9] "ENSG00000000460" "15"              "ENSG00000000938" "11"       
> tmp <- unlist(str_split(ensemble_id,'[.]',simplify = T))###simplify = T 此参数生成为矩阵
image.png
> class(unlist(str_split(ensemble_id,'[.]',simplify = T)))
[1] "matrix"
> ensemble_id <- tmp[,1]
> ensembl_id <- as.data.frame(ensemble_id)
image.png
> colnames(ensembl_id) <- 'ensembl_id'
> merge1 <- merge(x=ensembl_id,y=g2e,by='ensembl_id')
image.png
> merge2 <- merge(x=merge1,y=g2s,by='gene_id')
image.png
作业 2

根据R包hgu133a.db找到下面探针对应的基因名(symbol)

> tmp <- c('1053_at','117_at','121_at','1255_g_at','1316_at','1320_at','1405_i_at','1431_at','1438_at','1487_at','1494_f_at','1598_g_at','160020_at','1729_at','177_at')
> probe_id <- as.data.frame(tmp)
> View(probe_id)
> colnames(probe_id) <- 'probe_id'
> View(probe_id)
image.png
> a <- toTable(hgu133aSYMBOL)
> merge <- merge(x=probe_id,y=a,by='probe_id')
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1. MongoDB 简介 MongoDB是一个可扩展的高性能,开源,模式自由,面向文档的NoSQL,基于分布式文...
    rhlp阅读 4,866评论 0 3
  • 时间:2017.9.3内容:初级10 个题目:http://www.bio-info-trainee.com/37...
    桃浪桃浪阅读 1,697评论 0 1
  • MATLAB基本数据类型 双精度/单精度/整形 数据的范围 务必注意溢出的问题。 函数 类型检查 class is...
    hainingwyx阅读 11,115评论 0 6
  • 一. 为什么使用缓存 如图1,为了快速应对早期的业务快速发展,我们架设一个超级简单的Web服务,只有一台应用服务器...
    大头8086阅读 7,253评论 0 5
  • 经过一段时间的学习,也对数据库有了一些认识。 数据库基本是由表,关系,操作组成;对于初学者首先要学的: 1.数据库...
    imtcf阅读 4,353评论 0 0

友情链接更多精彩内容