comparison NMF/NMF.R @ 1:a098e1274f63 draft

Uploaded
author jfb
date Wed, 28 Feb 2018 14:09:56 -0500
parents dd301fc4b54e
children
comparison
equal deleted inserted replaced
0:dd301fc4b54e 1:a098e1274f63
1 NAMEOFOUTPUTFILE<-"output1.csv" 1 NAMEOFOUTPUTFILE<-"output1.csv"
2 #this is the name of the file you will create
3
4
5 2
6 SuperAwesometrial <- read.delim2("input1.tabular", header=FALSE) 3 SuperAwesometrial <- read.delim2("input1.tabular", header=FALSE)
7 #once you've used the other script to turn the FASFA into a CSV, copypaste the filepath and name 4 #once you've used the other script to turn the FASFA into a CSV, copypaste the filepath and name
8 #of the csv into this line between the quote marks. 5 #of the csv into this line between the quote marks.
9 6
10 SBF<-read.csv("input3.csv", stringsAsFactors = FALSE) 7 SBF<-read.csv("input3.csv", stringsAsFactors = FALSE, header = FALSE)
11 8 SBF<-t(SBF)
12 9
13 PositiveMotifs <- read.csv("input2.csv", stringsAsFactors=FALSE) 10 PositiveMotifs <- read.csv("input2.csv", stringsAsFactors=FALSE)
14 #because of R reasons, it is required that the motifs in this file have blank cells instead of spaces where there is no letter in 11 #because of R reasons, it is required that the motifs in this file have blank cells instead of spaces where there is no letter in
15 #the motif 12 #the motif
13
14 YsToim<-rep("xY",times=nrow(PositiveMotifs))
15 PositiveMotifs[,11]<-YsToim
16
17
16 18
17 ################################################################################################################################ 19 ################################################################################################################################
18 #I have to paste them, then split and unlist them, then find the x and paste again 20 #I have to paste them, then split and unlist them, then find the x and paste again
19 Positive9Letters<-PositiveMotifs[,4:18] 21 Positive9Letters<-PositiveMotifs[,4:18]
20 #head(Positive9Letters) 22 #head(Positive9Letters)
21 PositiveTrueMotifs<-c() 23 PositiveTrueMotifs<-c()
22 24
23 AccessionNumbers<-SBF[,1] 25 AccessionNumbers<-as.character(SBF[2:nrow(SBF),1])
26 AccessionNumbers<-AccessionNumbers[!is.na(AccessionNumbers)]
24 ALLPOSSIBLE<-SuperAwesometrial[,1] 27 ALLPOSSIBLE<-SuperAwesometrial[,1]
25 ALLPOSSIBLE<-as.character(ALLPOSSIBLE) 28 ALLPOSSIBLE<-as.character(ALLPOSSIBLE)
26 ################################################################################################################################ 29 ################################################################################################################################
27 30
28 for (q in 1:nrow(Positive9Letters)) { 31 for (q in 1:nrow(Positive9Letters)) {
57 ################################################################################################################################ 60 ################################################################################################################################
58 61
59 #TrueMotifNums<-which(ALLPOSSIBLE %in% AccessionNumbers) 62 #TrueMotifNums<-which(ALLPOSSIBLE %in% AccessionNumbers)
60 #fihlodeANs<-c() 63 #fihlodeANs<-c()
61 for (q in 1:length(AccessionNumbers)) { 64 for (q in 1:length(AccessionNumbers)) {
62 patterno<-AccessionNumbers[q] 65 patterno<-as.character(AccessionNumbers[q])
63 location<-sapply(ALLPOSSIBLE, grepl, pattern=patterno, fixed=TRUE) 66 location<-sapply(ALLPOSSIBLE, grepl, pattern=patterno, fixed=TRUE)
64 if (sum(location)>0){ 67 if (sum(location)>0){
65 whereisit<-which(location %in% TRUE) 68 whereisit<-which(location %in% TRUE)
66 for (u in 1:length(whereisit)) { 69 for (u in 1:length(whereisit)) {
67 i<-whereisit[u] 70 i<-whereisit[u]