You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorial.md
+25-7Lines changed: 25 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
##Tutorial
1
+
# Tutorial
2
2
3
3
To run the package, first install julia ([here](https://julialang.org/downloads/)).
4
4
To create a local environment with the package `cd` into your work directory and
@@ -18,7 +18,7 @@ You can now load the installed packages:
18
18
using HetDister, HistogramBinnings, CSV, DataFrames, DataFramesMeta
19
19
```
20
20
21
-
###Preparing input data
21
+
## Preparing input data
22
22
For example, suppose you have a `.vcf` file with called variants you want to analyze. Then, in the most basic case, you may compute distances between heterozygous SNPs as follows:
23
23
```julia
24
24
f ="/myproject/myfavouritespecies.vcf"
@@ -41,10 +41,26 @@ ils = df.POS[2:end] .- df.POS[1:end-1]
41
41
```
42
42
Now we have a vector of intervals `ils`.
43
43
44
-
###Fitting demographic models
44
+
## Fitting and comparing demographic models
45
45
The tool require three inputs: a vector of IBS segments lengths, a mutation rate and
46
-
a recombination rate (both per bp per generation). First, IBSs need to be placed into
47
-
a histogram.
46
+
a recombination rate (both per bp per generation). Additionally, we need to choose
47
+
a range of demographic models with epochs of piecewise constant effective size.
48
+
49
+
In the simplest use case we can just call
50
+
```julia
51
+
mu =1e-8
52
+
rho =1e-8
53
+
results =demoinfer(ils, 1:8, mu, rho)
54
+
```
55
+
and the 8 models will be saved in `results.fits`.
56
+
Then we can obtain the most probable model in the set with
57
+
```julia
58
+
best =compare_models(results.fits)
59
+
```
60
+
61
+
### More advanced options
62
+
First IBS spectrum is obtained as an histogram and the binning can be
63
+
controlled by the function `adapt_histogram` and it keyword arguments
48
64
```julia
49
65
h =adapt_histogram(ils)
50
66
mu =1e-8
@@ -53,10 +69,12 @@ rho = 1e-8
53
69
Then we set up the `FitOptions` object that contains several parameters for the optimization.
54
70
We stick with default values and only initialize with the three required inputs:
55
71
```julia
56
-
fop =FitOptions(sum(ils), mu, rho)
72
+
fop =FitOptions(sum(ils), length(ils), mu, rho)
57
73
```
58
74
And we fit 8 different model, with a number of epochs in the range 1 to 8:
59
75
```julia
60
76
results =demoinfer(h_obs, 1:8, fop)
61
77
```
62
-
The fitted models can be accessed with `results.fits`.
78
+
The fitted models can be accessed with `results.fits`.
79
+
80
+
See [Diagnostics](@ref) to inspect the result and assess goodness of fit and optimization convergence.
0 commit comments