comparison CHM.R @ 32:16593e40c2cd draft

Version 2.0.5
author insilico-bob
date Thu, 20 Jul 2017 15:31:06 -0400
parents 603d5c39e8dc
children 605ec840a06b
comparison
equal deleted inserted replaced
31:e01b833f5d43 32:16593e40c2cd
19 { 19 {
20 dataMatrix = read.table(dataFile, header=TRUE, sep = "\t", row.names = 1, as.is=TRUE, na.strings=c("NA","N/A","-","?")) 20 dataMatrix = read.table(dataFile, header=TRUE, sep = "\t", row.names = 1, as.is=TRUE, na.strings=c("NA","N/A","-","?"))
21 rowOrder <- createOrdering(dataMatrix, rowOrderMethod, "row", rowDistanceMeasure, rowAgglomerationMethod) 21 rowOrder <- createOrdering(dataMatrix, rowOrderMethod, "row", rowDistanceMeasure, rowAgglomerationMethod)
22 if (rowOrderMethod == "Hierarchical") { 22 if (rowOrderMethod == "Hierarchical") {
23 writeHCDataTSVs(rowOrder, rowDendroFile, rowOrderFile) 23 writeHCDataTSVs(rowOrder, rowDendroFile, rowOrderFile)
24 writeHCCut(rowOrder, rowCut, paste(rowOrderFile,".cut", sep=""))
25 } else {
26 writeOrderTSV(rowOrder, rownames(dataMatrix), rowOrderFile)
27 } 24 }
28 25
29 colOrder <- createOrdering(dataMatrix, colOrderMethod, "col", colDistanceMeasure, colAgglomerationMethod) 26 colOrder <- createOrdering(dataMatrix, colOrderMethod, "col", colDistanceMeasure, colAgglomerationMethod)
30 if (colOrderMethod == "Hierarchical") { 27 if (colOrderMethod == "Hierarchical") {
31 writeHCDataTSVs(colOrder, colDendroFile, colOrderFile) 28 writeHCDataTSVs(colOrder, colDendroFile, colOrderFile)
32 writeHCCut(colOrder, colCut, paste(colOrderFile,".cut", sep="")) 29 writeHCCut(colOrder, colCut, paste(colOrderFile,".cut", sep=""))
33 } else {
34 writeOrderTSV(colOrder, colnames(dataMatrix), colOrderFile)
35 } 30 }
36 } 31 }
37 32
38 #creates output files for hclust ordering 33 #creates output files for hclust ordering
39 writeHCDataTSVs<-function(uDend, outputHCDataFileName, outputHCOrderFileName) 34 writeHCDataTSVs<-function(uDend, outputHCDataFileName, outputHCOrderFileName)
44 39
45 data=matrix(,length(uDend$labels),2); 40 data=matrix(,length(uDend$labels),2);
46 for (i in 1:length(uDend$labels)) { 41 for (i in 1:length(uDend$labels)) {
47 data[i,1] = uDend$labels[i]; 42 data[i,1] = uDend$labels[i];
48 data[i,2] = which(uDend$order==i); 43 data[i,2] = which(uDend$order==i);
49 }
50 colnames(data)<-c("Id", "Order")
51 write.table(data, file = outputHCOrderFileName, append = FALSE, quote = FALSE, sep = "\t", row.names=FALSE)
52 }
53
54 #creates order file for non-clustering methods
55 writeOrderTSV<-function(newOrder, originalOrder, outputHCOrderFileName)
56 {
57 data=matrix(,length(originalOrder),2);
58 for (i in 1:length(originalOrder)) {
59 data[i,1] = originalOrder[i];
60 data[i,2] = which(newOrder==originalOrder[i]);
61 } 44 }
62 colnames(data)<-c("Id", "Order") 45 colnames(data)<-c("Id", "Order")
63 write.table(data, file = outputHCOrderFileName, append = FALSE, quote = FALSE, sep = "\t", row.names=FALSE) 46 write.table(data, file = outputHCOrderFileName, append = FALSE, quote = FALSE, sep = "\t", row.names=FALSE)
64 } 47 }
65 48