Skip to content

Commit

Permalink
fix to sdist; user variable to set ncores etc
Browse files Browse the repository at this point in the history
  • Loading branch information
czarrar committed Oct 5, 2012
1 parent d496f00 commit 843ef1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion simulations/lib_utils.R
@@ -1,6 +1,6 @@
zdist <- function(mat, method="cor") {
switch(method,
cor = 1 - corr(mat)
cor = 1 - corr(mat),
stop("Unsupported method for zdist")
)
}
21 changes: 16 additions & 5 deletions simulations/main.R
@@ -1,8 +1,14 @@
source("lib_mdmr.R")
library(igraph)
library(plyr)
library(doMC)

source("lib_mdmr.R")
source("lib_utils.R")

# Settings
run_parallel <- FALSE
run_parallel <- TRUE
ncores <- 3
nthreads <- 2
nsubs <- 200
nnodes <- 100
nnei <- 10
Expand All @@ -13,8 +19,14 @@ num_conns_change_per_node <- c(1:5, 6, 8, 10, 12, 15)

if (run_parallel) {
library(doMC)
registerDoMC(4)
registerDoMC(ncores)

if (system("hostname", intern=T) == "rocky") {
library(blasctl)
omp_set_num_threads(nthreads)
}
}

grp <- factor(rep(c("A","B"),each=nsubs/2))


Expand All @@ -24,7 +36,6 @@ grp <- factor(rep(c("A","B"),each=nsubs/2))
###

# Generate group adjacency matrix
library(igraph)
g <- watts.strogatz.game(1, nnodes, nnei, 0.05)
g <- simplify(g) # removes loops and multiple connections
group.adj <- get.adjacency(g)
Expand Down Expand Up @@ -61,7 +72,7 @@ subjects.wt <- laply(1:nsubs, function(i) {
subject.wt <- group.wt
subject.wt[conns] <- subject.wt[conns] + runif(length(conns), min=-0.1, max=0.1)
subject.wt
}, .progress="text", .parallel=run_parallel)
}, .progress="text", .parallel=F)

# 1. create group difference (i.e., add effect size)
subjects_with_diffs <- laply(effect_sizes, function(es) {
Expand Down

0 comments on commit 843ef1e

Please sign in to comment.