-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path7_geneTranscript.r
79 lines (64 loc) · 2.39 KB
/
7_geneTranscript.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -----------------------------------------
# Updated Date: 2014/03/24
# Input: Files generated by gene_deep.r and combineTtl.r are inputs.
# Output: The same items whose expression difference are significant between the control and treatment on both gene level
# and transcript level.
# Environemt: Linux or Windows
# Description: Matching processing is processed to check whether gene name is in the label of transcript name. If it is,
# a match was achieved and then was output.
# -----------------------------------------
# read gene
getGene <- read.table("6_gene_potential.csv",row.names=1,header=T,sep=",")
seqName <- c("gCtlRead","gTreRead","gCtlReadN","gTreReadN","gFold","gExDif","gProb")
colnames(getGene) <- seqName
# split function
getGeneName <- function(line) {
getRes <- strsplit(line[1],"\\|")
return(getRes[[1]][2])
}
getTranscriptName <- function(line) {
getRes <- strsplit(line[1],"\\|")
return(getRes[[1]][1])
}
# read transcript (origin)
getTranscript <- read.table("5_transcript.csv",row.names=1,header=T,sep=",")
totalName <- rownames(getTranscript)
getTranscript <- cbind(totalName,getTranscript)
geneName <- apply(getTranscript,1,getGeneName)
transcriptName <- apply(getTranscript,1,getTranscriptName)
getTranscript <- (cbind(geneName,transcriptName,getTranscript[,-9]))[,-3]
rownames(getTranscript) <- getTranscript[,2]
getTranscript <- getTranscript[,-2]
seqName <- c("geName","trCtlRead","trTreRead","trCtlReadN","trTreReadN","trFold","trExDif","trProb")
colnames(getTranscript) <- seqName
# find the same geneName
newData <- rownames(getGene)
newData2 <- getTranscript[,1]
multiData <- c()
for(i in 1:length(newData)) {
for(j in 1:length(newData2)) {
if(newData[i] == newData2[j]) {
multiData <- c(multiData,newData[i])
}
}
}
multiData <- unique(multiData)
trName <- rownames(getTranscript)
getTranscript <- cbind(trName,getTranscript)
# combine gene and transcript
newCombine <- c()
newCombineData <- c()
for(i in 1:length(getTranscript[,1])) {
for(j in 1:length(multiData)) {
if(getTranscript[i,2] == multiData[j]) {
getTranscriptData <- getTranscript[i,]
getGeneData <- getGene[multiData[j],]
newCombine <- cbind(getTranscriptData,getGeneData)
newCombineData <- rbind(newCombineData, newCombine)
break
}
}
}
newCombineData <- newCombineData[,-1]
# write table
write.table(newCombineData,"7_bothGeTr.csv",sep=",",row.names = TRUE,col.names = TRUE)