-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2vs2.R
39 lines (33 loc) · 1.26 KB
/
2vs2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(tidyverse)
library(DESeq2)
#import data
setwd("D:/yyy/Merge_HUADA_YK_HUADA2/")
mycounts<-read.table("Mergedata.txt",header = TRUE,row.names = 1,sep ="\t" )
mycounts_new<-mycounts
a<-colnames(mycounts)
c<-data.frame(0,0,0,0,0,0)
colnames(c)<-c("j","k","p","q","y","z")
for (j in 1:12) {
for (k in (j+1):13) {
for (p in 14:32) {
for (q in (p+1):33) {
mycounts<-mycounts_new[,c(a[j],a[k],a[p],a[q])]
condition<-factor(c(rep("KO",2),rep("WT",2)),levels = c("WT","KO"))
colData<-data.frame(row.names = colnames(mycounts),condition)
dds <- DESeqDataSetFromMatrix(mycounts, colData, design= ~ condition)
dds <- DESeq(dds)
res= as.data.frame(results(dds))
res_hi<-res[which(res$padj <0.05 & res$log2FoldChange >0.58),]
res_lo<-res[which(res$padj <0.05 & res$log2FoldChange <(-0.58)),]
y<-length(rownames(res_hi))
z<-length(rownames(res_lo))
if(y>z & (y/z)>=4){
b<-as.data.frame(t(as.data.frame(c(j,k,p,q,y,z))))
colnames(b)<-c("j","k","p","q","y","z")
c<-rbind(c,b)
write.table(mycounts,file = paste0("mycounts",j,k,p,q,".txt"),sep = "\t")
}
}
}
}
}