-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-cnetmcmc.sh
65 lines (49 loc) · 1.96 KB
/
run-cnetmcmc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# This script is used to run program cnetmcmc.
# Use MCMC to infer tree
# With configuration file
config_file=./mcmc.cfg
seed=$RANDOM
####################### Parameters related to input ###########################
Ns=3 # The number of regions
# input parameters
dir="./example" # The output directory
# prefix=sim-data-N5-cons1-model1-1
prefix=sim-data-1
is_total=1 # If yes, the input is total copy number
input=$dir/"$prefix"-cn.txt.gz
# input=$dir/"$prefix"-allele-cn.txt.gz
# The input file of sample timings (optional, required for estimating mutation rates)
times=$dir/"$prefix"-rel-times.txt
if [[ ! -f $times ]]; then
times=""
fi
# Optional reference real tree
# rtree=$dir/"$prefix"-tree.txt
rtree=""
init_tree=0 # Types of starting tree for MCMC. 0: random tree, 1: provided tree, 2: random tree with the same topology as real tree
file_itree=$dir/"$prefix"-tree.txt
################################################################################
####################### Set output directory and run the program ###############
# output parameters
odir=$dir/mcmc
if [[ ! -d $odir ]]; then
mkdir -p $odir
fi
suffix=$prefix
echo "Start running cnetmcmc"
# Run multiple chains
for i in {1..2}
do
# seed=$i
echo "chain $i"
# Use the suffix of MrBayes for compatibility with RWTY
trace_param_file=$odir/mcmc_"$suffix"_${i}.p
trace_tree_file=$odir/mcmc_"$suffix"_${i}.t
sum_tree_file=$odir/sum-mcmc_"$suffix"_${i}.txt
echo "seed $seed" > $odir/std_mcmc_"$suffix"_${i}
code/cnetmcmc -s $Ns --is_total $is_total -c $input -t "$times" --rtree "$rtree" --trace_param_file $trace_param_file --trace_tree_file $trace_tree_file --config_file $config_file --init_tree $init_tree --file_itree $file_itree --seed $seed >> $odir/std_mcmc_"$suffix"_${i}
# Summarize the sampled trees into a maximum credibility tree with median heights
# treeannotator -burnin 10 -heights median $trace_tree_file $sum_tree_file
done
echo "Finish running cnetmcmc"