Skip to content

Commit

Permalink
Merge branch 'master' into weave_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastide committed Sep 6, 2017
2 parents 5486f7b + 39a2375 commit f60c09f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ julia: # WARNING: any change here must also be done in docs/make.jl
# - release
- 0.6
env:
- DRAW_FIG="true"
- DRAW_FIG="false"
DOCUMENTER_DEBUG="true"
notifications:
email: false
Expand Down
59 changes: 59 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# notes to maintain documentation

- built with [Documenter](https://juliadocs.github.io/Documenter.jl)
using Paul Bastide's [fork](https://github.com/pbastide/Documenter.jl)
to have the flexibility to avoid committing new figures (see below)
- deployed [here](http://crsl4.github.io/PhyloNetworks.jl/)
(go to `latest/` or `stable/`)
using github and files committed to the `gh-pages` branch.

## how it works: overview

- `.travis.yml` asks to run `docs/make.jl` after a successful test & build.
- the julia script `docs/make.jl` has 3 steps:
1. run `docs/src/man/src/make_weave.jl` to
[Weave](http://weavejl.mpastell.com/stable/) the `.jmd` files
in `docs/src/man/src/*.jmd`: turns them into markdown files placed in
`docs/src/man/*.md`, that contain the input & output of julia code.
2. run `makedocs()` from `Documenter`: make the documentation
3. run `deploydocs(...)` also from Documenter. This step calls `mkdocs`,
which turns the markdown files in `docs/.../*.md` into html files.

## about julia markdown

- The `.jmd` files that are weaved into `.md` files
are listed in `docs/src/man/src/make_weave.jl`:
**add** to this list any new `.jmd` file that needs to be added to the manual.
- `.jmd` is similar to `.Rmd`: we can choose which julia chunks to eval, echo,
show as in the REPL (`term=true`) etc.
- the default chunk options are defined on line 3 of
`docs/src/man/src/make_weave.jl`: unlike in Rstudio,
the defaults here are `results="hidden"` and `eval=false`,
so that a `{julia}` chunk won't be evaluated. Just the input code will be shown.
To run the chunk and show both input and output, use:

`{julia; eval=true; results="markup"; term=true}`

for REPL display, or

`{julia; eval=true; results="markup";}`

to show output separately from input.

## figures

- all figures produced by the code are placed in `docs/assets/figures`.
`mkdocs` exports all files in `docs/assets` during the publishing;
they are tracked on the `gh-pages` branch (not on `master`).
- the chunk label determines the name of any files
that the chunk will create if one or more figures are drawn.
Figures are tracked by git,
so it's best to control the name of the files being created. example:

`{julia; eval=true; label="truenet_opt"; fig_width=4; fig_height=4}`

- `.travis.yml` defines an environment variable: `DRAW_FIG`.
If `"false"`, any figure produced during weaving of the jmd files
are suppressed from the commit (see Paul Bastide's `/src/Documenter.jl`
[here](https://github.com/pbastide/Documenter.jl/blob/master/src/Documenter.jl#L356)
for instance), to avoid tracking unimportant changes to `png` or `pdf` images.
2 changes: 1 addition & 1 deletion src/readwrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ function symmetricNet(n::Int, i::Int, j::Int, gamma::Real, ell::Real)
clo = clo*"):$(ell)"
end
clobis = clo[1:(length(clo)-length("$(ell)"))]*"$(0.5*ell)"
tree = replace(tree, op, "(#H:$(0.5*ell)::$(gamma),"*op)
tree = replace(tree, op, "(#H:$(ell)::$(gamma),"*op)
tree = replace(tree, clo, clobis*"):$(0.5*ell)")
## end hyb
op = "A$(2^(i-1)+1):$(ell)"
Expand Down
12 changes: 7 additions & 5 deletions src/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ function setGammas!(net::HybridNetwork, gammas::Vector)
else
net.nodes_changed[i].edge[majorHybrid][2].gamma = 1 - gammas[i]
end
net.nodes_changed[i].edge[minorHybrid][1].gamma = 1 - gammas[i]
end
end
return nothing
Expand All @@ -1176,7 +1175,9 @@ end
function maxLambda(times::Vector, V::MatrixTopologicalOrder)
maskTips = indexin(V.tipNumbers, V.nodeNumbersTopOrder)
maskNodes = indexin(V.internalNodeNumbers, V.nodeNumbersTopOrder)
return maximum(times[maskTips]) / maximum(times[maskNodes])
return minimum(times[maskTips]) / maximum(times[maskNodes])
# res = minimum(times[maskTips]) / maximum(times[maskNodes])
# res = res * (1 - 1/5/maximum(times[maskTips]))
end

function transform_matrix_lambda!{T <: AbstractFloat}(V::MatrixTopologicalOrder, lam::T,
Expand All @@ -1203,12 +1204,13 @@ function logLik_lam{T <: AbstractFloat}(lam::T,
msng=trues(length(Y))::BitArray{1}, # Which tips are not missing ?
ind=[0]::Vector{Int})
# Transform V according to lambda
transform_matrix_lambda!(V, lam, gammas, times)
Vp = deepcopy(V)
transform_matrix_lambda!(Vp, lam, gammas, times)
# Fit and take likelihood
fit_lam = phyloNetworklm_BM(X, Y, V; msng=msng, ind=ind)
fit_lam = phyloNetworklm_BM(X, Y, Vp; msng=msng, ind=ind)
res = - loglikelihood(fit_lam)
# Go back to original V
transform_matrix_lambda!(V, 1/lam, gammas, times)
# transform_matrix_lambda!(V, 1/lam, gammas, times)
return res
end

Expand Down

0 comments on commit f60c09f

Please sign in to comment.