limma package计算差异表达

test.txt:文件格式:

 geneTCGA-3M-AB46-01A-11R-A414-31TCGA-3M-AB47-01A-22R-A414-31TCGA-B7-A5TK-01A-12R-A36D-31TCGA-B7-A5TN-01A-21R-A31P-31
A2LD14316062731194
A2M358641594222086109363
AADACL202100
AADAT643388317241
pheno.txt文件格式:

TCGA-3M-AB46-01A-11R-A414-31 a
TCGA-3M-AB47-01A-22R-A414-31 b
TCGA-B7-A5TK-01A-12R-A36D-31 b
TCGA-B7-A5TN-01A-21R-A31P-31 a
TCGA-BR-6457-01A-21R-1802-13 a
TCGA-BR-6458-01A-11R-1802-13 a
TCGA-BR-6706-01A-11R-1884-13 b

## Librarys
library(limma)
## Matrix File
raw.data <-read.delim("test.txt")
attach(raw.data)
names(raw.data)
d <- raw.data[, 2:130]
rownames(d) <- raw.data[, 1]
# Pheno data file
pheno <- read.table("pheno.txt",header = F)
colnames(pheno) <- c("sample","group")
Group<-factor(pheno$group,levels=levels(pheno$group))
##To design matrix---
design<-model.matrix(~0+Group)
##Normalisation 
y <- voom(d,design,plot=TRUE)
colnames(design)
fit <-lmFit(y,design)
##Designing Contrast Matrix for group Differentiation
cont.wt<-makeContrasts(Groupb-Groupa,levels=design)
fit2 <-contrasts.fit(fit,cont.wt)
fit3<-eBayes(fit2)
DE<-topTable(fit3,number = 'all')
write.csv(DE, "limma_genes_test.csv")
selected = rownames(DE[DE$P.Value <0.05,])
# 默认是holm方法控制FWER
esetSel = y[selected, ]
heatmap(esetSel@.Data[[1]])
#p<- DE[DE$P.Value <1,]$P.Value 
#esetSela <- y[]
#p.adjust(c(0.001,0.02,0.03),"BH")

 

转载于:https://www.cnblogs.com/qiniqnyang/p/6564054.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值