annotate all stuff/Difference finder MADE 7 TO 7 4-18-2019.R @ 4:74ada21ceb70 draft

Uploaded
author jfb
date Fri, 19 Apr 2019 14:00:46 -0400
parents dff99bed3f56
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
1 #I should make an SOP for this. Problems we encountered: no x in the xY motif, and the kilodemon
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
2 #the output files have both Y and xY, they shouldn't why is that happening? make it not happen
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
3 #make sure that accession numbers stay locked to each motif, somehow
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
4 #output should look just like the KALIP input
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
5
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
6 #ff you want ONLY FULL MOTIFS, put "YES" here, please use all caps
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
7 FullMotifsOnly_questionmark<-"NO"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
8 #If you want ONLY TRUNCATED MOTIFS, put "YES" here, please use all caps
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
9 TruncatedMotifsOnly_questionmark<-"NO"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
10 #if you want to find the overlap, put a "YES" here (all caps), if you want to find the non-overlap, put "NO" (all caps)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
11 Are_You_Looking_For_Commonality<-"NO"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
12
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
13
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
14 #put the names of your input files here
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
15 FirstSubstrateSet<- read.csv("Galaxy1071-(17A_TiO2_Substrates.csv).csv", stringsAsFactors=FALSE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
16 Firstsubbackfreq<- read.csv("Galaxy1072-(17A_TiO2_SubstrateBackgroundFrequency.csv).csv", header=FALSE, stringsAsFactors=FALSE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
17
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
18 SecondSubstrateSet<- read.csv("Galaxy1073-(17A_FeNTA_Substrates.csv) (1).csv", stringsAsFactors=FALSE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
19 Secondsubbackfreq<- read.csv("Galaxy1074-(17A_FeNTA_SubstrateBackgroundFrequency.csv).csv", header=FALSE, stringsAsFactors=FALSE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
20
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
21 # ThirdSubstrateSet<- read.csv("Galaxy69-BTK_PLUS_R3_Substrates.csv", stringsAsFactors=FALSE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
22 # Thirdsubbackfreq<- read.csv("Galaxy70-BTK_PLUS_R3_SubstrateBackgroundFrequency.csv", header=FALSE, stringsAsFactors=FALSE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
23
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
24 #then put the names of your output files here
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
25 # Shared_motifs_table<-"180719_GALAXY-BTK-plus-rep-OVLP-7to7-substrates.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
26 # Shared_subbackfreq_table<-"180719_GALAXY-BTK-plus-rep-OVLP-7to7-SubBackFreq.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
27
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
28 # Shared_motifs_table<-"Shared motifs 7-27-17.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
29 # Shared_subbackfreq_table<-"SubstrateBackgrounFrequency-for-shared-motifs 4 7-27-17.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
30
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
31 First_unshared_motifs_table<-"17A TIo2 without FeNTA.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
32 First_unshared_subbackfreq<-"17A TIo2 without FeNTA sbf.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
33
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
34 Second_unshared_motifs_table<-"17A FeNTA without TIo2.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
35 Second_unshared_subbackfreq<-"17A FeNTA without TIo2 sbf.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
36
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
37 # Third_unshared_motifs_table<-"R3 subs.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
38 # Third_unshared_subbackfreq<-"R3 SBF.csv"
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
39
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
40 #final note, this code is going to be unworkable if you want to make a Venn diagram of more than 3 circles. I think I'll poke around
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
41 #other languages to see if any of them can do it.
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
42 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
43
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
44
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
45
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
46
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
47
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
48 # grepl(pattern = "S", x=asdf, ignore.case = TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
49
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
50 FirstCentralLetters<-FirstSubstrateSet[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
51 SecondCentralLetters<-SecondSubstrateSet[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
52
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
53 FirstEsses<-sapply(FirstCentralLetters, grepl, pattern="S", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
54 FirstTees<-sapply(FirstCentralLetters, grepl, pattern="T", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
55 FirstWys<-sapply(FirstCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
56
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
57 SecondEsses<-sapply(SecondCentralLetters, grepl, pattern="S", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
58 SecondTees<-sapply(SecondCentralLetters, grepl, pattern="T", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
59 SecondWys<-sapply(SecondCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
60
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
61 FirstCentralLetters<-replace(FirstCentralLetters,FirstEsses,"xS")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
62 FirstCentralLetters<-replace(FirstCentralLetters,FirstTees,"xT")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
63 FirstCentralLetters<-replace(FirstCentralLetters,FirstWys,"xY")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
64
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
65 SecondCentralLetters<-replace(SecondCentralLetters,SecondEsses,"xS")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
66 SecondCentralLetters<-replace(SecondCentralLetters,SecondTees,"xT")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
67 SecondCentralLetters<-replace(SecondCentralLetters,SecondWys,"xY")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
68
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
69 FirstCentralLetters->FirstSubstrateSet[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
70 SecondCentralLetters->SecondSubstrateSet[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
71
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
72 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
73 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
74 # better version of this code written in C: what happens when two kinases share a motif, but they found that motif in two
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
75 # separate proteins thus two separate accession numbers?
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
76 # It should actually output the shared motif and BOTH accession numbers. Right now it does not, it only maps out the second
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
77 # accession number. So that needs to be fixed BUT you need to keep the commonality between a motif and its accession number
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
78 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
79 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
80 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
81 ####################################################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
82
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
83 #Create the motif sets, deciding wether or not you're looking for truncated or full here
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
84 #full only
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
85
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
86
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
87 if (Are_You_Looking_For_Commonality=="NO"){
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
88
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
89 ###############################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
90 #ALL motifs, full and truncated
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
91
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
92 if (FullMotifsOnly_questionmark!="YES"&&TruncatedMotifsOnly_questionmark!="YES"){
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
93 FTLwtmotifs=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
94 FTLwtAccessionNumbers=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
95
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
96 for (i in 1:nrow(FirstSubstrateSet)){
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
97 FTLwtletters<-FirstSubstrateSet[i,4:18]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
98 FTLwtletters<-FTLwtletters[FTLwtletters !="XXXXX"]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
99 FTLwtletters<-paste(FTLwtletters, sep="", collapse="")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
100 leftspaces<-c()
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
101 rightspaces<-c()
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
102
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
103 YYYmotif <- unlist(strsplit(FTLwtletters, split = ""))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
104 YYYposition <- match(x = "x", table = YYYmotif)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
105 #position itself tells me how much is to the left of that X by what it's number is. x at position 4 tells me that there are
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
106 #just 3 letters to the left of x
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
107
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
108 YYYLettersToTheLeft <- YYYposition - 1
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
109 #how many letters to the right SHOULD just be length(motif)-position-1 if it's 5 long and x is at 3 then Y is at 4 and there is
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
110 #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
111 YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
112 #then sanity check, we're currently looking only at +/-4, but this spot allows for up to +/- 7 as well, just depends on what the
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
113 #variable the user puts in is
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
114
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
115
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
116 if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
117 leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
118 rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
119 #add blank spaces if the motif has less than 4 letters to the left/right
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
120 motif<-c(leftspaces,YYYmotif,rightspaces)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
121 #save that motif, which is the Y and +/- 4 amino acids, including truncation
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
122 motif<-motif[!motif %in% "x"]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
123 motif<-paste(motif, sep="", collapse="")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
124 FTLwtletters<-motif
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
125 FTLwtmotifs[i,1]<-FTLwtletters
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
126 FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
127 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
128
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
129 if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
130 motif<-YYYmotif
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
131 #add blank spaces if the motif has less than 4 letters to the left/right
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
132 motif<-c(leftspaces,YYYmotif,rightspaces)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
133 #save that motif, which is the Y and +/- 4 amino acids, including truncation
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
134 motif<-motif[!motif %in% "x"]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
135 motif<-paste(motif, sep="", collapse="")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
136 FTLwtletters<-motif
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
137 FTLwtmotifs[i,1]<-FTLwtletters
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
138 FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
139
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
140
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
141 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
142
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
143 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
144
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
145 D835Ymotifs=matrix(,nrow = nrow(SecondSubstrateSet),ncol=1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
146 D835YAccessionNumbers<-matrix(,nrow = nrow(SecondSubstrateSet),ncol = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
147
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
148 for (i in 1:nrow(SecondSubstrateSet)){
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
149 D835letters<-SecondSubstrateSet[i,4:18]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
150 D835letters<-D835letters[D835letters !="XXXXX"]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
151 D835letters<-paste(D835letters, sep="", collapse="")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
152 leftspaces<-c()
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
153 rightspaces<-c()
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
154
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
155 YYYmotif <- unlist(strsplit(D835letters, split = ""))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
156 YYYposition <- match(x = "x", table = YYYmotif)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
157 #position itself tells me how much is to the left of that X by what it's number is. x at position 4 tells me that there are
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
158 #just 3 letters to the left of x
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
159
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
160 YYYLettersToTheLeft <- YYYposition - 1
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
161 #how many letters to the right SHOULD just be length(motif)-position-1 if it's 5 long and x is at 3 then Y is at 4 and there is
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
162 #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
163 YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
164 #then sanity check, we're currently looking only at +/-4, but this spot allows for up to +/- 7 as well, just depends on what the
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
165 #variable the user puts in is
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
166 if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
167 leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
168 rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
169 #add blank spaces if the motif has less than 4 letters to the left/right
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
170 motif<-c(leftspaces,YYYmotif,rightspaces)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
171 #save that motif, which is the Y and +/- 4 amino acids, including truncation
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
172 motif<-motif[!motif %in% "x"]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
173 motif<-paste(motif, sep="", collapse="")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
174 D835letters<-motif
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
175 D835Ymotifs[i,1]<-D835letters
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
176 D835YAccessionNumbers[i,1]<-SecondSubstrateSet[i,3]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
177 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
178
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
179 if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
180 motif<-YYYmotif
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
181 #add blank spaces if the motif has less than 4 letters to the left/right
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
182 motif<-c(leftspaces,YYYmotif,rightspaces)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
183 #save that motif, which is the Y and +/- 4 amino acids, including truncation
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
184 motif<-motif[!motif %in% "x"]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
185 motif<-paste(motif, sep="", collapse="")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
186 D835letters<-motif
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
187 D835Ymotifs[i,1]<-D835letters
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
188 D835YAccessionNumbers[i,1]<-SecondSubstrateSet[i,3]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
189 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
190 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
191
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
192 names(FTLwtmotifs)<-FTLwtAccessionNumbers
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
193 names(D835Ymotifs)<-D835YAccessionNumbers
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
194
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
195 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
196
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
197
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
198 FTLwtmotifsFINAL<-FTLwtmotifs[!FTLwtmotifs %in% D835Ymotifs]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
199 FTLwtmotifsFINAL<-FTLwtmotifsFINAL[!duplicated(FTLwtmotifsFINAL)]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
200
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
201 D835YmotifsFINAL<-D835Ymotifs[!D835Ymotifs %in% FTLwtmotifs]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
202 D835YmotifsFINAL<-D835YmotifsFINAL[!duplicated(D835YmotifsFINAL)]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
203
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
204
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
205 columnalheader<-c(rep(NA,36))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
206 FTLFinalMatrix<-matrix(data =columnalheader,nrow = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
207
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
208 for (k in 1:length(FTLwtmotifsFINAL)) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
209 AN<-00000
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
210 #I don't remember why, but I felt it necessary to destroy the accession number multiple times to ensure it is
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
211 #destroyed immediately after use
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
212 for (m in 1:ncol(Firstsubbackfreq)) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
213 AN <- as.character(Firstsubbackfreq[1, m])
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
214 if (grepl(pattern = AN,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
215 x = names(FTLwtmotifsFINAL[k]),
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
216 fixed = TRUE) == TRUE) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
217 outputmatrix <- as.character(Firstsubbackfreq[, m])
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
218 outputmatrix <- matrix(outputmatrix, nrow = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
219 #with that accession number, find a match in the subbackfreq file and save it here
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
220 FTLFinalMatrix<-rbind(FTLFinalMatrix,outputmatrix)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
221 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
222 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
223 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
224 FTLFinalMatrix<-FTLFinalMatrix[!duplicated(FTLFinalMatrix),]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
225 FTLFinalMatrix<-FTLFinalMatrix[2:nrow(FTLFinalMatrix),]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
226
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
227 columnalheader<-c(rep(NA,36))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
228 D835YFinalMatrix<-matrix(data =columnalheader,nrow = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
229
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
230 for (k in 1:length(D835YmotifsFINAL)) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
231 #I don't remember why, but I felt it necessary to destroy the accession number multiple times to ensure it is
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
232 #destroyed immediately after use
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
233 for (m in 1:ncol(Secondsubbackfreq)) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
234 AN <- as.character(Secondsubbackfreq[1, m])
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
235 if (grepl(pattern = AN,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
236 x = names(D835YmotifsFINAL[k]),
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
237 fixed = TRUE) == TRUE) {
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
238 outputmatrix <- as.character(Secondsubbackfreq[, m])
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
239 outputmatrix <- matrix(outputmatrix, nrow = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
240 #with that accession number, find a match in the subbackfreq file and save it here
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
241 D835YFinalMatrix<-rbind(D835YFinalMatrix,outputmatrix)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
242 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
243 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
244 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
245 D835YFinalMatrix<-D835YFinalMatrix[!duplicated(D835YFinalMatrix),]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
246 D835YFinalMatrix<-D835YFinalMatrix[2:nrow(D835YFinalMatrix),]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
247
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
248 FTLoutputmatrix<-matrix(data=c(FTLwtmotifsFINAL,names(FTLwtmotifsFINAL)),ncol = 2)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
249
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
250
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
251 FLTheader<-c("Substrate","Species","Reference","-7","-6","-5","-4","-3","-2","-1","0","1","2","3","4","5","6","7","Phosphite")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
252 # FLTheader<-unlist(FLTheader)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
253 lefthandFLT<-matrix(data = rep(NA,times=2*nrow(FTLoutputmatrix)),nrow=nrow(FTLoutputmatrix))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
254 righthandFLT<-matrix(data = rep(NA,times=1*nrow(FTLoutputmatrix)),nrow=nrow(FTLoutputmatrix))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
255 FLTaccessionset<-FTLoutputmatrix[,2]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
256 FTLmeat<-sapply(FTLoutputmatrix[,1], strsplit, "")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
257 FTLmeat<-sapply(FTLmeat, unlist)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
258 colnames(FTLmeat)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
259 FTLmeat<-t(FTLmeat)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
260
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
261 FTLoutputmatrix2<-cbind(lefthandFLT,FLTaccessionset,FTLmeat,righthandFLT)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
262 colnames(FTLoutputmatrix2)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
263 rownames(FTLoutputmatrix2)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
264 colnames(FLTheader)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
265 rownames(FLTheader)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
266
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
267
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
268 FirstCentralLettersAGAIN<-FTLoutputmatrix2[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
269
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
270 FirstEsses<-sapply(FirstCentralLettersAGAIN, grepl, pattern="S", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
271 FirstTees<-sapply(FirstCentralLettersAGAIN, grepl, pattern="T", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
272 FirstWys<-sapply(FirstCentralLettersAGAIN, grepl, pattern="Y", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
273
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
274 FirstCentralLettersAGAIN<-replace(FirstCentralLettersAGAIN,FirstEsses,"xS")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
275 FirstCentralLettersAGAIN<-replace(FirstCentralLettersAGAIN,FirstTees,"xT")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
276 FirstCentralLettersAGAIN<-replace(FirstCentralLettersAGAIN,FirstWys,"xY")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
277
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
278 FirstCentralLettersAGAIN->FTLoutputmatrix2[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
279
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
280 FTLoutputmatrix2<-rbind(FLTheader,FTLoutputmatrix2)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
281
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
282 write.table(x=FTLoutputmatrix2,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
283 file=First_unshared_motifs_table,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
284 quote=FALSE, sep=",",
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
285 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
286
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
287 columnalheader<-c("Accession Numbers",as.character(Firstsubbackfreq[1:35,1]))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
288 columnalheader<-matrix(columnalheader,nrow = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
289 write.table(x=columnalheader,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
290 file=First_unshared_subbackfreq,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
291 quote=FALSE, sep=",",
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
292 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
293
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
294 write.table(x=FTLFinalMatrix,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
295 file=First_unshared_subbackfreq,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
296 quote=FALSE, sep=",",
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
297 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
298
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
299 ############################################################################################################
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
300
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
301 D835Youtputmatrix<-matrix(data=c(D835YmotifsFINAL,names(D835YmotifsFINAL)),ncol = 2)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
302
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
303 D835Yheader<-c("Substrate","Species","Reference","-7","-6","-5","-4","-3","-2","-1","0","1","2","3","4","5","6","7","Phosphite")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
304 # D835Yheader<-unlist(D835Yheader)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
305 lefthandD835<-matrix(data = rep(NA,times=2*nrow(D835Youtputmatrix)),nrow=nrow(D835Youtputmatrix))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
306 righthandD835<-matrix(data = rep(NA,times=1*nrow(D835Youtputmatrix)),nrow=nrow(D835Youtputmatrix))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
307 D835Yaset<-D835Youtputmatrix[,2]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
308 D835meat<-sapply(D835Youtputmatrix[,1], strsplit, "")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
309 D835meat<-sapply(D835meat, unlist)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
310 colnames(D835meat)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
311 D835meat<-t(D835meat)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
312
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
313 D835Youtputmatrix2<-cbind(lefthandD835,D835Yaset,D835meat,righthandD835)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
314 colnames(D835Youtputmatrix2)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
315 rownames(D835Youtputmatrix2)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
316 colnames(D835Yheader)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
317 rownames(D835Yheader)<-NULL
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
318
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
319
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
320 SecondCentralLettersAGAIN<-D835Youtputmatrix2[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
321
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
322 SecondEsses<-sapply(SecondCentralLettersAGAIN, grepl, pattern="S", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
323 SecondTees<-sapply(SecondCentralLettersAGAIN, grepl, pattern="T", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
324 SecondWys<-sapply(SecondCentralLettersAGAIN, grepl, pattern="Y", ignore.case=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
325
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
326 SecondCentralLettersAGAIN<-replace(SecondCentralLettersAGAIN,SecondEsses,"xS")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
327 SecondCentralLettersAGAIN<-replace(SecondCentralLettersAGAIN,SecondTees,"xT")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
328 SecondCentralLettersAGAIN<-replace(SecondCentralLettersAGAIN,SecondWys,"xY")
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
329
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
330 SecondCentralLettersAGAIN->D835Youtputmatrix2[,11]
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
331
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
332 D835Youtputmatrix2<-rbind(D835Yheader,D835Youtputmatrix2)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
333
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
334 write.table(x=D835Youtputmatrix2,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
335 file=Second_unshared_motifs_table,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
336 quote=FALSE, sep=",",
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
337 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
338
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
339 columnalheader<-c("Accession Numbers",as.character(Firstsubbackfreq[1:35,1]))
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
340 columnalheader<-matrix(columnalheader,nrow = 1)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
341 write.table(x=columnalheader,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
342 file=Second_unshared_subbackfreq,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
343 quote=FALSE, sep=",",
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
344 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
345
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
346 write.table(x=D835YFinalMatrix,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
347 file=Second_unshared_subbackfreq,
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
348 quote=FALSE, sep=",",
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
349 row.names=FALSE,col.names = FALSE, na="", append=TRUE)
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
350 }
dff99bed3f56 Uploaded
jfb
parents:
diff changeset
351