码迷,mamicode.com
首页 > 其他好文 > 详细

X98281_去重_均一化

时间:2021-04-07 11:22:35      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:平均值   需要   建行   splay   排序   tween   plot   nan   library   

rownames(X98281_RAW_new)=X98281_RAW_new[,1] #取出第一列
data=X98281_RAW_new[,-1] #将第一列删除
head(data)

 

newdata=as.data.frame(X98281_RAW_new)
set=newdata

#创建行平均值(除了第一行,第一行是基因名字)
set$mean <- apply(set[,2:21], 1, mean,na.rm=T)
#按行平均值排序
newset=set %>%
arrange(Symbol,desc(mean))
#只留第一个(按照Gene_Name)
newset=newset %>%
distinct(Symbol,.keep_all = T)
#去除NA值
newset=newset %>%
filter(Symbol!= "NA")
#将数据框的第一列作为行名
row.names(newset)<-newset[,1]
#将数据框的第一列删除,只留下剩余的列作为数据
newset<-newset[,-1]
#去除mean这个值
newset=newset[,c(1:20)]

exprSet <- normalizeBetweenArrays(newset)
par(cex = 0.7)
n.sample=ncol(exprSet)
if(n.sample>40) par(cex = 0.5)
cols <- rainbow(n.sample*1.2)

boxplot(newset, col = cols,main="expression value",las=2)

library(limma)
exprSet=normalizeBetweenArrays(newset)
boxplot(exprSet,outline=FALSE, notch=T,col=9, las=2)
exprSet1=newset
#View(exprSet)
#log转换 自己判断是否需要log转换
ex <- exprSet
qx <- as.numeric(quantile(ex, c(0., 0.25, 0.5, 0.75, 0.99, 1.0), na.rm=T))
LogC <- (qx[5] > 100) ||
(qx[6]-qx[1] > 50 && qx[2] > 0) ||
(qx[2] > 0 && qx[2] < 1 && qx[4] > 1 && qx[4] < 2)

if (LogC) { ex[which(ex <= 0)] <- NaN
exprSet<- log2(ex)
print("log2 transform finished")}else{print("log2 transform not needed")}

exprSet=normalizeBetweenArrays(exprSet)
exprSet1=normalizeBetweenArrays(exprSet)
par(cex = 0.7)
n.sample=ncol(exprSet1)
if(n.sample>40) par(cex = 0.5)
cols <- rainbow(n.sample*1.2)
boxplot(exprSet1, col = ‘#FEE0D2‘,main="expression value",las=2)

require("RColorBrewer")
display.brewer.all()

brewer.pal(9, "Reds")

 

X98281_去重_均一化

标签:平均值   需要   建行   splay   排序   tween   plot   nan   library   

原文地址:https://www.cnblogs.com/jolinstory/p/14621288.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!