Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
f10560c8
Commit
f10560c8
authored
Jul 23, 2018
by
Carine Rey
Browse files
add final convergence checking of diffsel
parent
9696a2ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
7 deletions
+124
-7
lib/diffsel.ml
lib/diffsel.ml
+26
-1
lib/diffsel.mli
lib/diffsel.mli
+4
-0
lib/pipeline.ml
lib/pipeline.ml
+8
-6
lib/scripts/diffselMCMCConvergenceAnalysis.Rmd
lib/scripts/diffselMCMCConvergenceAnalysis.Rmd
+86
-0
No files found.
lib/diffsel.ml
View file @
f10560c8
...
...
@@ -31,6 +31,32 @@ let diffsel ~(phy_n:nucleotide_phylip workflow) ~(tree: _ workflow) ~(w_every:in
)
]
let
check_conv
run_diffsel
:
text_file
directory
workflow
=
let
env
=
docker_image
~
account
:
"carinerey"
~
name
:
"r_basics"
~
tag
:
"07162018"
()
in
let
script
=
tmp
//
"DiffselMCMCConvergenceAnalysis.Rmd"
in
let
trace
=
run_diffsel
/
selector
[
"myrun.trace"
]
in
let
out
=
dest
//
"out.html"
in
let
nb_new_iterations
=
dest
//
"new_iterations.txt.txt"
in
workflow
~
descr
:
"convergence_detection.DiffselMCMCConvergenceAnalysis"
[
docker
env
(
and_list
[
mkdir_p
tmp
;
mkdir_p
dest
;
cd
tmp
;
cmd
"cp"
[
file_dump
(
string
Scripts
.
diffselMCMCConvergenceAnalysis
)
;
script
]
;
cmd
"Rscript"
[
string
"-e"
;
string
{
|
"rmarkdown::render(
\"
DiffselMCMCConvergenceAnalysis.Rmd
\"
,|} ;
string {|params=list(set_trace1=
\"
|} ;
dep trace ;
string {|
\"
))"
|
};
]
;
cmd
"cp"
[
string
"DiffselMCMCConvergenceAnalysis.html"
;
ident
out
]
;
cmd
"cp"
[
string
"new_iterations.txt"
;
ident
nb_new_iterations
]
]
)
]
let
selector
run_diffsel
:
text_file
workflow
=
let
env
=
docker_image
~
account
:
"vlanore"
~
name
:
"diffsel"
~
tag
:
"v1.0"
()
in
let
package
=
tmp
//
"diffsel_script_utils.py"
in
...
...
@@ -46,7 +72,6 @@ let selector run_diffsel : text_file workflow =
and_list
[
mkdir_p
tmp
;
cd
tmp
;
(* cmd "ls" [dep run_diffsel]; (\* FIXME: PV ça sert à quoi ? *\) *)
cmd
"cp"
[
dep_ali
;
tmp_ali
];
(* required dep to link the file in the env *)
cmd
"cp"
[
dep_tree
;
tmp_tree
];
(* required dep to link the file in the env *)
...
...
lib/diffsel.mli
View file @
f10560c8
...
...
@@ -13,3 +13,7 @@ val diffsel :
val
selector
:
[
`diffsel
]
directory
workflow
->
text_file
workflow
val
check_conv
:
[
`diffsel
]
directory
workflow
->
text_file
directory
workflow
lib/pipeline.ml
View file @
f10560c8
...
...
@@ -140,8 +140,7 @@ let derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns ~no_Ne ~no_
let
repo_of_detection_result
res
=
let
det_meth_prefix
=
Convergence_detection
.
meth_string_of_result
res
in
Repo
.[
(
match
res
with
[
match
res
with
|
`Pcoc
w
->
item
[
"pcoc.results.tsv"
]
(
Pcoc
.
results
w
)
|
`Pcoc_gamma
w
->
item
[
"pcoc_gamma.results.tsv"
]
(
Pcoc
.
results
w
)
|
`Pcoc_C60
w
->
item
[
"pcoc_C60.results.tsv"
]
(
Pcoc
.
results
w
)
...
...
@@ -152,8 +151,8 @@ let repo_of_detection_result res =
|
`Topological_WAG
w
->
item
[
"Topological_WAG.results.tsv"
]
(
Topological
.
results
w
)
|
`Tdg09
w
->
item
[
"Tdg09.results.tsv"
]
(
Tamuri
.
results
w
)
|
`Multinomial
w
->
item
[
"Multinomial.results.tsv"
]
(
Multinomial
.
results
w
)
)
;
(
]
;
[
match
res
with
|
`Pcoc
w
->
item
[
"raw_results"
]
w
|
`Pcoc_gamma
w
->
item
[
"raw_results"
]
w
...
...
@@ -165,8 +164,11 @@ let repo_of_detection_result res =
|
`Topological_WAG
w
->
item
[
"raw_results"
]
w
|
`Tdg09
w
->
item
[
"raw_results"
]
w
|
`Multinomial
w
->
item
[
"raw_results"
]
w
)
;
]
]
;
match
res
with
|
`Diffsel
w
->
[
item
[
"chain_convergence_checking.html"
]
((
Diffsel
.
check_conv
w
)
/
selector
[
"out.html"
])]
|
_
->
[]
]
|>
List
.
concat
|>
Repo
.
shift
det_meth_prefix
|>
Repo
.
shift
"Detection_tools"
...
...
lib/scripts/diffselMCMCConvergenceAnalysis.Rmd
0 → 100644
View file @
f10560c8
---
title: "Diffsel MCMC convergence study"
author: "Reviewphiltrans (Bastien Boussau)"
output: html_document
params:
set_trace1: "myrun.trace"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Study of the convergence of diffsel, using 1 chain.
We use the files .trace output by diffsel.
## Reading data
```{r, echo = F}
trace1 = gsub(" ", "",params$set_trace1)
```
```{r, echo = T}
library(coda)
d1<-read.table(trace1, h=T, comment.char="&")[,1:7]
```
## Summary
```{r, echo = T}
md1 <- mcmc(d1)
print(summary(md1))
```
## Autocorrelation plots
```{r}
a<-autocorr.plot(d1, auto.layout = F)
```
## Effective sizes
### ESS
```{r}
d1ess <- apply(d1, 2, effectiveSize)
plot(d1ess, main= "ESS of chain 1")
```
## Trace plots
```{r}
for (i in 1:length(d1[1,])) {
plot(d1[,1], t="l", ylab=colnames(d1)[i])
}
```
## Convergence in quantiles (Raftery and Lewis)
We require that estimation of the 0.025 quantile should be precise at the 1% level.
```{r}
md1 <- mcmc(d1)
print(summary(md1))
test = raftery.diag(md1, r=0.01)
print(test)
required_it = as.numeric(test$resmatrix[2])
run_it = dim(md1)[1]
new_iterations = required_it - run_it
new_iterations_str = if (new_iterations > 0) {as.character(new_iterations)} else {"0"}
writeLines(new_iterations_str, "new_iterations.txt")
```
`r run_it ` iterations were already run.
`r required_it ` iterations are needed.
`r new_iterations` additionnal iterations must be run.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment