Skip to content

Commit 3e3c2e0

Browse files
committed
updated hpc scripts
1 parent 9735019 commit 3e3c2e0

File tree

10 files changed

+199
-16
lines changed

10 files changed

+199
-16
lines changed

csh/calc_sipw_submit2slurm.csh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/csh
22

33
set imps = $argv[1]
4-
set imp = 1
4+
set imp = 6
55

66
while ($imp <= $imps)
77
echo $imp

csh/run_zinb+.R

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# getting arguments form command line:
2+
# https://quantitative-ecology.blogspot.no/2007/08/including-arguments-in-r-cmd-batch-mode.html
3+
4+
#R CMD BATCH --no-save --no-restore '--args a=1 i=1 c=1)' run_zinb.R test.out &
5+
# R --slave --vanilla --file=run_zinb.R --args a=2 i=3 scratch=$SCRATH "s=string with spaces" > output
6+
# Rscript myscript.R $a $i $c
7+
8+
9+
args=(commandArgs(TRUE))
10+
11+
m = args[1]
12+
a = args[2]
13+
i = args[3]
14+
c = args[4]
15+
16+
17+
library(rstan)
18+
19+
#sm = stan_model("zinb_deltaARCClog_2SB.stan", allow_undefined = TRUE,
20+
# includes = paste0('\n#include "',
21+
# file.path(getwd(), 'get_iter.hpp'), '"\n'),
22+
# auto_write = T)
23+
if (m == 1) {
24+
sm = readRDS("../stan/bebi_logit_deltaAR_2SB.rds")
25+
} else {
26+
sm = 1
27+
}
28+
load(paste0("../data/pADHD_2SB/a",a,"_i",i,"+.Rdata"))
29+
30+
setwd(system("echo $SCRATCH", intern = T))
31+
32+
sample_file = paste0("tmp",standata$id,".csv")
33+
34+
sf = sampling(sm,
35+
data = standata,
36+
iter = 750,
37+
warmup = 250,
38+
chain = 1,
39+
sample_file = sample_file,
40+
control = list(max_treedepth = 20)
41+
)
42+
43+
sroot = "/cluster/home/guidopb/programming/R/representativeness/IPW/samples/pADHD/"
44+
45+
file.copy(sample_file,
46+
paste0(sroot,
47+
"bebi_a",a,"_i",i,"_c",c,"_",
48+
ifelse(m == 1,"logit","logit"),"+.csv"),
49+
overwrite = T)
50+
51+
save(sf,file = paste0(sroot,
52+
"bebi_a",a,"_i",i,"_c",c,"_",
53+
ifelse(m == 1,"logit","logit"),"+.Rdata"))
54+
55+

csh/run_zinb+raw.R

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# getting arguments form command line:
2+
# https://quantitative-ecology.blogspot.no/2007/08/including-arguments-in-r-cmd-batch-mode.html
3+
4+
#R CMD BATCH --no-save --no-restore '--args a=1 i=1 c=1)' run_zinb.R test.out &
5+
# R --slave --vanilla --file=run_zinb.R --args a=2 i=3 scratch=$SCRATH "s=string with spaces" > output
6+
# Rscript myscript.R $a $i $c
7+
8+
9+
args=(commandArgs(TRUE))
10+
11+
m = args[1]
12+
a = args[2]
13+
i = args[3]
14+
c = args[4]
15+
16+
17+
library(rstan)
18+
19+
#sm = stan_model("zinb_deltaARCClog_2SB.stan", allow_undefined = TRUE,
20+
# includes = paste0('\n#include "',
21+
# file.path(getwd(), 'get_iter.hpp'), '"\n'),
22+
# auto_write = T)
23+
if (m == 1) {
24+
sm = readRDS("../stan/bebi_logit_deltaAR_2SB+raw.rds")
25+
} else {
26+
sm = 1
27+
}
28+
load(paste0("../data/pADHD_2SB/a",a,"_i",i,"x+raw.Rdata"))
29+
30+
setwd(system("echo $SCRATCH", intern = T))
31+
32+
sample_file = paste0("tmp",standata$id,".csv")
33+
34+
sf = sampling(sm,
35+
data = standata,
36+
iter = 750,
37+
warmup = 250,
38+
chain = 1,
39+
sample_file = sample_file,
40+
control = list(max_treedepth = 20)
41+
)
42+
43+
sroot = "/cluster/home/guidopb/programming/R/representativeness/IPW/samples/pADHD/"
44+
45+
file.copy(sample_file,
46+
paste0(sroot,
47+
"bebi_a",a,"_i",i,"_c",c,"_",
48+
ifelse(m == 1,"logit","logit"),"x+raw.csv"),
49+
overwrite = T)
50+
51+
save(sf,file = paste0(sroot,
52+
"bebi_a",a,"_i",i,"_c",c,"_",
53+
ifelse(m == 1,"logit","logit"),"x+raw.Rdata"))
54+
55+

csh/run_zinb.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ library(rstan)
2121
# file.path(getwd(), 'get_iter.hpp'), '"\n'),
2222
# auto_write = T)
2323
if (m == 1) {
24-
sm = readRDS("../stan/zinb_deltaARCC_2SB.rds")
24+
sm = readRDS("../stan/bebi_logit_deltaAR_2SB.rds")
2525
} else {
26-
sm = readRDS("../stan/zinb_deltaARCClog_2SB.rds")
26+
sm = 1
2727
}
2828
load(paste0("../data/pADHD_2SB/a",a,"_i",i,".Rdata"))
2929

