-
Notifications
You must be signed in to change notification settings - Fork 0
/
name_table.r
46 lines (32 loc) · 1.1 KB
/
name_table.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
40
41
42
43
44
45
46
tab = read.table('res.TCGA.all.05')
ind<-which(abs(tab)>1, arr.ind=T)
write.table(file='ind',ind,sep="\t",col.names=F,row.names=F)
Exp.cols<-read.table('ExpressionMatrix.colNames',stringsAsFactors=F)
Meth.cols<-read.table('Methylation.colNames',stringsAsFactors=F)
Meth.names<-vector(len=length(ind)/2)
Gene.names<-vector(len=length(ind)/2)
for (i in 1:length(ind)/2)
{
Meth.names[i]<-(Meth.cols[ind[i,][1],1])
Gene.names[i]<-(Exp.cols[ind[i,][2],1])
}
names.df<-data.frame(Meth.names,Gene.names)
write.table(file='names_05',names.df,quote=F,sep="\t",col.names=F,row.names=F)
#meth.tab<-table(ind[,1])
#gene.tab<-table(ind[,2])
meth.ind<-ind[,1]
gene.ind<-ind[,2]
gene.freq<-vector(len=length(gene.ind))
for (i in 1:length(gene.ind))
{
gene.freq[i]<-(Gene.names[i])
}
gene.tab<-table(gene.freq)
meth.freq<-vector(len=length(meth.ind))
for (i in 1:length(meth.ind))
{
meth.freq[i]<-(Meth.names[i])
}
meth.tab<-table(meth.freq)
write.table(file='gene_freq_table_05',gene.tab,quote=F,sep="\t",col.names=F,row.names=F)
write.table(file='meth_freq_table_05',meth.tab,quote=F,sep="\t",col.names=F,row.names=F)