美文网首页
初级题目

初级题目

作者: 晓颖_9b6f | 来源:发表于2020-10-09 19:01 被阅读0次

1、前期的准备工作

安装了:BiocManager、WGCNA、ggplot2", "pheatmap","ggpubr等各种包。

2、打开 Rstudio 告诉我它的工作目录。

 getwd()
[1] "C:/Users/Huangxiaoying/Documents"

3、新建6个向量,基于不同的原子类型。(重点是字符串,数值,逻辑值)

不同的原子类型有:逻辑值、数字、整型、复合型、字符、原型

V <- TURE
V <- c(1:10)
V <- 3L
v <- 4+5i
v <- "abc"
v <- charToRaw("Hello")
print(class(v))

4、告诉我在你打开的rstudio里面 getwd() 代码运行后返回的是什么?

 getwd()
[1] "C:/Users/Huangxiaoying/Documents"

5、新建一些数据结构,比如矩阵,数组,数据框,列表等重点是数据框,矩阵)

#建立矩阵
mymatrix <-matrix(1:100,nrow=5)
print(mymatrix )
#建立数组
myarray <- array(1:100,dim =seq(2,4))
print(myarray)
#建立数据框
name <- c('xiaoying','xiaohun','xiaogong','huangxiong','hungling','kinggan')
score <- c(100,60,30,20,10,0)
pass <- c(TRUE,TRUE,FALSE,FALSE,FALSE,FALSE)
class <- c(1:6)
tall <- c(runif(6))
lsjsd <- c(2:7)
name <- factor(name)
mydata.frame <- data.frame(name,score,pass,class,tall,lsjsd)
print(mydata.frame)

6、在你新建的数据框进行切片操作,比如首先取第1,3行, 然后取第4,6列

mydata.frame[c(1,3),]
mydata.frame[,c(4,3)]

7、使用data函数来加载R内置数据集 rivers 描述它

print(rivers)
class(rivers)
head(rivers)
tail(rivers)
str(rivers)
summary(rivers)

8、下载 https://www.ncbi.nlm.nih.gov/sra?term=SRP133642 里面的 RunInfo Table 文件读入到R里面,了解这个数据框,多少列,每一列都是什么属性的元素。

options(stringsAsFactors = F)
table = read.table("SraRunTable (1).txt", sep = "\t", header = T)
print(table) 
dim(table)
str(table)

9、下载 https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE111229 里面的样本信息sample.csv读入到R里面,了解这个数据框,多少列,每一列都是什么属性的元素。

options(stringsAsFactors = F)
table1 = read.csv("sample.csv", sep = "\t", header = T)
dim(table1)
str(table1)

10、把前面两个步骤的两个表(RunInfo Table 文件,样本信息sample.csv)关联起来,使用merge函数。

table2 <- merge(table,table1)

11、基于下午的统计可视化

rm(list = ls())
options(stringsAsFactors = F)
# 或者下载:http://www.bio-info-trainee.com/tmp/5years/SraRunTable.txt
a=read.table('SraRunTable.txt',sep = '\t',header = T)
# 或者下载:http://www.bio-info-trainee.com/tmp/5years/sample.csv 
b=read.csv('sample.csv')
colnames(a)
colnames(b)
d=merge(a,b,by.x = 'Sample_Name',by.y = 'Accession')
e=d[,c("MBases","Title")]
save(e,file = 'input.Rdata')

rm(list = ls())
options(stringsAsFactors = F)
load(file = 'input.Rdata')

e[,2]
plate=unlist(lapply(e[,2],function(x){
 # x=e[1,2]
 x
 strsplit(x,'_')[[1]][3]

}))
table(plate)
boxplot(e[,1]~plate)
t.test(e[,1]~plate)
e$plate=plate
library(ggplot2)
colnames(e)
ggplot(e,aes(x=plate,y=MBases))+geom_boxplot()

library(ggpubr)
p <- ggboxplot(e, x = "plate", y = "MBases",
 color = "plate", palette = "jco",
 add = "jitter")
# Add p-value
微信截图_20201009190044.png

相关文章

  • 初级题目

    1、前期的准备工作 安装了:BiocManager、WGCNA、ggplot2", "pheatmap","ggp...

  • 翻转图像

    题目: 题目的理解: 操作二维数组的方法 python实现 提交 // END 加油,消灭初级算法

  • R作业初级

    初级题目 R语言练习题-初级 正式开始我们的旅程 软件安装以及R包安装参考:http://www.bio-info...

  • leetcode79 单词搜索

    题目 单词搜索 分析 解法:dfs没啥可讲的,dfs初级练习题目(当然bfs也没问题)。 代码

  • R_test

    题目:初级:http://www.bio-info-trainee.com/3793.html中级:http://...

  • 2019-06-15 R语言作业(初级)

    R语言作业(初级) 题目链接:http://www.bio-info-trainee.com/3793.html ...

  • 学习总结

    时间:2017.9.3内容:初级10 个题目:http://www.bio-info-trainee.com/37...

  • 十一月份总结

    做的(正)事:1号-16号备考BEC高级;17号-30号上课、学习会计初级、看专业课本;报名会计初级、选定论文题目...

  • R语言作业(初级·上)

    初级作业·上 题目链接:http://www.bio-info-trainee.com/3793.html 1.软...

  • 由简单算法题引出的 JavaScript 精度误差问题

    最近突然来了灵感, 想去 LeetCode 刷点算法题, 在一道初级题目上遇到了看似无法理解的错误. 题目:给定一...

网友评论

      本文标题:初级题目

      本文链接:https://www.haomeiwen.com/subject/wzokpktx.html