diff kinatestid_r/Kinatest-R.R @ 18:e16ca3e9fc49 draft

Uploaded
author jfb
date Tue, 17 Apr 2018 13:07:41 -0400
parents 26ef4add9f7b
children 9e520c365624
line wrap: on
line diff
--- a/kinatestid_r/Kinatest-R.R	Wed Feb 28 14:09:19 2018 -0500
+++ b/kinatestid_r/Kinatest-R.R	Tue Apr 17 13:07:41 2018 -0400
@@ -19,7 +19,7 @@
 SubstrateBackgroundFrequency<-Sub
 
 args = commandArgs(trailingOnly=TRUE)
-TodaysKinase<-args[1]
+TodaysKinase<-as.character(args[1])
 
 
 
@@ -528,42 +528,40 @@
 SetOfAAs<-c("Letter","A","C","D","E","F","G","H","I","K","L","M","N","P","Q","R","S","T","V","W","Y")
 
 
-SumOfSigmaAAs<-c(1:15)
+SumOfSigmaAAs<-c(1:9)
 
-for (i in 1:15){
+for (i in 1:9){
   SumOfSigmasValue<-0
   for (j in 1:20){
-        value<-0
+    value<-0
     if (SDtable[j,i]>2){
-      value<-sum(substrates[,i]==SetOfAAs[j])
+      q=j+1
+      value<-sum(substrates[,i]==SetOfAAs[q])
     }
     SumOfSigmasValue<-SumOfSigmasValue+value
   }
   SumOfSigmaAAs[i]<-SumOfSigmasValue
 }
 
-# AAs1<-length(substrates[,1])-sum(substrates[,1]=="")
-# AAs2<-length(substrates[,2])-sum(substrates[,2]=="")
-# AAs3<-length(substrates[,3])-sum(substrates[,3]=="")
-# AAs4<-length(substrates[,4])-sum(substrates[,4]=="")
-# AAs5<-length(substrates[,5])-sum(substrates[,5]=="")
-# AAs6<-length(substrates[,6])-sum(substrates[,6]=="")
-# AAs7<-length(substrates[,7])-sum(substrates[,7]=="")
-# AAs8<-length(substrates[,8])-sum(substrates[,8]=="")
-# AAs9<-length(substrates[,9])-sum(substrates[,9]=="")
-# 
-# 
-# 
-# #AAsAtPositions<-c(AAs1,AAs2,AAs3,AAs4,AAs5,AAs6,AAs7,AAs8,AAs9)
+AAs1<-length(substrates[,1])-sum(substrates[,1]=="")
+AAs2<-length(substrates[,2])-sum(substrates[,2]=="")
+AAs3<-length(substrates[,3])-sum(substrates[,3]=="")
+AAs4<-length(substrates[,4])-sum(substrates[,4]=="")
+AAs5<-length(substrates[,5])-sum(substrates[,5]=="")
+AAs6<-length(substrates[,6])-sum(substrates[,6]=="")
+AAs7<-length(substrates[,7])-sum(substrates[,7]=="")
+AAs8<-length(substrates[,8])-sum(substrates[,8]=="")
+AAs9<-length(substrates[,9])-sum(substrates[,9]=="")
+AAsAtPositions<-c(AAs1,AAs2,AAs3,AAs4,AAs5,AAs6,AAs7,AAs8,AAs9)
 # AAsAtPositions<-c(length(substrates[,1]),length(substrates[,2]),length(substrates[,3]),length(substrates[,4]),
 #                   length(substrates[,5]),length(substrates[,6]),length(substrates[,7]),length(substrates[,8]),
 #                   length(substrates[,9]))
 
-SumOfExpectedSigmaAAs<-c(1:15)
-for (i in 1:15){
+SumOfExpectedSigmaAAs<-c(1:9)
+for (i in 1:9){
   ExpectedValue<-0
   for (j in 1:20){
-        value<-0
+    value<-0
     if (SDtable[j,i]>2){
       value<-AllMeans[j]
     }
@@ -572,7 +570,14 @@
   SumOfExpectedSigmaAAs[i]<-ExpectedValue*(length(substrates[,i])-sum(substrates[,i]%in% ""))/100
 }
 
-SelectivityRow<-SumOfSigmaAAs/SumOfExpectedSigmaAAs
+#SelectivityRow<-SumOfSigmaAAs/SumOfExpectedSigmaAAs
+
+SelectivityRow<-rep(0,times=9)
+
+for (q in 1:9) {
+  SelectivityRow[q]<-(SumOfSigmaAAs[q]/SumOfExpectedSigmaAAs[q])*(SumOfSigmaAAs[q]/AAsAtPositions[q])
+}
+
 SelectivitySheet<-rbind(SumOfSigmaAAs,SumOfExpectedSigmaAAs,SelectivityRow)
 
 SetOfAAs<-matrix(data = SetOfAAs,ncol = 1)