[Swift-commit] r2140 - SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Jul 18 13:19:03 CDT 2008


Author: skenny
Date: 2008-07-18 13:19:03 -0500 (Fri, 18 Jul 2008)
New Revision: 2140

Added:
   SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedman.R
Log:
perm stuff

Added: SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedman.R
===================================================================
--- SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedman.R	                        (rev 0)
+++ SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedman.R	2008-07-18 18:19:03 UTC (rev 2140)
@@ -0,0 +1,39 @@
+#---- doing friedman permutations
+#---- coded Wednesday; July 2, 2008
+
+#---- this is the function used in the aggregate:
+FriedmanPerm <- function(x){
+    mm <- matrix(nrow=24,ncol=3)
+    mm[,1] = x[1:24]
+    mm[,2] = x[25:48]
+    mm[,3] = x[49:72]
+    a <- mm[subj_resamp,cond_resamp]
+    b <- mm[subj_same,]
+    mm_shuffle <- rbind(a,b)
+    return(friedman.test(mm_shuffle)[[1]][[1]])
+}
+
+#---- Swift housekeeping:
+allinputs <- Sys.getenv("R_SWIFT_ARGS")
+print(Sys.getenv("R_SWIFT_ARGS"));
+outname <- noquote(strsplit(allinputs," ")[[1]][1])
+outname2 <- noquote(strsplit(allinputs," ")[[1]][2])
+configLine <- noquote(strsplit(allinputs," ")[[1]][3])
+
+inputfile <- Sys.getenv("R_INPUT")
+print(inputfile)
+Query_out <- as.matrix(read.table(inputfile))
+config <- as.matrix(read.table("perm_config_file.txt"))
+cond_resamp <- as.vector(config[configLine,25:27])
+subj_resamp <- which(as.vector(config[configLine,1:24])==1)
+subj_same <- which(as.vector(config[configLine,1:24])==0)
+
+
+#---- this is where the fun begins:
+data_stack <- stack(data.frame(Query_out[,3:5]))[1]
+vertices <- Query_out[,2]
+nn <- data.frame(cbind(vertices,data_stack))
+m <- matrix(nrow=length(as.integer(levels(as.factor(vertices)))),ncol=2)
+m[,1] <- as.integer(levels(as.factor(vertices)))
+m[,2] <- aggregate(nn$values, list(nn$vertices),FriedmanPerm)[,2]
+write.table(round(m,5), file=paste(outname2,outname,".txt",sep=""), row.names=FALSE, col.names=FALSE, quote=F)




More information about the Swift-commit mailing list