@@ -36,18 +36,20 @@ sf = sampling(sm,
3636
iter = 750,
3737
warmup = 250,
3838
chain = 1,
39-
init = list(list(scale = 1e-2)),
4039
sample_file = sample_file,
4140
control = list(max_treedepth = 20)
4241
)
4342

4443
sroot = "/cluster/home/guidopb/programming/R/representativeness/IPW/samples/pADHD/"
44+
4545
file.copy(sample_file,
4646
paste0(sroot,
47-
"samples_m1_a",a,"_i",i,"_c",c,"_v9x_",
48-
ifelse(m == 1,"lin","log"),"sb.csv"),
47+
"bebi_a",a,"_i",i,"_c",c,"_",
48+
ifelse(m == 1,"logit","logit"),".csv"),
4949
overwrite = T)
5050

5151
save(sf,file = paste0(sroot,
52-
"samples_m1_a",a,"_i",i,"_c",c,"_v9x_",
53-
ifelse(m == 1,"lin","log"),"sb.Rdata"))
52+
"bebi_a",a,"_i",i,"_c",c,"_",
53+
ifelse(m == 1,"logit","logit"),".Rdata"))
54+
55+

csh/run_zinbR.sl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#SBATCH --account=nn9469k
77

88
# Wall clock limit:
9-
#SBATCH --time=48:00:00
9+
##SBATCH --time=48:00:00
1010

1111
# Max memory usage:
1212
##SBATCH --mem-per-cpu=64G --partition=hugemem
13-
#SBATCH --mem-per-cpu=4G
13+
#SBATCH --mem-per-cpu=8G
1414

1515
#SBATCH --ntasks=1
1616
#SBATCH --ntasks-per-node=1

csh/run_zinbRx.sl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/csh
2+
3+
4+
5+
# Project:
6+
#SBATCH --account=nn9469k
7+
8+
# Wall clock limit:
9+
##SBATCH --time=48:00:00
10+
11+
# Max memory usage:
12+
##SBATCH --mem-per-cpu=64G --partition=hugemem
13+
#SBATCH --mem-per-cpu=8G
14+
15+
#SBATCH --ntasks=1
16+
#SBATCH --ntasks-per-node=1
17+
#SBATCH --nodes=1
18+
19+
##SBATCH --qos=lowpri
20+
21+
set model = $argv[1]
22+
set analysis = $argv[2]
23+
set imp = $argv[3]
24+
set chain = $argv[4]
25+
26+
module purge
27+
module load R/3.5.0.gnu
28+
module load gcc/6.3.0
29+
30+
Rscript run_zinbx+raw.R $model $analysis $imp $chain > a{$analysis}_i{$imp}_c{$chain}_m{$model}x.Rout
31+

csh/submit2slurm.csh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ else
1111
endif
1212

1313
set cn = $start_chain
14-
set imp = 1
14+
set imp = 2
15+
16+
if ($analysis == 2) then
17+
set time = 12
18+
else
19+
set time = 12
20+
endif
1521

1622
while ($imp <= $imputations)
1723
while ($cn <= $end_chain)
1824
set outfile = /cluster/home/guidopb/programming/R/representativeness/IPW/csh/slurm-%j-a{$analysis}-i{$imp}-c{$cn}.out
19-
sbatch -J a{$analysis}-i{$imp}-c{$cn} -o $outfile run_zinbR.sl 1 $analysis $imp $cn
25+
sbatch -J a{$analysis}-i{$imp}-c{$cn} -o $outfile --time={$time}:00:00 run_zinbR.sl 1 $analysis $imp $cn
2026
echo $outfile
2127
@ cn++
2228
sleep 3

csh/submit2slurmx.csh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/csh
2+
3+
set analysis = $argv[1]
4+
set start_chain = $argv[2]
5+
set end_chain = $argv[3]
6+
7+
if ($#argv == 4) then
8+
set imputations = $argv[4]
9+
else
10+
set imputations = 1
11+
endif
12+
13+
set cn = $start_chain
14+
set imp = 11
15+
16+
if ($analysis == 2) then
17+
set time = 4
18+
else
19+
set time = 4
20+
endif
21+
22+
while ($imp <= $imputations)
23+
while ($cn <= $end_chain)
24+
set outfile = /cluster/home/guidopb/programming/R/representativeness/IPW/csh/slurm-%j-a{$analysis}-i{$imp}-c{$cn}x.out
25+
sbatch -J a{$analysis}-i{$imp}-c{$cn}x -o $outfile --time={$time}:00:00 run_zinbRx.sl 1 $analysis $imp $cn
26+
echo $outfile
27+
@ cn++
28+
sleep 3
29+
end
30+
set cn = $start_chain
31+
@ imp++
32+
end
33+
34+

csh/submit_all.csh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
csh submit2slurm.csh 1 1 1 3 5
2-
#csh submit2slurm.csh 1 2 1 3 5
3-
csh submit2slurm.csh 1 3 1 3 5
1+
csh submit2slurmx.csh 1 1 3 20
2+
csh submit2slurmx.csh 2 1 3 20
3+
csh submit2slurmx.csh 3 1 3 20
44

stan/compile_stanmodel.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
library(rstan)
22

3-
sm = stan_model("bebi_logit_deltaAR_2SB.stan", allow_undefined = TRUE,
3+
sm = stan_model("bebi_logit_deltaAR_2SB+raw.stan", allow_undefined = TRUE,
44
includes = paste0('\n#include "',
55
file.path(getwd(), 'get_iter.hpp'), '"\n'),
66
auto_write = T)

0 commit comments

Comments
 (0)