annotate all stuff/.Rhistory @ 10:78f16bc92ba6 draft

Uploaded
author jfb
date Fri, 21 Feb 2020 16:37:08 -0500
parents 033dd86d3e0c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
1 ?rnorm
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
2 ?rnorm
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
3 ?rnorm
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
4 pwr
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
5 ?pwr
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
6 ??pwr
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
7 power.t.test(n=6, power = .7, type = "two.sample", alternative = "two.sided")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
8 power.t.test(n=6, power = .9, type = "two.sample", alternative = "two.sided")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
9 ?power.t.test
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
10 power.t.test(n=5, sd=1000, power = .7, type = "paired", alternative = "one.sided")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
11 10^4
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
12 power.t.test(n=5, sd=10000, power = .7, type = "paired", alternative = "one.sided")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
13 power.t.test(n=10, delta = 7, sd=10, type = "paired", alternative = "one.sided")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
14 setwd("C:/Users/John Blankenhor/Downloads/difference_finder-4dd15c41d9e7/difference_finder-4dd15c41d9e7/all stuff")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
15 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
16 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
17 Firstsubbackfreq<- read.csv("SBF1.csv", header=FALSE, stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
18 FirstSubstrateSet
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
19 EmptySubHeader<-First_unshared_motifs_table[1,]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
20 First_unshared_motifs_table<-"1RS.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
21 First_unshared_subbackfreq<-"1RSBF.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
22 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
23 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
24 Firstsubbackfreq<- read.csv("SBF1.csv", header=FALSE, stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
25 EmptySubHeader<-FirstSubstrateSet[1,]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
26 head(Firstsubbackfreq)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
27 EmptySBFHeader<-Firstsubbackfreq[,1]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
28 #ff you want ONLY FULL MOTIFS, put "YES" here, please use all caps
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
29 FullMotifsOnly_questionmark<-"NO"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
30 #If you want ONLY TRUNCATED MOTIFS, put "YES" here, please use all caps
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
31 TruncatedMotifsOnly_questionmark<-"NO"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
32 #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)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
33 Are_You_Looking_For_Commonality<-"NO"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
34 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
35 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
36 Firstsubbackfreq<- read.csv("SBF1.csv", header=FALSE, stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
37 SecondSubstrateSet<- read.csv("S2.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
38 Secondsubbackfreq<- read.csv("SBF2.csv", header=FALSE, stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
39 First_unshared_motifs_table<-"1RS.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
40 First_unshared_subbackfreq<-"1RSBF.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
41 Second_unshared_motifs_table<-"2RS.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
42 Second_unshared_subbackfreq<-"2RSBF.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
43 EmptySubHeader<-FirstSubstrateSet[1,]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
44 EmptySBFHeader<-Firstsubbackfreq[,1]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
45 FirstCentralLetters<-FirstSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
46 SecondCentralLetters<-SecondSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
47 FirstEsses<-sapply(FirstCentralLetters, grepl, pattern="S", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
48 FirstTees<-sapply(FirstCentralLetters, grepl, pattern="T", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
49 FirstWys<-sapply(FirstCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
50 SecondEsses<-sapply(SecondCentralLetters, grepl, pattern="S", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
51 SecondTees<-sapply(SecondCentralLetters, grepl, pattern="T", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
52 SecondWys<-sapply(SecondCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
53 FirstCentralLetters<-replace(FirstCentralLetters,FirstEsses,"xS")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
54 FirstCentralLetters<-replace(FirstCentralLetters,FirstTees,"xT")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
55 FirstCentralLetters<-replace(FirstCentralLetters,FirstWys,"xY")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
56 SecondCentralLetters<-replace(SecondCentralLetters,SecondEsses,"xS")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
57 SecondCentralLetters<-replace(SecondCentralLetters,SecondTees,"xT")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
58 SecondCentralLetters<-replace(SecondCentralLetters,SecondWys,"xY")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
59 FirstCentralLetters->FirstSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
60 SecondCentralLetters->SecondSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
61 if (FullMotifsOnly_questionmark!="YES"&&TruncatedMotifsOnly_questionmark!="YES"){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
62 FTLwtmotifs=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
63 FTLwtAccessionNumbers=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
64 for (i in 1:nrow(FirstSubstrateSet)){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
65 FTLwtletters<-FirstSubstrateSet[i,4:18]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
66 FTLwtletters<-FTLwtletters[FTLwtletters !="XXXXX"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
67 FTLwtletters<-paste(FTLwtletters, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
68 leftspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
69 rightspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
70 YYYmotif <- unlist(strsplit(FTLwtletters, split = ""))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
71 YYYposition <- match(x = "x", table = YYYmotif)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
72 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
73 #just 3 letters to the left of x
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
74 YYYLettersToTheLeft <- YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
75 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
76 #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
77 YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
78 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
79 #variable the user puts in is
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
80 if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
81 leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
82 rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
83 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
84 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
85 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
86 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
87 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
88 FTLwtletters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
89 FTLwtmotifs[i,1]<-FTLwtletters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
90 FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
91 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
92 if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
93 motif<-YYYmotif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
94 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
95 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
96 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
97 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
98 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
99 FTLwtletters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
100 FTLwtmotifs[i,1]<-FTLwtletters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
101 FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
102 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
103 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
104 D835Ymotifs=matrix(,nrow = nrow(SecondSubstrateSet),ncol=1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
105 D835YAccessionNumbers<-matrix(,nrow = nrow(SecondSubstrateSet),ncol = 1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
106 for (i in 1:nrow(SecondSubstrateSet)){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
107 D835letters<-SecondSubstrateSet[i,4:18]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
108 D835letters<-D835letters[D835letters !="XXXXX"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
109 D835letters<-paste(D835letters, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
110 leftspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
111 rightspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
112 YYYmotif <- unlist(strsplit(D835letters, split = ""))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
113 YYYposition <- match(x = "x", table = YYYmotif)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
114 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
115 #just 3 letters to the left of x
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
116 YYYLettersToTheLeft <- YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
117 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
118 #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
119 YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
120 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
121 #variable the user puts in is
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
122 if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
123 leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
124 rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
125 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
126 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
127 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
128 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
129 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
130 D835letters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
131 D835Ymotifs[i,1]<-D835letters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
132 D835YAccessionNumbers[i,1]<-SecondSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
133 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
134 if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
135 motif<-YYYmotif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
136 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
137 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
138 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
139 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
140 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
141 D835letters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
142 D835Ymotifs[i,1]<-D835letters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
143 D835YAccessionNumbers[i,1]<-SecondSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
144 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
145 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
146 names(FTLwtmotifs)<-FTLwtAccessionNumbers
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
147 names(D835Ymotifs)<-D835YAccessionNumbers
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
148 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
149 FTLwtmotifsFINAL<-FTLwtmotifs[!FTLwtmotifs %in% D835Ymotifs]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
150 FTLwtmotifsFINAL<-FTLwtmotifsFINAL[!duplicated(FTLwtmotifsFINAL)]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
151 D835YmotifsFINAL<-D835Ymotifs[!D835Ymotifs %in% FTLwtmotifs]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
152 D835YmotifsFINAL<-D835YmotifsFINAL[!duplicated(D835YmotifsFINAL)]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
153 if (FullMotifsOnly_questionmark!="YES"&&TruncatedMotifsOnly_questionmark!="YES"){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
154 FTLwtmotifs=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
155 FTLwtAccessionNumbers=matrix(,nrow = nrow(FirstSubstrateSet),ncol=1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
156 for (i in 1:nrow(FirstSubstrateSet)){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
157 FTLwtletters<-FirstSubstrateSet[i,4:18]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
158 FTLwtletters<-FTLwtletters[FTLwtletters !="XXXXX"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
159 FTLwtletters<-paste(FTLwtletters, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
160 leftspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
161 rightspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
162 YYYmotif <- unlist(strsplit(FTLwtletters, split = ""))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
163 YYYposition <- match(x = "x", table = YYYmotif)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
164 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
165 #just 3 letters to the left of x
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
166 YYYLettersToTheLeft <- YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
167 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
168 #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
169 YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
170 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
171 #variable the user puts in is
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
172 if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
173 leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
174 rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
175 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
176 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
177 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
178 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
179 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
180 FTLwtletters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
181 FTLwtmotifs[i,1]<-FTLwtletters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
182 FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
183 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
184 if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
185 motif<-YYYmotif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
186 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
187 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
188 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
189 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
190 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
191 FTLwtletters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
192 FTLwtmotifs[i,1]<-FTLwtletters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
193 FTLwtAccessionNumbers[i,1]<-FirstSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
194 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
195 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
196 D835Ymotifs=matrix(,nrow = nrow(SecondSubstrateSet),ncol=1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
197 D835YAccessionNumbers<-matrix(,nrow = nrow(SecondSubstrateSet),ncol = 1)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
198 for (i in 1:nrow(SecondSubstrateSet)){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
199 D835letters<-SecondSubstrateSet[i,4:18]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
200 D835letters<-D835letters[D835letters !="XXXXX"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
201 D835letters<-paste(D835letters, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
202 leftspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
203 rightspaces<-c()
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
204 YYYmotif <- unlist(strsplit(D835letters, split = ""))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
205 YYYposition <- match(x = "x", table = YYYmotif)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
206 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
207 #just 3 letters to the left of x
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
208 YYYLettersToTheLeft <- YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
209 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
210 #just 1 spot to the right of Y so LettersToTheRight<-1 because 5-3-1=1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
211 YYYLettersToTheRight <- length(YYYmotif) - YYYposition - 1
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
212 #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
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
213 #variable the user puts in is
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
214 if (YYYLettersToTheLeft < 7 | YYYLettersToTheRight < 7) {
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
215 leftspaces<-rep(" ",times=(7-YYYLettersToTheLeft))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
216 rightspaces<-rep(" ",times=7-(YYYLettersToTheRight))
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
217 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
218 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
219 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
220 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
221 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
222 D835letters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
223 D835Ymotifs[i,1]<-D835letters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
224 D835YAccessionNumbers[i,1]<-SecondSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
225 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
226 if(YYYLettersToTheLeft>6 && YYYLettersToTheRight>6){
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
227 motif<-YYYmotif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
228 #add blank spaces if the motif has less than 4 letters to the left/right
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
229 motif<-c(leftspaces,YYYmotif,rightspaces)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
230 #save that motif, which is the Y and +/- 4 amino acids, including truncation
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
231 motif<-motif[!motif %in% "x"]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
232 motif<-paste(motif, sep="", collapse="")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
233 D835letters<-motif
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
234 D835Ymotifs[i,1]<-D835letters
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
235 D835YAccessionNumbers[i,1]<-SecondSubstrateSet[i,3]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
236 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
237 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
238 names(FTLwtmotifs)<-FTLwtAccessionNumbers
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
239 names(D835Ymotifs)<-D835YAccessionNumbers
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
240 }
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
241 #ff you want ONLY FULL MOTIFS, put "YES" here, please use all caps
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
242 FullMotifsOnly_questionmark<-"NO"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
243 #If you want ONLY TRUNCATED MOTIFS, put "YES" here, please use all caps
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
244 TruncatedMotifsOnly_questionmark<-"NO"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
245 #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)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
246 Are_You_Looking_For_Commonality<-"NO"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
247 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
248 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
249 Firstsubbackfreq<- read.csv("SBF1.csv", header=FALSE, stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
250 SecondSubstrateSet<- read.csv("S2.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
251 Secondsubbackfreq<- read.csv("SBF2.csv", header=FALSE, stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
252 First_unshared_motifs_table<-"1RS.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
253 First_unshared_subbackfreq<-"1RSBF.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
254 Second_unshared_motifs_table<-"2RS.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
255 Second_unshared_subbackfreq<-"2RSBF.csv"
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
256 EmptySubHeader<-FirstSubstrateSet[1,]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
257 EmptySBFHeader<-Firstsubbackfreq[,1]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
258 FirstCentralLetters<-FirstSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
259 SecondCentralLetters<-SecondSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
260 FirstEsses<-sapply(FirstCentralLetters, grepl, pattern="S", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
261 FirstTees<-sapply(FirstCentralLetters, grepl, pattern="T", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
262 FirstWys<-sapply(FirstCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
263 SecondEsses<-sapply(SecondCentralLetters, grepl, pattern="S", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
264 SecondTees<-sapply(SecondCentralLetters, grepl, pattern="T", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
265 SecondWys<-sapply(SecondCentralLetters, grepl, pattern="Y", ignore.case=TRUE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
266 FirstCentralLetters<-replace(FirstCentralLetters,FirstEsses,"xS")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
267 FirstCentralLetters<-replace(FirstCentralLetters,FirstTees,"xT")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
268 FirstCentralLetters<-replace(FirstCentralLetters,FirstWys,"xY")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
269 SecondCentralLetters<-replace(SecondCentralLetters,SecondEsses,"xS")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
270 SecondCentralLetters<-replace(SecondCentralLetters,SecondTees,"xT")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
271 SecondCentralLetters<-replace(SecondCentralLetters,SecondWys,"xY")
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
272 FirstCentralLetters->FirstSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
273 SecondCentralLetters->SecondSubstrateSet[,11]
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
274 FirstSubstrateSet
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
275 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
276 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
277 FirstSubstrateSet
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
278 head(SecondSubstrateSet)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
279 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
280 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
281 head(SecondSubstrateSet)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
282 FirstSubstrateSet
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
283 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
284 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
285 FirstSubstrateSet
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
286 #put the names of your input files here
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
287 FirstSubstrateSet<- read.csv("S1.csv", stringsAsFactors=FALSE)
033dd86d3e0c Uploaded
jfb
parents:
diff changeset
288 SecondSubstrateSet<- read.csv("S2.csv", stringsAsFactors=FALSE)