资源来自生信技能树

#1.读取ex1.txt
ex1= read.table("ex1.txt",header = T) #header=T把数据第一行设为列名
原数据为:

运行下面代码
#2.读取ex2_B cell receptor signaling pathway.csv
ex2 = read.csv("ex2_B cell receptor signaling pathway.csv")

解决上述红框问题,将行名设为基因名,列名为原数据格式
ex2 = read.csv("ex2_B cell receptor signaling pathway.csv",
row.names = 1,
check.names = F)

原始数据:

#3.读取GSE32575_series_matrix.txt,赋值给gse。
gse = read.table("GSE32575_series_matrix.txt")

要去掉数据中的前65行和最后一行注释信息,则运行下列代码
gse = read.table("GSE32575_series_matrix.txt",
comment.char = "!",
header = T,
row.names = 1)
#comment.char = "!"为去掉含!的行,header = T以第一行为列名,row.names = 1以第一列为行名

#4.描述gse的属性
dim(gse)
colnames(gse)
rownames(gse)


#5.将gse导出为新的txt和csv文件。
write.table(gse,file = "zz.txt")
write.csv(gse,file = "zz.csv") #sep="\t"为以Tab键为分隔符,sep=" "为以空格为分隔符
#6.将gse保存为Rdata并加载。
save(gse,file = "zz.Rdata")
#7.保存多个变量到Rdata
save(gse,ex1,ex2,file = "zz.Rdata")
#8.加载Rdata
load("zz.Rdata")

高阶数据读取指南
网友评论