# Outcrossing Populations

#### Statistical Genetics Lab
Department of Genetics
Luiz de Queiroz College of Agriculture
University of São Paulo

#### 2017-10-18

The following example is intended to show the usage of `OneMap` functions for linkage mapping in outcrossing (non-inbred) populations. With basic knowledge of R syntax, one should have no problems using it. If you are not familiar with R, we recommend reading the vignette Introduction to R.

Hopefully these examples will be clear enough to help any user to understand its functionality and start using it. You do not need to be an expert in R to build your linkage map, but some concepts are necessary and will help you through the process.

There is a github `OneMap` version which is constantly improved, we strong recommend all users to try this version. In `augusto-garcia/onemap` github page you can find instructions to install the package from github and also more fancy tutorials.

# Creating the data file

This step may be quite difficult, because the data file is not very simple and some errors can occur while reading it. The input file format is similar to that used by MAPMAKER/EXP (Lander et al., 1987), so experienced users of genetic analysis software should be already familiar with this scenario.

Basically, the input file is a text file, where the first line indicates the cross type and the second line provides information about the number of individuals, the number of markers, the presence of physical marker locations and the presence of phenotypic data. The third line contains sample IDs. Then, the genotype information is included separately for each marker. The character `*` indicates the beginning of information input for a new marker, followed by the marker name. Next, there is a code indicating the marker type, according to Wu’s et al. (2002a) notation. Actually, it is recommended to check Wu’s et al. (2002a) paper before using `OneMap`.

Marker types must be one of the following: `A.1`, `A.2`, `A.3`, `A.4`, `B1.5`, `B2.6`, `B3.7`, `C.8`, `D1.9`, `D1.10`, `D1.11`, `D1.12`, `D1.13`, `D2.14`, `D2.15`, `D2.16`, `D2.17` or `D2.18`, each one corresponding to a row of the following table:

|  |  | Parent |  | Offspring |
--- | --- | --- | --- | --- | --- | ---
|  | Crosstype | Cross | Observed bands | Observed bands | Segregation
\(A\) |  | 1 | \(ab \times cd\) | \(ab \times cd\) | \(ac, ad, bc, bd\) | \(1:1:1:1\)
|  | 2 | \(ab \times ac\) | \(ab \times ac\) | \(a, ac, ba, bc\) | \(1:1:1:1\)
|  | 3 | \(ab \times co\) | \(ab \times c\) | \(ac, a, bc,b\) | \(1:1:1:1\)
|  | 4 | \(ao \times bo\) | \(a \times b\) | \(ab, a, b, o\) | \(1:1:1:1\)
\(B\) | \(B_1\) | 5 | \(ab \times ao\) | \(ab \times a\) | \(ab, 2a,b\) | \(1:2:1\)
| \(B_2\) | 6 | \(ao \times ab\) | \(a \times ab\) | \(ab,2a,b\) | \(1:2:1\)
| \(B_3\) | 7 | \(ab \times ab\) | \(ab \times ab\) | \(a, 2ab,b\) | \(1:2:1\)
\(C\) |  | 8 | \(ao \times ao\) | \(a \times a\) | \(3a, o\) | \(3:1\)
\(D\) | \(D_1\) | 9 | \(ab \times cc\) | \(ab \times c\) | \(ac, bc\) | \(1:1\)
|  | 10 | \(ab \times aa\) | \(ab \times a\) | \(a, ab\) | \(1:1\)
|  | 11 | \(ab \times oo\) | \(ab \times o\) | \(a, b\) | \(1:1\)
|  | 12 | \(bo \times aa\) | \(b \times a\) | \(ab, a\) | \(1:1\)
|  | 13 | \(ao \times oo\) | \(a \times o\) | \(a, o\) | \(1:1\)
| \(D_2\) | 14 | \(cc \times ab\) | \(c \times ab\) | \(ac, bc\) | \(1:1\)
|  | 15 | \(aa \times ab\) | \(a \times ab\) | \(a, ab\) | \(1:1\)
|  | 16 | \(oo \times ab\) | \(o \times ab\) | \(a, b\) | \(1:1\)
|  | 17 | \(aa \times bo\) | \(a \times b\) | \(ab, a\) | \(1:1\)
|  | 18 | \(oo \times ao\) | \(o \times a\) | \(a, o\) | \(1:1\)

Letters `A`, `B`, `C` and `D` indicate the segregation type (i.e., `1:1:1:1`, `1:2:1`, `3:1` or `1:1`, respectively), while the number after the dot (e.g., `A.1`) indicates the observed bands in the offspring. The paper cited above gives details with respect to marker types; we will not discuss them here, but it is easy to see that each marker is classified based on the band patterns of parents and progeny.

Finally, after each marker name, comes the genotype data for the segregating population. The coding for marker genotypes used by `OneMap` is also the same one proposed by Wu et al. (2002a) and the possible values vary according to the specific marker type. Missing data are indicated with the character `-` (minus sign) and an empty space separates the information for each individual. Phenotype information, if present, follows genotypic data with a similar structure. Details are found in the help of function `read_onemap`.

Here is an example of such file for 10 individuals and 5 markers (the three zeros in the second line indicate that there is no chromosome information, physical position information or phenotypic data, respectively). It is very similar to a MAPMAKER/EXP file, but has additional information about the crosstype.

    data type outcross
    10 5 0 0 0
    I1 I2 I3 I4 I5 I6 I7 I8 I9 I10
    *M1 B3.7 ab ab - ab b ab ab - ab b
    *M2 D2.18 o - a a - o a - o o
    *M3 D1.13 o a a o o - a o a o
    *M4 A.4 ab b - ab a b ab b - a
    *M5 D2.18 a a o - o o a o o o

Notice that once the marker type is identified, no variations of symbols presented on the table for the observed bands is allowed. For example, for `A.1`, only `ac`, `ad`, `bc` and `bd` genotypes are expected (plus missing values). We notice in FAQs that this is a common mistake made by users, so please be careful.

The input file must be saved in text format, with extensions like `.raw`. It is a good idea to open the text file called `example_out.raw` (available with `OneMap` and saved in the directory you installed it) to see how this file should be. You can see where `OneMap` is installed using the command

    system.file(package = "onemap")

# Create data file from VCF file

If you are working with biallelic markers, as SNPs and indels (marker types B3.7, D1.10 or D2.15), in VCF (Variant Call Format) files, you can use the function `vcf2raw` to convert the genotype information from the VCF file to `OneMap` format `.raw`. Moreover, the function keeps chromosome and position information for each marker at the end of raw file.

To see how the function works, there is a short example of VCF file called `vcf_example_out.vcf` saved in the directory you installed the `OneMap`. This file is already sorted, compressed and tabix indexed as require by the function. If you need to sort your file, we suggest the `vcf-sort` perl script from `vcftools` program. The functions `bgzip` and `indexTabix` from `Rsamtools` package can be used to compress and add tabix index.

    vcf2raw(input = system.file("extdata/vcf_example_out.vcf.gz", package = "onemap"),
            output = "vcf_example_out.raw", parent1 = "P1", parent2 = "P2", cross = "outcross")

The first argument is the path and the name of the data file. You can acess the example data using the function `system.file` as already seen above. For the second argument you can choose a name for the output `.raw` data. At the `parent1` and `parent2` arguments you should specify the parents samples IDs. They could be only one ID or, if there are replicate samples of the parents, multiple IDs for each parent. If you have replicates, you can specify a real number between 0.0 and 1.0 for the argument `min_class` to define the proportion of parents replicates that must have the same genotype for it to be assigned to the corresponding parent. At the `cross` argument you should point the cross type. You can access more information in the help page `?vcf2raw`.

After running the function, the `OneMap` imput file `vcf_example_out.raw` generated will be at your working directory.

The function will not convert non-informative markers (if both parents are homozygotes). Therefore, you can have smaller number of markers in your `.raw` file compared to `vcf` file. In our example, there is one non-informative marker, identified as `SNP15`.

# Importing data

Once the input file is created, the data can be loaded and saved into an R `onemap` object. The function used to import data is named `read_onemap`. Its usage is quite simple:

    example_out <- read_onemap(dir = "C:/workingdirectory", inputfile = "example_out.raw")

The first argument is the directory where the input file is located, so modify it accordingly. The second one is the data file name. In this example, an object named `example_out` was created. If you leave the argument `dir` blank, the file will be loaded from your `working directory`.

You can change the working directory in R using function `setwd()` or in the toolbar clicking `File -> Change dir`. If you set your working directory to the one containing the input file, you can just type:

    example_out <- read_onemap(inputfile = "example_out.raw")

If no error has occurred, a message will display some basic information about the data, such as number of individuals and number of markers:

    #>  Working...
    #>
    #>  --Read the following data:
    #>  Type of cross:           outcross
    #>  Number of individuals:   100
    #>  Number of markers:       30
    #>  Chromosome information:  no
    #>  Position information:    no
    #>  Number of traits:        3
    #>  Missing trait values:
    #>   Pheno1: 0
    #>   Pheno2: 3
    #>   Pheno3: 0

Because this particular data set is distributed along with the package, as an alternative you can load it typing

    data("example_out")

Loading the data creates an object of class `onemap`, which will further be used in the analysis. R command `print` recognizes objects of this class. Thus, if you type:

    example_out

you will see some information about the object:

    #>   This is an object of class 'onemap'
    #>     Type of cross:      outcross
    #>     No. individuals:    100
    #>     No. markers:        30
    #>     CHROM information:  no
    #>     POS information:    no
    #>     Percent genotyped:  100
    #>
    #>     Segregation types:
    #>                 A.1 -->  3
    #>                 A.2 -->  1
    #>                 A.4 -->  4
    #>                B1.5 -->  1
    #>                B2.6 -->  2
    #>                B3.7 -->  5
    #>                 C.8 -->  2
    #>               D1.10 -->  2
    #>               D1.12 -->  1
    #>               D1.13 -->  2
    #>               D2.15 -->  1
    #>               D2.16 -->  2
    #>               D2.17 -->  2
    #>               D2.18 -->  2
    #>
    #>     No. traits:         3
    #>     Missing trait values:
    #>   Pheno1: 0
    #>   Pheno2: 3
    #>   Pheno3: 0

Also, you can use the `plot.onemap` function to see graphically markers genotypes:

    plot(example_out)

Changing the argument `all` to `FALSE`, the markers will be separed by their type. In this case, you can note that the graphic cells size will adapt to the number of markers of the same type. In other words, the greater is the number of markers with the same type, smaller are the cells for this type.

    plot(example_out, all = FALSE)

This function can take quite some time, depending on the number of markers involved. More informations about this plot function can be found using `?plot.onemap`.

Also, you can see graphically the number of markers by segregattion pattern with the `plot_by_segreg_type` function:

    plot_by_segreg_type(example_out)

In the next analysis, we will also use the data from `vcf` file. You can load it in the same way as shown above:

    vcf_example_out <- read_onemap("C:/workingdirectory", "vcf_example_out.raw")

Or, because it is also a data set from the package:

    data("vcf_example_out")

    #>  Working...
    #>
    #>  --Read the following data:
    #>  Type of cross:           outcross
    #>  Number of individuals:   92
    #>  Number of markers:       24
    #>  Chromosome information:  yes
    #>  Position information:    yes
    #>  Number of traits:        0

And you can see the informations about this new object with:

    vcf_example_out
    #>   This is an object of class 'onemap'
    #>     Type of cross:      outcross
    #>     No. individuals:    92
    #>     No. markers:        24
    #>     CHROM information:  yes
    #>     POS information:    yes
    #>     Percent genotyped:  100
    #>
    #>     Segregation types:
    #>                B3.7 -->  18
    #>               D1.10 -->  6
    #>
    #>     No. traits:         0

and with:

    plot(vcf_example_out, all = FALSE)

The black cells here are indicating missing genotypes for those markers and individuals.

# Combining `OneMap` datasets

If you have more than one dataset of markers, all from the same cross type, you can use the function `combine_onemap` to merge them into only one `onemap` object.

In our example, we have two datasets:

- first: `example_out` with 29 markers and 100 individuals
- second: `vcf_example_out` with 24 biallelic markers and 92 individuals.

The `combine_function` recognizes the correspondent individuals by the ID, thus, it is important define exactly same IDs to respective individuals in both `raw` files. Compared with the first file, the second file do not have markers informations for 8 individuals. The `combine_onemap` will complete those informations with NA.

In our examples, we have only genotypic information, but the function can also merge the phenotipic information if it exists.

    comb_example <- combine_onemap(example_out, vcf_example_out)
    comb_example
    #>   This is an object of class 'onemap'
    #>     Type of cross:      outcross
    #>     No. individuals:    100
    #>     No. markers:        54
    #>     CHROM information:  yes
    #>     POS information:    yes
    #>     Percent genotyped:  96
    #>
    #>     Segregation types:
    #>                 A.1 -->  3
    #>                 A.2 -->  1
    #>                 A.4 -->  4
    #>                B1.5 -->  1
    #>                B2.6 -->  2
    #>                B3.7 -->  23
    #>                 C.8 -->  2
    #>               D1.10 -->  8
    #>               D1.12 -->  1
    #>               D1.13 -->  2
    #>               D2.15 -->  1
    #>               D2.16 -->  2
    #>               D2.17 -->  2
    #>               D2.18 -->  2
    #>
    #>     No. traits:         3
    #>     Missing trait values:
    #>   Pheno1: 0
    #>   Pheno2: 3
    #>   Pheno3: 0

The function arguments are the names of the `onemap` objects you want to combine.

Plotting markers genotypes from the outputted `onemap` object, we can see that there are more missing data `-` (black vertical lines) for some individuals, because they were missing in the second file.

    plot(comb_example)

# Find redundant markers

It is possible that there are redundant markers in your dataset, specially when dealing with too many markers. Redundant markers have the same genotypic informations that others markers, usually because didn’t happen recombination events between each other. They will not increase informations to the map, but will increase computational effort during the map building. Therefore, it is a good pratice to remove them to build the map and, once the map is already builded, they can be added again.

First, we use the function `find_bins` to group the markers into bins according with their genotypic informations. In other words, markers with the same genotypic informations will be at the same bin.

    bins <- find_bins(comb_example, exact = FALSE)
    bins
    #> This is an object of class 'onemap_bin'
    #>     No. individuals:                         100
    #>     No. markers in original dataset:         54
    #>     No. of bins found:                       52
    #>     Average of markers per bin:              1.038462
    #>     Type of search performed:                non exact

The first argument is the `onemap` object and the `exact` argument specify if only markers with exact same informations will be at the same bin. Using `FALSE` at this second argument, missing data will not be considered and the marker with the lowest amount of missing data will be the representative marker on the bin.

Our example dataset have only two redundant marker. We can create a new `onemap` object without them, using the `create_data_bins` function. This function keeps only the most representative marker of each bin from `bins` object.

    bins_example <- create_data_bins(comb_example, bins)
    bins_example
    #>   This is an object of class 'onemap'
    #>     Type of cross:      outcross
    #>     No. individuals:    100
    #>     No. markers:        52
    #>     CHROM information:  yes
    #>     POS information:    yes
    #>     Percent genotyped:  97
    #>
    #>     Segregation types:
    #>                 A.1 -->  3
    #>                 A.2 -->  1
    #>                 A.4 -->  4
    #>                B1.5 -->  1
    #>                B2.6 -->  2
    #>                B3.7 -->  22
    #>                 C.8 -->  2
    #>               D1.10 -->  7
    #>               D1.12 -->  1
    #>               D1.13 -->  2
    #>               D2.15 -->  1
    #>               D2.16 -->  2
    #>               D2.17 -->  2
    #>               D2.18 -->  2
    #>
    #>     No. traits:         3
    #>     Missing trait values:
    #>   Pheno1: 0
    #>   Pheno2: 3
    #>   Pheno3: 0

The arguments for `create_data_bins` function are the `onemap` object and the object created by `find_bins` function.

# Testing segregation pattern

For the map building process it is also important to know which markers have deviations in the expecteded segregation pattern. It can be a good pratice to remove them from the map building process, because they can adversely affect the map building, and, once the map is builded, they can be inserted.

The function `test_segregation_of_a_marker` performs chi-square test according with mendelian segregation to check if a specific marker is following the expected segregation pattern.

    test_segregation_of_a_marker(bins_example, 4)
    #> $Hypothesis
    #> [1] "1:1:1:1"
    #>
    #> $qui.quad
    #> X-squared
    #>      2.64
    #>
    #> $p.val
    #> [1] 0.4505201
    #>
    #> $perc.genot
    #> [1] 100

The arguments are the `onemap` object and the number of the marker you want to test.

You can also test all the markers in your `onemap` object using the `test_segregation` function. The results can be viewed printing the output object of class `onemap_segreg_test`.

    segreg_test <- test_segregation(bins_example)
    print(segreg_test)
    #>    Marker      H0  Chi-square      p-value % genot.
    #> 1      M1   1:2:1  1.76000000 4.147829e-01      100
    #> 2      M2     1:1  0.04000000 8.414806e-01      100
    #> 3      M3     1:1  0.36000000 5.485062e-01      100
    #> 4      M4 1:1:1:1  2.64000000 4.505201e-01      100
    #> 5      M5     1:1  1.96000000 1.615133e-01      100
    #> 6      M6   1:2:1  1.52000000 4.676664e-01      100
    #> 7      M7     1:1  0.16000000 6.891565e-01      100
    #> 8      M8   1:2:1  0.86000000 6.505091e-01      100
    #> 9      M9     1:1  0.04000000 8.414806e-01      100
    #> 10    M10     1:1  0.36000000 5.485062e-01      100
    #> 11    M11     1:1  0.16000000 6.891565e-01      100
    #> 12    M12 1:1:1:1  6.48000000 9.045460e-02      100
    #> 13    M13     3:1  0.00000000 1.000000e+00      100
    #> 14    M14 1:1:1:1  0.40000000 9.402425e-01      100
    #> 15    M15 1:1:1:1  2.24000000 5.241127e-01      100
    #> 16    M16     1:1  1.44000000 2.301393e-01      100
    #> 17    M17   1:2:1 35.58000000 1.878889e-08      100
    #> 18    M18 1:1:1:1  1.44000000 6.961859e-01      100
    #> 19    M19   1:2:1 37.98000000 5.659105e-09      100
    #> 20    M20 1:1:1:1  4.88000000 1.807980e-01      100
    #> 21    M21     1:1  1.44000000 2.301393e-01      100
    #> 22    M22     1:1  1.00000000 3.173105e-01      100
    #> 23    M23     3:1  0.48000000 4.884223e-01      100
    #> 24    M24   1:2:1  1.50000000 4.723666e-01      100
    #> 25    M25   1:2:1 35.04000000 2.461278e-08      100
    #> 26    M26 1:1:1:1  1.52000000 6.776621e-01      100
    #> 27    M27     1:1  1.00000000 3.173105e-01      100
    #> 28    M28 1:1:1:1  1.20000000 7.530043e-01      100
    #> 29    M29     1:1  0.00000000 1.000000e+00      100
    #> 30    M30   1:2:1  3.42000000 1.808658e-01      100
    #> 31   SNP1   1:2:1  3.73913043 1.541907e-01       92
    #> 32   SNP2   1:2:1  4.76086957 9.251035e-02       92
    #> 33   SNP3   1:2:1  4.76086957 9.251035e-02       92
    #> 34   SNP5   1:2:1  4.95652174 8.388899e-02       92
    #> 35   SNP6   1:2:1  1.80434783 4.056868e-01       92
    #> 36   SNP7   1:2:1  1.45652174 4.827478e-01       92
    #> 37   SNP8   1:2:1  0.26086957 8.777137e-01       92
    #> 38   SNP9   1:2:1  1.39130435 4.987491e-01       92
    #> 39  SNP10   1:2:1  0.06521739 9.679172e-01       92
    #> 40  SNP11   1:2:1  0.52173913 7.703814e-01       92
    #> 41  SNP12   1:2:1  0.17391304 9.167170e-01       92
    #> 42  SNP13   1:2:1  0.08695652 9.574534e-01       92
    #> 43  SNP14     1:1  0.69565217 4.042485e-01       92
    #> 44  SNP16   1:2:1  0.00000000 1.000000e+00       92
    #> 45  SNP17     1:1  0.00000000 1.000000e+00       92
    #> 46  SNP18     1:1  0.17391304 6.766573e-01       92
    #> 47  SNP20     1:1  0.04347826 8.348273e-01       92
    #> 48  SNP21     1:1  0.00000000 1.000000e+00       92
    #> 49  SNP22   1:2:1  1.10869565 5.744468e-01       92
    #> 50  SNP23   1:2:1  2.15217391 3.409270e-01       92
    #> 51  SNP24   1:2:1  2.86956522 2.381671e-01       92
    #> 52  SNP25   1:2:1  2.15217391 3.409270e-01       92

The only argument of the function is a `onemap` object.

Once we have the `onemap_segreg_test`object, the function `select_segreg` can be used to show only the markers considered with/without segregation distortion if Bonferroni’s correction is applied with global \(\alpha=0.5\).

    select_segreg(segreg_test, distorted = TRUE) #to show the markers names with segregation distortion
    #> [1] "M17" "M19" "M25"

    select_segreg(segreg_test, distorted = FALSE) #to show the markers names without segregation distortion
    #>  [1] "M1"    "M2"    "M3"    "M4"    "M5"    "M6"    "M7"    "M8"
    #>  [9] "M9"    "M10"   "M11"   "M12"   "M13"   "M14"   "M15"   "M16"
    #> [17] "M18"   "M20"   "M21"   "M22"   "M23"   "M24"   "M26"   "M27"
    #> [25] "M28"   "M29"   "M30"   "SNP1"  "SNP2"  "SNP3"  "SNP5"  "SNP6"
    #> [33] "SNP7"  "SNP8"  "SNP9"  "SNP10" "SNP11" "SNP12" "SNP13" "SNP14"
    #> [41] "SNP16" "SNP17" "SNP18" "SNP20" "SNP21" "SNP22" "SNP23" "SNP24"
    #> [49] "SNP25"

For the next steps will be useful to know the numbers of each markers with segregation distortion, so then you can keep those out of your map building analysis. These numbers refer to the lines where markers are located on the data file.

To access the corresponding number for of this markers you can change the `numbers` argument:

    dist <- select_segreg(segreg_test, distorted = TRUE, numbers = TRUE) #to show the markers numbers with segregation distortion
    dist
    #> [1] 17 19 25

    no_dist <- select_segreg(segreg_test, distorted = FALSE, numbers = TRUE) #to show the markers numbers without segregation distortion
    no_dist
    #>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 18 20 21 22 23 24 26
    #> [24] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    #> [47] 50 51 52

You can also see the results graphically by:

    plot(segreg_test)

# Strategies for this tutorial example

Now, we start the map building analysis. In this example we follow two different strategies:

- Using only recombinations informations.

- Using the recombinations and also the reference genome informations, once our example have `CHROM` and `POS` informations for some of the markers.

First, we will apply the strategy using only recombinations informations. In a second part of this tutorial we show a way to use also reference genome informations. At the and of our analysis we will be able to compare this two strategies drawing the resulted genetic maps.

# Using only recombinations informations

## Estimating two-point recombination fractions

To start the map building analysis, the first step is estimating the recombination fraction between all pairs of markers, using two-point tests.

The function `rf_2pts` uses as default values of LOD Score `3` and maximum recombination fraction `0.50`. You can change this values according with your dataset. Also, you can use the function `suggest_lod` to calculate a suggested LOD score considering that multiple tests are being performed.

    LOD_sug <- suggest_lod(bins_example)
    LOD_sug
    #> [1] 3.688802

And apply this suggested value to the two-point tests:

    twopts <- rf_2pts(bins_example, LOD = LOD_sug, max.rf = 0.5)

Although two-point tests were implemented in C language, which is usually much faster than R, this step can take quite some time, depending on the number of markers involved and their segregation type, because all combinations will be estimated and tested. Besides, the results use a lot of memory and a rather powerful computer is needed.

When the two-point analysis is finished, an object of class `rf_2pts` is created. Typing

    twopts

will show a message with the criteria used in the analysis and some other information:

    #>   This is an object of class 'rf_2pts'
    #>
    #>   Criteria: LOD = 3.688802 , Maximum recombination fraction = 0.5
    #>
    #>   This object is too complex to print
    #>   Type 'print(object, c(mrk1=marker, mrk2=marker))' to see
    #>     the analysis for two markers
    #>     mrk1 and mrk2 can be the names or numbers of both markers

If you want to see the results for given markers, say `M1` and `M3`, the command is:

    print(twopts, c("M1", "M3"))
    #>   Results of the 2-point analysis for markers: M1 and M3
    #>   Criteria: LOD =  3.688802 , Maximum recombination fraction =  0.5
    #>
    #>           rf      LOD
    #> CC 0.2954514 1.646878
    #> CR 0.2954514 1.646878
    #> RC 0.7045486 1.646878
    #> RR 0.7045486 1.646878

Each line corresponds to a possible linkage phase. `CC` denotes coupling phase in both parents, `CR` and `RC` denote coupling phase in parent 1 and 2, respectively, and repulsion in the other, and `RR` denotes repulsion phase in both parents. Value `rf` is the maximum likelihood estimate of the recombination fraction, with its corresponding LOD Score.

## Assigning markers to linkage groups

Once the recombination fractions and linkage phases for all pairs of markers have been estimated and tested, markers can be assigned to linkage groups. To do this, first use the function `make_seq` to create a sequence with the markers you want to assign.

The function `make_seq` is used to create sequences from objects of several kinds, as will be seen along this tutorial.

Here, the object is of class `rf_2pts` and the second argument specifies which markers one wants to use. If one wants to use only a subset of markers, say `M1` and `M2`, the option will be a vector with the corresponding numbers of the markers, as `c(1,2)`, you can also use a string `"all"` to specify that you want to analyze all markers. In our example, we will use the vector with the numbers of the markers with no segregation distortion.

    mark_no_dist <- make_seq(twopts, c(no_dist))

Because the identification of the markers can be cumbersome, one should use the function `marker type` to see their numbers, names and types:

    marker_type(mark_no_dist)
    #>   Marker 1 ( M1 ) is of type B3.7
    #>   Marker 2 ( M2 ) is of type D2.18
    #>   Marker 3 ( M3 ) is of type D1.13
    #>   Marker 4 ( M4 ) is of type A.4
    #>   Marker 5 ( M5 ) is of type D2.18
    #>   Marker 6 ( M6 ) is of type B3.7
    #>   Marker 7 ( M7 ) is of type D2.15
    #>   Marker 8 ( M8 ) is of type B3.7
    #>   Marker 9 ( M9 ) is of type D1.10
    #>   Marker 10 ( M10 ) is of type D2.17
    #>   Marker 11 ( M11 ) is of type D2.16
    #>   Marker 12 ( M12 ) is of type A.2
    #>   Marker 13 ( M13 ) is of type C.8
    #>   Marker 14 ( M14 ) is of type A.4
    #>   Marker 15 ( M15 ) is of type A.4
    #>   Marker 16 ( M16 ) is of type D2.17
    #>   Marker 18 ( M18 ) is of type A.1
    #>   Marker 20 ( M20 ) is of type A.1
    #>   Marker 21 ( M21 ) is of type D2.16
    #>   Marker 22 ( M22 ) is of type D1.10
    #>   Marker 23 ( M23 ) is of type C.8
    #>   Marker 24 ( M24 ) is of type B3.7
    #>   Marker 26 ( M26 ) is of type A.1
    #>   Marker 27 ( M27 ) is of type D1.12
    #>   Marker 28 ( M28 ) is of type A.4
    #>   Marker 29 ( M29 ) is of type D1.13
    #>   Marker 30 ( M30 ) is of type B3.7
    #>   Marker 31 ( SNP1 ) is of type B3.7
    #>   Marker 32 ( SNP2 ) is of type B3.7
    #>   Marker 33 ( SNP3 ) is of type B3.7
    #>   Marker 34 ( SNP5 ) is of type B3.7
    #>   Marker 35 ( SNP6 ) is of type B3.7
    #>   Marker 36 ( SNP7 ) is of type B3.7
    #>   Marker 37 ( SNP8 ) is of type B3.7
    #>   Marker 38 ( SNP9 ) is of type B3.7
    #>   Marker 39 ( SNP10 ) is of type B3.7
    #>   Marker 40 ( SNP11 ) is of type B3.7
    #>   Marker 41 ( SNP12 ) is of type B3.7
    #>   Marker 42 ( SNP13 ) is of type B3.7
    #>   Marker 43 ( SNP14 ) is of type D1.10
    #>   Marker 44 ( SNP16 ) is of type B3.7
    #>   Marker 45 ( SNP17 ) is of type D1.10
    #>   Marker 46 ( SNP18 ) is of type D1.10
    #>   Marker 47 ( SNP20 ) is of type D1.10
    #>   Marker 48 ( SNP21 ) is of type D1.10
    #>   Marker 49 ( SNP22 ) is of type B3.7
    #>   Marker 50 ( SNP23 ) is of type B3.7
    #>   Marker 51 ( SNP24 ) is of type B3.7
    #>   Marker 52 ( SNP25 ) is of type B3.7

The grouping step is very simple and can be done by using the function `group`:

    LGs <- group(mark_no_dist)
    #>    Selecting markers:
    #>    group    1
    #>     .........................
    #>    group    2
    #>     .................
    #>    group    3
    #>     .......

For this function, optional arguments are `LOD` and `max.rf`, which define thresholds to be used when assigning markers to linkage groups. If none provided (default), criteria previously defined for the object `twopts` are used.

The previous command generates an object of class `group` and the command `print` for such object has two options. If you type:

    LGs

you will get detailed information about the groups, that is, all linkage groups will be printed, displaying the names of markers in each one of them.

    #>   This is an object of class 'group'
    #>   It was generated from the object "mark_no_dist"
    #>
    #>   Criteria used to assign markers to groups:
    #>     LOD = 3.688802 , Maximum recombination fraction = 0.5
    #>
    #>   No. markers:            49
    #>   No. groups:             3
    #>   No. linked markers:     49
    #>   No. unlinked markers:   0
    #>
    #>   Printing groups:
    #>   Group 1 : 25 markers
    #>     M1 M2 M3 M5 M6 M10 M11 M12 M14 M15 M26 M28 M30 SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13
    #>
    #>   Group 2 : 17 markers
    #>     M4 M9 M16 M20 M21 M23 M24 M27 M29 SNP17 SNP18 SNP20 SNP21 SNP22 SNP23 SNP24 SNP25
    #>
    #>   Group 3 : 7 markers
    #>     M7 M8 M13 M18 M22 SNP14 SNP16

However, in case you just want to see some basic information (such as the number of groups, number of linked markers, etc), use

    print(LGs, detailed = FALSE)
    #>   This is an object of class 'group'
    #>   It was generated from the object "mark_no_dist"
    #>
    #>   Criteria used to assign markers to groups:
    #>     LOD = 3.688802 , Maximum recombination fraction = 0.5
    #>
    #>   No. markers:            49
    #>   No. groups:             3
    #>   No. linked markers:     49
    #>   No. unlinked markers:   0

You can notice that all markers are linked to some linkage group. If the LOD Score threshold is changed to a higher value, some markers are kept unassigned:

    LGs <- group(mark_no_dist, LOD = 6)
    #>    Selecting markers:
    #>    group    1
    #>     .........................
    #>    group    2
    #>     ...........
    #>    group    3
    #>     ......
    #>    group    4
    #>     .....
    LGs
    #>   This is an object of class 'group'
    #>   It was generated from the object "mark_no_dist"
    #>
    #>   Criteria used to assign markers to groups:
    #>     LOD = 6 , Maximum recombination fraction = 0.5
    #>
    #>   No. markers:            49
    #>   No. groups:             4
    #>   No. linked markers:     47
    #>   No. unlinked markers:   2
    #>
    #>   Printing groups:
    #>   Group 1 : 25 markers
    #>     M1 M2 M3 M5 M6 M10 M11 M12 M14 M15 M26 M28 M30 SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13
    #>
    #>   Group 2 : 11 markers
    #>     M4 M9 M16 M20 M21 M23 M27 SNP17 SNP18 SNP20 SNP21
    #>
    #>   Group 3 : 6 markers
    #>     M8 M13 M18 M22 SNP14 SNP16
    #>
    #>   Group 4 : 5 markers
    #>     M24 SNP22 SNP23 SNP24 SNP25
    #>
    #>   Unlinked markers: 2  markers
    #>     M7 M29

Changing back to the previous criteria, now setting the maximum recombination fraction to 0.40:

    LGs <- group(mark_no_dist, LOD = LOD_sug, max.rf = 0.4)
    #>    Selecting markers:
    #>    group    1
    #>     .........................
    #>    group    2
    #>     .................
    #>    group    3
    #>     .......
    LGs
    #>   This is an object of class 'group'
    #>   It was generated from the object "mark_no_dist"
    #>
    #>   Criteria used to assign markers to groups:
    #>     LOD = 3.688802 , Maximum recombination fraction = 0.4
    #>
    #>   No. markers:            49
    #>   No. groups:             3
    #>   No. linked markers:     49
    #>   No. unlinked markers:   0
    #>
    #>   Printing groups:
    #>   Group 1 : 25 markers
    #>     M1 M2 M3 M5 M6 M10 M11 M12 M14 M15 M26 M28 M30 SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13
    #>
    #>   Group 2 : 17 markers
    #>     M4 M9 M16 M20 M21 M23 M24 M27 M29 SNP17 SNP18 SNP20 SNP21 SNP22 SNP23 SNP24 SNP25
    #>
    #>   Group 3 : 7 markers
    #>     M7 M8 M13 M18 M22 SNP14 SNP16

## Genetic mapping of linkage group 3

Once marker assignment to linkage groups is finished, the mapping step can take place. First of all, you must set the mapping function that should be used to display the genetic map throughout the analysis. You can choose between `Kosambi` or `Haldane` mapping functions. To use Haldane, type

    set_map_fun(type = "haldane")

To use Kosambi

    set_map_fun(type = "kosambi")

Now, you must define which linkage group will be mapped. In another words, a linkage group must be `extracted` from the object of class `group`, in order to be mapped. For simplicity, we will start here with the smallest one, which is linkage group 3. This can be easily done using the following code:

    LG3 <- make_seq(LGs, 3)

The first argument (`LGs`) is an object of class `group` and the second is a number indicating which linkage group will be extracted, according to the results stored in object `LGs`. The object `LG3`, generated by function `make_seq`, is of class `sequence`, showing that this function can be used with several types of objects.

If you type

    LG3

you will see which markers are comprised in the sequence, and also that no parameters have been estimated so far.

    #>
    #> Number of markers: 7
    #> Markers in the sequence:
    #> M7 M8 M13 M18 M22 SNP14 SNP16
    #>
    #> Parameters not estimated.

To order these markers, one can use a two-point based algorithm such as Seriation (Buetow and Chakravarti, 1987), Rapid Chain Delineation (Doerge, 1996), Recombination Counting and Ordering (Van Os et al., 2005) and Unidirectional Growth (Tan and Fu, 2006):

    LG3_ser <- seriation(LG3)
    LG3_rcd <- rcd(LG3)
    LG3_rec <- record(LG3)
    LG3_ug <- ug(LG3)

In this case, there are some differeces between algorithms results (results not shown).

To order by comparing all possible orders (exhaustive search), the function `compare` can be used:

    LG3_comp <- compare(LG3)

This algorithm can take some time to run, depending on marker types in the linkage group. If you are working in a personal computer, without high capacity, we recommend using maximum of ten markers.

In the example, `LG3` contains six markers. Two of them are of type D1 and one are segregating in 3:1 fashion (type C). Thus, although the number of possible orders is relatively small (360), for each order there are various possible combinations of linkage phases. Also, the convergence of the EM algorithm takes considerably more time, because markers of type C and D are not very informative.

The first argument to the `compare` function is an object of class `sequence` (the extracted group `LG3`), and the object generated by this function is of class `compare`.

To see the results of the previous step, type

    LG3_comp
    #>
    #> Number of orders: 50
    #> Best 50 unique orders                         LOD    Nested LOD
    #> --------------------------------------------------------------
    #> order  1:    43  22   7  18   8  13  44
    #>         CC  CC  CC  RR  RR  RR         0.00       0.00
    #> --------------------------------------------------------------
    #> order  2:    43   7  22  18   8  13  44
    #>         CC  CC  CC  RR  RR  RR        -0.01       0.00
    #> --------------------------------------------------------------
    #> order  3:     7  43  22  18   8  13  44
    #>         CC  CC  CC  RR  RR  RR        -0.20       0.00
    #> --------------------------------------------------------------
    #> order  4:    22  43   7  18   8  13  44
    #>         CC  CC  CC  RR  RR  RR        -0.20       0.00
    #> --------------------------------------------------------------
    #> order  5:    22   7  43  18   8  13  44
    #>         CC  CC  CC  RR  RR  RR        -0.21       0.00
    #> --------------------------------------------------------------
    #> order  6:     7  22  43  18   8  13  44
    #>         CC  CC  CC  RR  RR  RR        -0.41       0.00
    #> --------------------------------------------------------------
    #> order  7:     7  18   8  13  44  22  43
    #>         CC  RR  RR  RR  RC  CC        -0.49       0.00
    #> --------------------------------------------------------------
    #> order  8:     7  44  13   8  18  22  43
    #>         CR  RR  RR  RR  CC  CC        -0.61       0.00
    #> --------------------------------------------------------------
    #> order  9:     7  44  13   8  18  43  22
    #>         CR  RR  RR  RR  CC  CC        -0.79       0.00
    #> --------------------------------------------------------------
    #> order 10:     7  18   8  13  44  43  22
    #>         CC  RR  RR  RR  RC  CC        -0.81       0.00
    #> --------------------------------------------------------------
    #> order 11:    43  22   7  13  18   8  44
    #>         CC  CC  CC  CC  RR  CC        -0.98       0.00
    #> --------------------------------------------------------------
    #> order 12:    43   7  22  13  18   8  44
    #>         CC  CC  CC  CC  RR  CC        -0.98       0.00
    #> --------------------------------------------------------------
    #> order 13:    43  22   7  13  44   8  18
    #>         CC  CC  CC  RR  CC  RR        -1.07       0.00
    #> --------------------------------------------------------------
    #> order 14:    43   7  22  13  44   8  18
    #>         CC  CC  CC  RR  CC  RR        -1.08       0.00
    #> --------------------------------------------------------------
    #> order 15:    43  22   7  44  13   8  18
    #>         CC  CC  RR  RR  RR  RR        -1.14       0.00
    #> --------------------------------------------------------------
    #> order 16:    43   7  22  44  13   8  18
    #>         CC  CC  RR  RR  RR  RR        -1.15       0.00
    #> --------------------------------------------------------------
    #> order 17:     7  43  22  13  18   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.21       0.00
    #> --------------------------------------------------------------
    #> order 18:    43  22   7  18  13   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.25       0.00
    #> --------------------------------------------------------------
    #> order 19:    43   7  22  18  13   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.26       0.00
    #> --------------------------------------------------------------
    #> order 20:     7  43  22  44  13   8  18
    #>         CC  CC  RR  RR  RR  RR        -1.30       0.00
    #> --------------------------------------------------------------
    #> order 21:     7  43  22  13  44   8  18
    #>         CC  CC  CC  RR  CC  RR        -1.36       0.00
    #> --------------------------------------------------------------
    #> order 22:     7  43  22  18  13   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.45       0.00
    #> --------------------------------------------------------------
    #> order 23:    22  43   7  18  13   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.45       0.00
    #> --------------------------------------------------------------
    #> order 24:    22   7  43  18  13   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.46       0.00
    #> --------------------------------------------------------------
    #> order 25:    22  43   7  44  13   8  18
    #>         CC  CC  RR  RR  RR  RR        -1.59       0.00
    #> --------------------------------------------------------------
    #> order 26:    22   7  43  44  13   8  18
    #>         CC  CC  RR  RR  RR  RR        -1.60       0.00
    #> --------------------------------------------------------------
    #> order 27:     7  22  43  18  13   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.66       0.00
    #> --------------------------------------------------------------
    #> order 28:     7  13  44   8  18  22  43
    #>         CC  RR  CC  RR  CC  CC        -1.69       0.00
    #> --------------------------------------------------------------
    #> order 29:     7  18  13   8  44  22  43
    #>         CC  CC  RR  CC  RC  CC        -1.72       0.00
    #> --------------------------------------------------------------
    #> order 30:     7  22  43  44  13   8  18
    #>         CC  CC  RR  RR  RR  RR        -1.77       0.00
    #> --------------------------------------------------------------
    #> order 31:     7  44   8  13  18  22  43
    #>         CR  CC  RR  CC  CC  CC        -1.83       0.00
    #> --------------------------------------------------------------
    #> order 32:     7  13  44   8  18  43  22
    #>         CC  RR  CC  RR  CC  CC        -1.88       0.00
    #> --------------------------------------------------------------
    #> order 33:    22  43   7  13  18   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.89       0.00
    #> --------------------------------------------------------------
    #> order 34:    22   7  43  13  18   8  44
    #>         CC  CC  CC  CC  RR  CC        -1.90       0.00
    #> --------------------------------------------------------------
    #> order 35:    22  43   7  13  44   8  18
    #>         CC  CC  CC  RR  CC  RR        -1.90       0.00
    #> --------------------------------------------------------------
    #> order 36:    22   7  43  13  44   8  18
    #>         CC  CC  CC  RR  CC  RR        -1.91       0.00
    #> --------------------------------------------------------------
    #> order 37:     7  18   8  44  13  22  43
    #>         CC  RR  CC  RR  CC  CC        -1.96       0.00
    #> --------------------------------------------------------------
    #> order 38:     7  44   8  13  18  43  22
    #>         CR  CC  RR  CC  CC  CC        -2.01       0.00
    #> --------------------------------------------------------------
    #> order 39:     7  18  13   8  44  43  22
    #>         CC  CC  RR  CC  RC  CC        -2.05       0.00
    #> --------------------------------------------------------------
    #> order 40:     7  13  18   8  44  22  43
    #>         CC  CC  RR  CC  RC  CC        -2.16       0.00
    #> --------------------------------------------------------------
    #> order 41:     7  22  43  13  18   8  44
    #>         CC  CC  CC  CC  RR  CC        -2.18       0.00
    #> --------------------------------------------------------------
    #> order 42:     7  22  43  13  44   8  18
    #>         CC  CC  CC  RR  CC  RR        -2.21       0.00
    #> --------------------------------------------------------------
    #> order 43:     7  44   8  18  13  22  43
    #>         CR  CC  RR  CC  CC  CC        -2.28       0.00
    #> --------------------------------------------------------------
    #> order 44:    43  22   7  44   8  13  18
    #>         CC  CC  RR  CC  RR  CC        -2.32       0.00
    #> --------------------------------------------------------------
    #> order 45:    43   7  22  44   8  13  18
    #>         CC  CC  RR  CC  RR  CC        -2.33       0.00
    #> --------------------------------------------------------------
    #> order 46:     7  13  18   8  44  43  22
    #>         CC  CC  RR  CC  RC  CC        -2.47       0.00
    #> --------------------------------------------------------------
    #> order 47:     7  43  22  44   8  13  18
    #>         CC  CC  RR  CC  RR  CC        -2.48       0.00
    #> --------------------------------------------------------------
    #> order 48:    43  22   7  18   8  44  13
    #>         CC  CC  CC  RR  CC  RR        -2.49       0.00
    #> --------------------------------------------------------------
    #> order 49:    43   7  22  18   8  44  13
    #>         CC  CC  CC  RR  CC  RR        -2.50       0.00
    #> --------------------------------------------------------------
    #> order 50:     7  18   8  44  13  43  22
    #>         CC  RR  CC  RR  CC  CC        -2.52       0.00
    #> --------------------------------------------------------------

Remember that for outcrossing populations, one needs to estimate marker order and also linkage phases between markers for a given order. However, because two point analysis provides information about linkage phases, this information is taken into consideration in the `compare` function, reducing the number of combinations to be evaluated. If a given linkage phase has LOD greater than 0.005 in the two point analysis, we assume that this phase is very unlikely and so does not need to be evaluated in the multipoint procedure used by `compare`. We did extensive simulations which showed that this is a good procedure.

By default, `OneMap` stores 50 orders, which may or may not be unique. The value of `LOD` refers to the overall LOD Score, considering all orders tested. `Nested LOD` refers to LOD Scores within a given order, that is, scores for different combinations of linkage phases for the same marker order.

For example, order 1 has the largest value of log-likelihood and, therefore, its LOD Score is zero for a given combination of linkage phases (CC, CC, RR, RR). For this same order and other linkage phases, LOD Score is -5.20. Analyzing the results for order 2, notice that its highest LOD Score is very close to zero, indicating that this order is also quite plausible. Notice also that `Nested LOD` will always contain at least one zero value, corresponding to the best combination of phases for markers in a given order. Due to the information provided by two-point analysis, not all combinations are tested and that is the reason why the number of Nested LOD values is different for each order.

Unless one has some biological information, it is a good idea to choose the order with the highest likelihood. The final map can then be obtained with the command

    LG3_final <- make_seq(LG3_comp, 1, 1)

The first argument is the object of class `compare`. The second argument indicates which order is chosen: 1 is for the order with highest likelihood, 2 is for the second best, and so on. The third argument indicates which combination of phases is chosen for a given order: 1 also means the combination with highest likelihood among all combinations of phases (based on Nested LOD).

For simplicity, these values are defaults, so typing

    LG3_final <- make_seq(LG3_comp)

have the same effect.

To see the final map, type

    LG3_final
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 43 SNP14              0.00           a |  | b       a |  | a
    #> 22 M22               13.35           a |  | b       a |  | a
    #>  7 M7                13.35           a |  | a       a |  | b
    #> 18 M18               57.71           a |  | b       c |  | d
    #>  8 M8                63.40           b |  | a       b |  | a
    #> 13 M13               66.06           a |  | o       a |  | o
    #> 44 SNP16             71.94           b |  | a       b |  | a
    #>
    #> 7 markers            log-likelihood: -398.922

At the leftmost position, marker names are displayed. `Position` shows the cumulative distance using the Kosambi mapping function. Finally, `Parent 1` and `Parent 2` show the diplotypes of both parents, that is, the combination in which alleles are arranged in the chromosomes, given the estimated linkage phase. Notation is the same as that used by Wu et al. (2002a). Details about how ordering algorithms can be chosen and used are presented by Mollinari et al. (2009).

A careful examination of the results can be done using the function `rf_graph_table` to provide graphical view:

    rf_graph_table(LG3_final, inter = FALSE)

The recombination fractions are plotted below the diagonal and the LOD Scores are plotted above the diagonal. The color scale varies from red (small distances or big LODs) to dark blue. This color scale follows the `rainbow` color palette with `start` argument equal to 0 and `end` argument equal to 0.65. White cells indicate combinations of markers for which the recombination fractions cannot be estimated (D1 and D2).

If you change the `inter` argument to `TRUE`, you can see some information about cells corresponding to two markers (off the secondary diagonal) just clicking on them. For example, clicking on the cell corresponding to markers numbers 7 and 12, you can see their names (`M8` and `M13` ), types (`A.4` and `B1.5`), recombination fraction (`rf = 0.02662`) and LOD Scores for each possible linkage phase. Clicking on a cell on the diagonal, some information about the corresponding marker is shown, including percent of missing data. This is quite useful in helping to interpret the results.

The `rf_graph_table` can also be used to check the order of markers based on the monotonicity of the matrix: as we get away from the secondary diagonal, the recombination fraction values should increase.

Looking at the matrix, it is possible to see a gap between markers `M22` and `M18` (numbers 21 and 17). In some cases, gaps could indicate that the group must be divided at this position, but here `SNP14` also show linkage with `M8`, which points that probabily it is only a gap. Adding more markers to this groups could fill this gap.

## Genetic mapping of linkage group 2

Now, let us map the markers in linkage group number 2.

Again, `extract` that group from the object `LGs`:

    LG2 <- make_seq(LGs, 2)
    LG2
    #>
    #> Number of markers: 17
    #> Markers in the sequence:
    #> M4 M9 M16 M20 M21 M23 M24 M27 M29 SNP17 SNP18 SNP20 SNP21 SNP22 SNP23
    #> SNP24 SNP25
    #>
    #> Parameters not estimated.

Note that there are 10 markers in this group, so it is infeasible to use the `compare` function with all of them because it will take a very long time to proceed.

First, use `rcd` to get a preliminary order estimate:

    LG2_rcd <- rcd(LG2)
    #>
    #> order obtained using RCD algorithm:
    #>
    #>  20 4 23 45 48 9 46 21 27 16 47 50 24 49 52 51 29
    #>
    #> calculating multipoint map using tol =  1e-04 .
    LG2_rcd
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 20 M20                0.00           a |  | b       c |  | d
    #>  4 M4                12.77           a |  | o       o |  | b
    #> 23 M23               29.17           a |  | o       a |  | o
    #> 45 SNP17             40.14           a |  | b       a |  | a
    #> 48 SNP21             50.79           a |  | b       a |  | a
    #>  9 M9                55.41           a |  | b       a |  | a
    #> 46 SNP18             60.16           a |  | b       a |  | a
    #> 21 M21               60.16           o |  | o       a |  | b
    #> 27 M27              101.48           b |  | o       a |  | a
    #> 16 M16              101.49           a |  | a       b |  | o
    #> 47 SNP20            165.05           a |  | b       a |  | a
    #> 50 SNP23            196.42           a |  | b       a |  | b
    #> 24 M24              201.45           a |  | b       a |  | b
    #> 49 SNP22            204.78           a |  | b       a |  | b
    #> 52 SNP25            209.74           a |  | b       a |  | b
    #> 51 SNP24            220.79           a |  | b       a |  | b
    #> 29 M29              250.34           o |  | a       o |  | o
    #>
    #> 17 markers            log-likelihood: -952.9627

Use the `marker_type` function to check the segregation types of all markers in this group:

    marker_type(LG2)
    #>   Marker 4 ( M4 ) is of type A.4
    #>   Marker 9 ( M9 ) is of type D1.10
    #>   Marker 16 ( M16 ) is of type D2.17
    #>   Marker 20 ( M20 ) is of type A.1
    #>   Marker 21 ( M21 ) is of type D2.16
    #>   Marker 23 ( M23 ) is of type C.8
    #>   Marker 24 ( M24 ) is of type B3.7
    #>   Marker 27 ( M27 ) is of type D1.12
    #>   Marker 29 ( M29 ) is of type D1.13
    #>   Marker 45 ( SNP17 ) is of type D1.10
    #>   Marker 46 ( SNP18 ) is of type D1.10
    #>   Marker 47 ( SNP20 ) is of type D1.10
    #>   Marker 48 ( SNP21 ) is of type D1.10
    #>   Marker 49 ( SNP22 ) is of type B3.7
    #>   Marker 50 ( SNP23 ) is of type B3.7
    #>   Marker 51 ( SNP24 ) is of type B3.7
    #>   Marker 52 ( SNP25 ) is of type B3.7

Based on their segregation types and distribution on the preliminary map, markers `M4`, `M20`, `M24`, `SNP22`, `SNP23`, `SNP24` and `SNP25` are the most informative ones (type `A` is better, followed by type `B`). So, let us create a framework of ordered markers using `compare` for the most informative ones:

    LG2_init <- make_seq(twopts, c(4, 20, 24, 49,50,51))

Now, the first argument to `make_seq` is an object of class `rf_2pts`, and the second argument is a vector of integers, specifying which molecular markers comprise the sequence.

    LG2_comp <- compare(LG2_init)

Select the best order:

    LG2_frame <- make_seq(LG2_comp)

Also, we can obtain a useful diagnostic graphic using the function `rf_graph_table`.

    rf_graph_table(LG2_frame)

The graphic shows that there are two groups of markers, once `M20` and `M4` are far from the other markers. This markers could be in different linkage groups or they are distant in the same group. Adding more markers will give more informations to solve this issue.

Next, let us try to map the remaining markers, one at a time. Fist, we will try to add the remaining most informative markers. Starting with `SNP25`:

    LG2_extend <- try_seq(LG2_frame, 52)

    LG2_extend
    #>
    #> LOD scores correspond to the best linkage phase combination
    #> for each position
    #>
    #> The symbol "*" outside the box indicates that more than one
    #> linkage phase is possible for the corresponding position
    #>
    #>
    #>        Marker tested: 52
    #>
    #>        Markers     LOD
    #>      =====================
    #>      |                   |
    #>      |           -26.44  |  1
    #>      |  20               |
    #>      |           -50.47  |  2
    #>      |   4               |
    #>      |            -8.34  |  3
    #>      |  51               |
    #>      |            -8.79  |  4
    #>      |  50               |
    #>      |            -8.43  |  5
    #>      |  24               |
    #>      |            -2.46  |  6
    #>      |  49               |
    #>      |             0.00  |  7
    #>      |                   |
    #>      =====================

Based on the LOD Scores, marker SNP25 is probably better located after `SNP22`. Detailed results can be seen with

    print(LG2_extend, 7)
    #>
    #> LOD is the overall LOD score (among all orders)
    #>
    #> NEST.LOD is the LOD score within the order
    #>
    #> Marker tested: 52
    #> --------------
    #> |     |      |
    #> | 20  |      |
    #> |     |  CR  |
    #> |  4  |      |
    #> |     |  CC  |
    #> | 51  |      |
    #> |     |  CC  |
    #> | 50  |      |
    #> |     |  CC  |
    #> | 24  |      |
    #> |     |  CC  |
    #> | 49  |      |
    #> |     |  CC  |
    #> | 52  |      |
    #> |     |      |
    #> |------------|
    #> | LOD |   0.0|
    #> |------------|
    #> |NEST.|      |
    #> | LOD |   0.0|
    #> --------------

The second argument indicates the position where to place the marker. Note that the first allele arrangement is the most likely one.

It should be pointed out that the framework created by the function `compare` (with `M20`, `M4`, `SNP24`, `SNP23`, `M24` and `SNP22`) could be in reverse order (`SNP22`, `M24`, `SNP23`, `SNP24`, `M4` and `M20`) and still represent the same map.Thus, positioning of markers with the `try_seq` command can be different in your computer. For example, here marker `SNP25` was better placed at position 7; however if you obtain a reversed order, marker `SNP25` would be better placed in position 1. In both cases the best position for this marker is after `SNP22`.

We can better evaluate the order with `rf_graph_table`. It requires a object of `sequence` class with mapping informations.

    LG2_test <- make_seq(LG2_extend, 7, 1)

When using `make_seq` with an object of class `try`, the second argument is the position on the map (according to the scale on the right of the output) and the last argument indicates linkage phases (defaults to 1, higher nested LOD).

    rf_graph_table(LG2_test)

We can see that `SNP25` (or marker 52) was positioned at the end of the sequence and the colour pattern shows that it is strongly linked with its neighbors, indicating that it is well positioned, then we will maintain this marker at this position:

    LG2_frame <- LG2_test

Adding other markers, one by one (output not shown):

    LG2_extend <- try_seq(LG2_frame, 9)
    LG2_frame <- make_seq(LG2_extend, 3)
    LG2_extend <- try_seq(LG2_frame, 16)
    LG2_frame <- make_seq(LG2_extend, 1)
    LG2_extend <- try_seq(LG2_frame, 21)
    LG2_frame <- make_seq(LG2_extend, 4)
    LG2_extend <- try_seq(LG2_frame, 23)
    LG2_frame <- make_seq(LG2_extend, 5)
    LG2_extend <- try_seq(LG2_frame, 27)
    LG2_frame <- make_seq(LG2_extend, 1)
    LG2_extend <- try_seq(LG2_frame, 29)
    LG2_frame <- make_seq(LG2_extend, 12)
    LG2_extend <- try_seq(LG2_frame, 45)
    LG2_frame <- make_seq(LG2_extend, 7)
    LG2_extend <- try_seq(LG2_frame, 46)
    LG2_frame <- make_seq(LG2_extend, 6)
    LG2_extend <- try_seq(LG2_frame, 47)
    LG2_frame <- make_seq(LG2_extend, 6)
    LG2_extend <- try_seq(LG2_frame, 48)
    LG2_final <- make_seq(LG2_extend, 6)

Checking graphically:

    rf_graph_table(LG2_final)

The process of adding markers sequentially can be automated with the use of function `order_seq`.

    LG2_ord <- order_seq(LG2, n.init = 5, THRES = 3)
    #>
    #> Cross type: outcross
    #> Using segregation types of the markers to choose initial subset
    #>
    #> Comparing 60 orders:
    #>
    #>
      |
      |                                                                 |   0%
      |
      |=                                                                |   2%
      |
      |==                                                               |   3%
      |
      |===                                                              |   5%
      |
      |====                                                             |   7%
      |
      |=====                                                            |   8%
      |
      |======                                                           |  10%
      |
      |========                                                         |  12%
      |
      |=========                                                        |  13%
      |
      |==========                                                       |  15%
      |
      |===========                                                      |  17%
      |
      |============                                                     |  18%
      |
      |=============                                                    |  20%
      |
      |==============                                                   |  22%
      |
      |===============                                                  |  23%
      |
      |================                                                 |  25%
      |
      |=================                                                |  27%
      |
      |==================                                               |  28%
      |
      |====================                                             |  30%
      |
      |=====================                                            |  32%
      |
      |======================                                           |  33%
      |
      |=======================                                          |  35%
      |
      |========================                                         |  37%
      |
      |=========================                                        |  38%
      |
      |==========================                                       |  40%
      |
      |===========================                                      |  42%
      |
      |============================                                     |  43%
      |
      |=============================                                    |  45%
      |
      |==============================                                   |  47%
      |
      |===============================                                  |  48%
      |
      |================================                                 |  50%
      |
      |==================================                               |  52%
      |
      |===================================                              |  53%
      |
      |====================================                             |  55%
      |
      |=====================================                            |  57%
      |
      |======================================                           |  58%
      |
      |=======================================                          |  60%
      |
      |========================================                         |  62%
      |
      |=========================================                        |  63%
      |
      |==========================================                       |  65%
      |
      |===========================================                      |  67%
      |
      |============================================                     |  68%
      |
      |==============================================                   |  70%
      |
      |===============================================                  |  72%
      |
      |================================================                 |  73%
      |
      |=================================================                |  75%
      |
      |==================================================               |  77%
      |
      |===================================================              |  78%
      |
      |====================================================             |  80%
      |
      |=====================================================            |  82%
      |
      |======================================================           |  83%
      |
      |=======================================================          |  85%
      |
      |========================================================         |  87%
      |
      |=========================================================        |  88%
      |
      |==========================================================       |  90%
      |
      |============================================================     |  92%
      |
      |=============================================================    |  93%
      |
      |==============================================================   |  95%
      |
      |===============================================================  |  97%
      |
      |================================================================ |  98%
      |
      |=================================================================| 100%
    #>
    #>
    #>
    #> Running try algorithm
    #> 51 --> SNP24 : ......
    #> 52 --> SNP25 : ......
    #> 23 --> M23   : ......
    #>  9 --> M9    : .......
    #> 27 --> M27   : .......
    #> 29 --> M29   : ........
    #> 45 --> SNP17 : ........
    #> 46 --> SNP18 : .........
    #> 47 --> SNP20 : .........
    #> 48 --> SNP21 : .........
    #> 16 --> M16   : .........
    #> 21 --> M21   : .........
    #>
    #> LOD threshold = 3
    #>
    #> Positioned markers: 27 20 4 21 23 45 50 24 49
    #>
    #> Markers not placed on the map: 9 16 29 46 47 48 51 52
    #>
    #>
    #> Calculating LOD-Scores
    #>  9 --> M9    : ..........
    #> 16 --> M16   : ..........
    #> 29 --> M29   : ..........
    #> 46 --> SNP18 : ..........
    #> 47 --> SNP20 : ..........
    #> 48 --> SNP21 : ..........
    #> 51 --> SNP24 : ..........
    #> 52 --> SNP25 : ..........
    #>
    #>
    #> Placing remaining marker(s) at most likely position
    #> 52 --> SNP25 : ..........
    #> 46 --> SNP18 : ...........
    #> 48 --> SNP21 : ............
    #>  9 --> M9    : .............
    #> 29 --> M29   : ..............
    #> 47 --> SNP20 : ...............
    #> 51 --> SNP24 : ................
    #> 16 --> M16   : .................
    #>
    #> Estimating final genetic map using tol = 10E-5.

Basically, this function automates what the `try_seq` function does, using some pre-defined rules. In the function, `n.init = 5` means that five markers (the most informative ones) will be used in the `compare` step; `THRES = 3` indicates that the `try_seq` step will only add markers to the sequence which can be mapped with LOD Score greater than 3.

NOTE: Although very useful, this function can be misleading, specially if there are not many fully informative markers, so use it carefully. Results can vary between multiple runs on the same markers, of course.

Check the final order:

    LG2_ord
    #>
    #> Best sequence found.
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 27 M27                0.00           b |  | o       a |  | a
    #> 20 M20               21.18           a |  | b       c |  | d
    #>  4 M4                33.95           a |  | o       o |  | b
    #> 21 M21               47.95           o |  | o       a |  | b
    #> 23 M23               53.59           a |  | o       a |  | o
    #> 45 SNP17             72.79           a |  | b       a |  | a
    #> 50 SNP23            101.92           a |  | b       b |  | a
    #> 24 M24              106.95           a |  | b       b |  | a
    #> 49 SNP22            110.83           a |  | b       b |  | a
    #>
    #> 9 markers            log-likelihood: -548.6658
    #>
    #>
    #>
    #> The following markers could not be uniquely positioned.
    #> Printing most likely positions for each unpositioned marker:
    #>
    #> ------------------------------------------------------
    #> |    |   9 |  16 |  29 |  46 |  47 |  48 |  51 |  52 |
    #> |----|-----|-----|-----|-----|-----|-----|-----|-----|
    #> |    |     | **  |     |     |     |     |     |     |
    #> | 27 |     |     |     |     |     |     |     |     |
    #> |    |     | *** |     |     |     |     |     |     |
    #> | 20 |     |     |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |     |     |
    #> |  4 |     |     |     |     |     |     |     |     |
    #> |    |     |     |     |     |     | *   |     |     |
    #> | 21 |     |     |     |     |     |     |     |     |
    #> |    |     |     |     |     |     | *   |     |     |
    #> | 23 |     |     |     |     |     |     |     |     |
    #> |    | *** |     |     |     | **  | *** |     |     |
    #> | 45 |     |     |     |     |     |     |     |     |
    #> |    | *   |     | **  | *** | *** | *   | *** |     |
    #> | 50 |     |     |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |     |     |
    #> | 24 |     |     |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |     |     |
    #> | 49 |     |     |     |     |     |     |     |     |
    #> |    |     |     | *** |     |     |     | **  | *** |
    #> ------------------------------------------------------
    #>
    #> '***' indicates the most likely position(s) (LOD = 0.0)
    #>
    #> '**' indicates very likely positions (LOD > -1.0)
    #>
    #> '*' indicates likely positions (LOD > -2.0)

Note that markers `9`, `16`, `29`, `46`, `47`, `48`, `51` and `52` could not be safely mapped to a single position (`LOD Score > THRES` in absolute value). The output displays the `safe` order and the most likely positions for markers not mapped, where `***` indicates the most likely position and `*` corresponds to other plausible positions.

To get the safe order (i.e., without markers `9`, `16`, `29`, `46`, `47`, `48`, `51` and `52`), use

    LG2_safe <- make_seq(LG2_ord, "safe")

and to get the order with all markers, use

    LG2_all <- make_seq(LG2_ord, "force")
    LG2_all
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 27 M27                0.00           b |  | o       a |  | a
    #> 16 M16               11.74           a |  | a       b |  | o
    #> 20 M20               22.93           a |  | b       c |  | d
    #>  4 M4                35.70           a |  | o       o |  | b
    #> 21 M21               49.45           o |  | o       a |  | b
    #> 23 M23               55.14           a |  | o       a |  | o
    #> 48 SNP21             67.95           a |  | b       a |  | a
    #>  9 M9                74.08           a |  | b       a |  | a
    #> 45 SNP17             82.64           a |  | b       a |  | a
    #> 46 SNP18             97.89           a |  | b       a |  | a
    #> 47 SNP20            114.31           a |  | b       a |  | a
    #> 50 SNP23            143.74           a |  | b       b |  | a
    #> 24 M24              148.75           a |  | b       b |  | a
    #> 49 SNP22            152.08           a |  | b       b |  | a
    #> 52 SNP25            157.05           a |  | b       b |  | a
    #> 51 SNP24            168.11           a |  | b       b |  | a
    #> 29 M29              198.00           o |  | a       o |  | o
    #>
    #> 17 markers            log-likelihood: -869.83

Notice that, for this linkage group, the `forced` map obtained with `order_seq` is different from that obtained with `compare` plus `try_seq`. It depends of which markers we choose to try add first when doing manually.

The `order_seq` function can also perform two rounds of the `try_seq` algorithms, first using `THRES` and then `THRES - 1` as threshold. This generally results in safe orders with more markers mapped, but may take longer to run. To do this use the `touchdown` option:

    LG2_ord <- order_seq(LG2, n.init = 5, THRES = 3, touchdown = TRUE)

    LG2_ord
    #>
    #> Best sequence found.
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 27 M27                0.00           b |  | o       a |  | a
    #> 20 M20               21.18           a |  | b       c |  | d
    #>  4 M4                33.95           a |  | o       o |  | b
    #> 21 M21               47.96           o |  | o       a |  | b
    #> 23 M23               53.62           a |  | o       a |  | o
    #> 45 SNP17             72.17           a |  | b       a |  | a
    #> 46 SNP18             87.10           a |  | b       a |  | a
    #> 50 SNP23            115.03           a |  | b       b |  | a
    #> 24 M24              120.05           a |  | b       b |  | a
    #> 49 SNP22            123.35           a |  | b       b |  | a
    #> 52 SNP25            128.36           a |  | b       b |  | a
    #>
    #> 11 markers            log-likelihood: -625.2533
    #>
    #>
    #>
    #> The following markers could not be uniquely positioned.
    #> Printing most likely positions for each unpositioned marker:
    #>
    #> ------------------------------------------
    #> |    |   9 |  16 |  29 |  47 |  48 |  51 |
    #> |----|-----|-----|-----|-----|-----|-----|
    #> |    |     | **  |     |     |     |     |
    #> | 27 |     |     |     |     |     |     |
    #> |    |     | *** |     |     |     |     |
    #> | 20 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> |  4 |     |     |     |     |     |     |
    #> |    |     |     |     |     | *   |     |
    #> | 21 |     |     |     |     |     |     |
    #> |    |     |     |     |     | *   |     |
    #> | 23 |     |     |     |     |     |     |
    #> |    |     |     |     | *   | *** |     |
    #> | 45 |     |     |     |     |     |     |
    #> |    | *** |     |     | *   | **  |     |
    #> | 46 |     |     |     |     |     |     |
    #> |    |     |     | **  | *** | **  | **  |
    #> | 50 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 24 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 49 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 52 |     |     |     |     |     |     |
    #> |    |     |     | *** |     |     | *** |
    #> ------------------------------------------
    #>
    #> '***' indicates the most likely position(s) (LOD = 0.0)
    #>
    #> '**' indicates very likely positions (LOD > -1.0)
    #>
    #> '*' indicates likely positions (LOD > -2.0)

For this particular sequence, the `touchdown` step could map safely markers `46` and `52`, but this depends on the specific dataset.

Finally, to check for alternative orders (because we did not use exhaustive search), use the `ripple_seq` function:

    ripple_seq(LG2_all, ws = 4, LOD = LOD_sug)
    #> 27-16-20-4-|-21-...
    #>   Alternative orders:
    #>    27 16 20 4 21 ... :    0.00 ( linkage phases: 1 1 2 2 ... )
    #>    16 27 20 4 21 ... :   -0.02 ( linkage phases: 1 1 2 2 ... )
    #>
    #> ...-27-|-16-20-4-21-|-23-... OK
    #>
    #> ...-16-|-20-4-21-23-|-48-...
    #>   Alternative orders:
    #>   ... 16 20 4 21 23 48 ... :    0.00 ( linkage phases: ... 1 2 2 1 1 ... )
    #>   ... 16 20 4 23 21 48 ... :   -2.62 ( linkage phases: ... 1 2 2 1 1 ... )
    #>
    #> ...-20-|-4-21-23-48-|-9-...
    #>   Alternative orders:
    #>   ... 20 4 21 23 48 9 ... :    0.00 ( linkage phases: ... 2 2 1 1 1 ... )
    #>   ... 20 4 23 21 48 9 ... :   -2.62 ( linkage phases: ... 2 2 1 1 1 ... )
    #>
    #> ...-4-|-21-23-48-9-|-45-...
    #>   Alternative orders:
    #>   ... 4 21 23 48 9 45 ... :    0.00 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 4 23 21 48 9 45 ... :   -2.62 ( linkage phases: ... 2 1 1 1 1 ... )
    #>
    #> ...-21-|-23-48-9-45-|-46-...
    #>   Alternative orders:
    #>   ... 21 23 48 9 45 46 ... :    0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 21 23 48 45 9 46 ... :   -0.31 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 21 23 45 48 9 46 ... :   -0.31 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 21 23 45 9 48 46 ... :   -0.68 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 21 48 23 45 9 46 ... :   -1.97 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-23-|-48-9-45-46-|-47-...
    #>   Alternative orders:
    #>   ... 23 48 9 46 45 47 ... :   0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 48 9 45 46 47 ... :  -0.81 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 48 46 9 45 47 ... :  -0.83 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 48 45 9 46 47 ... :  -1.12 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 45 48 9 46 47 ... :  -1.12 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 45 46 9 48 47 ... :  -1.12 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 45 9 48 46 47 ... :  -1.49 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 45 9 46 48 47 ... :  -1.49 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 23 48 45 46 9 47 ... :  -3.44 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-48-|-9-45-46-47-|-50-...
    #>   Alternative orders:
    #>   ... 48 9 46 45 47 50 ... :    0.00 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 9 46 47 45 50 ... :   -0.56 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 9 45 46 47 50 ... :   -0.81 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 46 9 45 47 50 ... :   -0.83 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 45 9 46 47 50 ... :   -1.12 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 47 46 9 45 50 ... :   -1.93 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 9 45 47 46 50 ... :   -2.39 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 47 45 9 46 50 ... :   -3.02 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 45 46 9 47 50 ... :   -3.44 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 9 47 46 45 50 ... :   -3.49 ( linkage phases: ... 1 1 1 1 2 ... )
    #>   ... 48 46 9 47 45 50 ... :   -3.51 ( linkage phases: ... 1 1 1 1 2 ... )
    #>
    #> ...-9-|-45-46-47-50-|-24-...
    #>   Alternative orders:
    #>   ... 9 46 45 47 50 24 ... :    0.00 ( linkage phases: ... 1 1 1 2 1 ... )
    #>   ... 9 46 47 45 50 24 ... :   -0.56 ( linkage phases: ... 1 1 1 2 1 ... )
    #>   ... 9 45 46 47 50 24 ... :   -0.81 ( linkage phases: ... 1 1 1 2 1 ... )
    #>   ... 9 45 47 46 50 24 ... :   -2.39 ( linkage phases: ... 1 1 1 2 1 ... )
    #>   ... 9 47 46 45 50 24 ... :   -3.49 ( linkage phases: ... 1 1 1 2 1 ... )
    #>
    #> ...-45-|-46-47-50-24-|-49-...
    #>   Alternative orders:
    #>   ... 45 46 47 50 24 49 ... :    0.00 ( linkage phases: ... 1 1 2 1 1 ... )
    #>   ... 45 47 46 50 24 49 ... :   -1.58 ( linkage phases: ... 1 1 2 1 1 ... )
    #>
    #> ...-46-|-47-50-24-49-|-52-... OK
    #>
    #> ...-47-|-50-24-49-52-|-51-...
    #>   Alternative orders:
    #>   ... 47 50 24 49 52 51 ... :    0.00 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 47 52 49 24 50 51 ... :   -0.55 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 47 50 24 52 49 51 ... :   -2.75 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 47 49 52 24 50 51 ... :   -2.81 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 47 50 52 49 24 51 ... :   -3.11 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 47 50 49 52 24 51 ... :   -3.62 ( linkage phases: ... 2 1 1 1 1 ... )
    #>
    #> ...-50-|-24-49-52-51-|-29-...
    #>   Alternative orders:
    #>   ... 50 24 49 52 51 29 :    0.00 ( linkage phases: ... 1 1 1 1 3 )
    #>   ... 50 24 52 49 51 29 :   -2.75 ( linkage phases: ... 1 1 1 1 3 )
    #>   ... 50 51 24 49 52 29 :   -2.86 ( linkage phases: ... 1 1 1 1 3 )
    #>   ... 50 52 49 24 51 29 :   -3.11 ( linkage phases: ... 1 1 1 1 3 )
    #>   ... 50 49 52 24 51 29 :   -3.62 ( linkage phases: ... 1 1 1 1 3 )
    #>
    #> 24-|-49-52-51-29
    #>   Alternative orders:
    #>   ... 24 49 52 51 29 :    0.00 ( linkage phases: ... 1 1 1 3 )
    #>   ... 24 52 49 51 29 :   -2.75 ( linkage phases: ... 1 1 1 3 )

We should do this to any of the orders we found, either using `try_seq` or `order_seq`. Here, we choose `LG2_all` for didactic purposes only. The second argument, `ws = 4`, means that subsets (windows) of four markers will be permutated sequentially (`4!` orders for each window), to search for other plausible orders. The `LOD` argument means that only orders with LOD Score smaller than 3.67 will be printed.

The output shows sequences of four numbers, because `ws = 4`. They are followed by an `OK` if there is no alternative order with LOD Score smaller than `LOD = LOD_sug` in absolute value, or by a list of alternative orders. In the example, some sequences showed alternative orders with LOD smaller than `LOD = LOD_sug`. However, the best order was the original one (`LOD = 0.00`).

If there were an alternative order more likely than the original, one should check the difference between these orders (and linkage phases).

In some cases, even if there are no better alternative order suggested by `ripple_seq`, the graphic showed color pattern different of the expected. Then, we can remove doubtful markers (for this groups markers `23` and `51`) and try to positioned them again. First, we use the function `drop_marker` to remove selected marker of our sequence.

    LG2_test_seq <- drop_marker(LG2_all, c(23,51))

The function will provide a sequence with the same order of the estimated map (`LG2_all`). After, we should estimate the map again using this predefined order. For this we use the `map` function:

    (LG2_test_map <- map(LG2_test_seq))
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 27 M27                0.00           b |  | o       a |  | a
    #> 16 M16                0.00           a |  | a       b |  | o
    #> 20 M20               16.03           a |  | b       c |  | d
    #>  4 M4                28.80           a |  | o       o |  | b
    #> 21 M21               46.26           o |  | o       a |  | b
    #> 48 SNP21             46.26           a |  | b       a |  | a
    #>  9 M9                52.76           a |  | b       a |  | a
    #> 45 SNP17             61.38           a |  | b       a |  | a
    #> 46 SNP18             76.76           a |  | b       a |  | a
    #> 47 SNP20             93.31           a |  | b       a |  | a
    #> 50 SNP23            122.96           a |  | b       b |  | a
    #> 24 M24              127.97           a |  | b       b |  | a
    #> 49 SNP22            131.35           a |  | b       b |  | a
    #> 52 SNP25            136.45           a |  | b       b |  | a
    #> 29 M29              164.84           o |  | a       o |  | o
    #>
    #> 15 markers            log-likelihood: -781.656

Now we have the map without markers `23` and `51`.

    rf_graph_table(LG2_test_map)

We use `try_seq` function to positioned them again:

    LG2_test_seq <- try_seq(LG2_test_map, 51)
    #> 51 --> SNP24 : ................
    LG2_test_51 <- make_seq(LG2_test_seq, 15)
    LG2_test_seq <- try_seq(LG2_test_51, 23)
    #> 23 --> M23   : .................
    LG2_test_51_23 <- make_seq(LG2_test_seq, 6)

Markers 23 and 51 was positioned at the same position as before. We will remove marker 23 of our map, because it color pattern are too different of expected. Then, our final map is:

    LG2_final <- LG2_test_51
    LG2_final
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 27 M27                0.00           b |  | o       a |  | a
    #> 16 M16                0.10           a |  | a       b |  | o
    #> 20 M20               16.13           a |  | b       c |  | d
    #>  4 M4                28.90           a |  | o       o |  | b
    #> 21 M21               46.36           o |  | o       a |  | b
    #> 48 SNP21             46.46           a |  | b       a |  | a
    #>  9 M9                52.96           a |  | b       a |  | a
    #> 45 SNP17             61.58           a |  | b       a |  | a
    #> 46 SNP18             76.94           a |  | b       a |  | a
    #> 47 SNP20             93.48           a |  | b       a |  | a
    #> 50 SNP23            123.24           a |  | b       b |  | a
    #> 24 M24              128.25           a |  | b       b |  | a
    #> 49 SNP22            131.61           a |  | b       b |  | a
    #> 52 SNP25            136.62           a |  | b       b |  | a
    #> 51 SNP24            147.69           a |  | b       b |  | a
    #> 29 M29              176.73           o |  | a       o |  | o
    #>
    #> 16 markers            log-likelihood: -840.2059

## Genetic mapping of linkage group 1

Finally, linkage group 1 (the largest one) will be analyzed. Extract markers:

    LG1 <- make_seq(LGs, 1)

Construct the linkage map, by automatically using try algorithm:

    LG1_ord <- order_seq(LG1, n.init = 6, touchdown = TRUE)

Notice that the second round of `try_seq` added markers `10`, `31`, `32`, `35`, `36`, `40` and `42`.

    LG1_ord
    #>
    #> Best sequence found.
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 34 SNP5               0.00           a |  | b       a |  | b
    #> 32 SNP2              13.48           a |  | b       a |  | b
    #> 12 M12               17.26           b |  | a       c |  | a
    #> 31 SNP1              22.81           a |  | b       a |  | b
    #>  3 M3                46.09           o |  | a       o |  | o
    #> 14 M14               59.22           a |  | o       b |  | o
    #>  2 M2                66.93           o |  | o       o |  | a
    #> 36 SNP7              92.49           b |  | a       b |  | a
    #> 35 SNP6             105.45           b |  | a       b |  | a
    #>  1 M1               109.86           b |  | a       b |  | a
    #> 10 M10              115.37           a |  | a       o |  | b
    #> 28 M28              132.05           a |  | o       b |  | o
    #> 26 M26              164.42           a |  | b       d |  | c
    #> 42 SNP13            179.54           b |  | a       b |  | a
    #>  6 M6               185.89           b |  | a       b |  | a
    #> 39 SNP10            192.06           b |  | a       b |  | a
    #> 41 SNP12            208.53           b |  | a       b |  | a
    #> 40 SNP11            225.65           b |  | a       b |  | a
    #> 15 M15              267.89           o |  | a       o |  | b
    #>
    #> 19 markers            log-likelihood: -1313.595
    #>
    #>
    #>
    #> The following markers could not be uniquely positioned.
    #> Printing most likely positions for each unpositioned marker:
    #>
    #> ------------------------------------------
    #> |    |   5 |  11 |  30 |  33 |  37 |  38 |
    #> |----|-----|-----|-----|-----|-----|-----|
    #> |    |     |     |     |     |     |     |
    #> | 34 |     |     |     |     |     |     |
    #> |    |     |     |     | *** |     |     |
    #> | 32 |     |     |     |     |     |     |
    #> |    |     |     | *** | *   |     |     |
    #> | 12 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 31 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> |  3 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 14 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> |  2 |     |     |     |     |     |     |
    #> |    |     |     |     |     | *   |     |
    #> | 36 |     |     |     |     |     |     |
    #> |    |     |     |     |     | **  | *   |
    #> | 35 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> |  1 |     |     |     |     |     |     |
    #> |    |     |     |     |     | *** | *** |
    #> | 10 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 28 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 26 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 42 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> |  6 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 39 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 41 |     |     |     |     |     |     |
    #> |    |     |     |     |     |     |     |
    #> | 40 |     |     |     |     |     |     |
    #> |    | **  | **  |     |     |     |     |
    #> | 15 |     |     |     |     |     |     |
    #> |    | *** | *** |     |     |     |     |
    #> ------------------------------------------
    #>
    #> '***' indicates the most likely position(s) (LOD = 0.0)
    #>
    #> '**' indicates very likely positions (LOD > -1.0)
    #>
    #> '*' indicates likely positions (LOD > -2.0)

Now, get the order with all markers:

    (LG1_frame <- make_seq(LG1_ord, "force"))
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 34 SNP5               0.00           a |  | b       a |  | b
    #> 33 SNP3              12.27           a |  | b       a |  | b
    #> 32 SNP2              18.45           a |  | b       a |  | b
    #> 30 M30               21.21           a |  | b       a |  | b
    #> 12 M12               22.22           b |  | a       c |  | a
    #> 31 SNP1              27.77           a |  | b       a |  | b
    #>  3 M3                51.05           o |  | a       o |  | o
    #> 14 M14               64.18           a |  | o       b |  | o
    #>  2 M2                72.05           o |  | o       o |  | a
    #> 36 SNP7              95.86           b |  | a       b |  | a
    #> 37 SNP8             112.04           b |  | a       b |  | a
    #> 35 SNP6             126.75           b |  | a       b |  | a
    #>  1 M1               131.15           b |  | a       b |  | a
    #> 38 SNP9             137.28           b |  | a       b |  | a
    #> 10 M10              148.79           a |  | a       o |  | b
    #> 28 M28              165.35           a |  | o       b |  | o
    #> 26 M26              197.72           a |  | b       d |  | c
    #> 42 SNP13            212.84           b |  | a       b |  | a
    #>  6 M6               219.19           b |  | a       b |  | a
    #> 39 SNP10            225.36           b |  | a       b |  | a
    #> 41 SNP12            241.82           b |  | a       b |  | a
    #> 40 SNP11            258.95           b |  | a       b |  | a
    #> 15 M15              301.19           o |  | a       o |  | b
    #>  5 M5               306.20           o |  | o       o |  | a
    #> 11 M11              326.21           o |  | o       b |  | a
    #>
    #> 25 markers            log-likelihood: -1554.628

Check the map graphically:

    rf_graph_table(LG1_frame)

Check for alternative orders:

    ripple_seq(LG1_frame)
    #> 34-33-32-30-|-12-...
    #>   Alternative orders:
    #>    34 33 32 30 12 ... :    0.00 ( linkage phases: 1 1 1 4 ... )
    #>    34 32 33 30 12 ... :   -1.29 ( linkage phases: 1 1 1 4 ... )
    #>    34 33 30 32 12 ... :   -1.55 ( linkage phases: 1 1 1 4 ... )
    #>
    #> ...-34-|-33-32-30-12-|-31-...
    #>   Alternative orders:
    #>    34 33 12 30 32 31 ... :    0.00 ( linkage phases:  1 4 4 1 1 ... )
    #>    34 33 30 12 32 31 ... :   -0.25 ( linkage phases:  1 1 4 4 1 ... )
    #>    34 33 32 30 12 31 ... :   -0.59 ( linkage phases:  1 1 1 4 4 ... )
    #>    34 32 33 30 12 31 ... :   -1.88 ( linkage phases:  1 1 1 4 4 ... )
    #>    34 33 30 32 12 31 ... :   -2.14 ( linkage phases:  1 1 1 4 4 ... )
    #>    34 33 32 12 30 31 ... :   -2.74 ( linkage phases:  1 1 4 4 1 ... )
    #>
    #> ...-33-|-32-30-12-31-|-3-...
    #>   Alternative orders:
    #>   ... 33 12 30 32 31 3 ... :    0.00 ( linkage phases: ... 4 4 1 1 4 ... )
    #>   ... 33 30 12 32 31 3 ... :   -0.25 ( linkage phases: ... 1 4 4 1 4 ... )
    #>   ... 33 32 30 12 31 3 ... :   -0.59 ( linkage phases: ... 1 1 4 4 4 ... )
    #>   ... 33 30 32 12 31 3 ... :   -2.14 ( linkage phases: ... 1 1 4 4 4 ... )
    #>   ... 33 32 12 30 31 3 ... :   -2.74 ( linkage phases: ... 1 4 4 1 4 ... )
    #>
    #> ...-32-|-30-12-31-3-|-14-...
    #>   Alternative orders:
    #>   ... 32 30 12 31 3 14 ... :    0.00 ( linkage phases: ... 1 4 4 4 4 ... )
    #>   ... 32 12 30 31 3 14 ... :   -2.15 ( linkage phases: ... 4 4 1 4 4 ... )
    #>
    #> ...-30-|-12-31-3-14-|-2-... OK
    #>
    #> ...-12-|-31-3-14-2-|-36-... OK
    #>
    #> ...-31-|-3-14-2-36-|-37-... OK
    #>
    #> ...-3-|-14-2-36-37-|-35-...
    #>   Alternative orders:
    #>   ... 3 14 2 36 37 35 ... :    0.00 ( linkage phases: ... 4 2 3 1 1 ... )
    #>   ... 3 14 2 37 36 35 ... :   -0.89 ( linkage phases: ... 4 2 3 1 1 ... )
    #>
    #> ...-14-|-2-36-37-35-|-1-...
    #>   Alternative orders:
    #>   ... 14 2 36 37 35 1 ... :    0.00 ( linkage phases: ... 2 3 1 1 1 ... )
    #>   ... 14 2 37 36 35 1 ... :   -0.89 ( linkage phases: ... 2 3 1 1 1 ... )
    #>
    #> ...-2-|-36-37-35-1-|-38-...
    #>   Alternative orders:
    #>   ... 2 36 37 1 35 38 ... :    0.00 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 36 37 35 1 38 ... :   -0.25 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 37 36 35 1 38 ... :   -1.14 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 37 36 1 35 38 ... :   -2.34 ( linkage phases: ... 3 1 1 1 1 ... )
    #>
    #> ...-36-|-37-35-1-38-|-10-...
    #>   Alternative orders:
    #>   ... 36 37 1 35 38 10 ... :   0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 35 1 38 10 ... :  -0.25 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 35 1 38 37 10 ... :  -1.23 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 38 35 1 10 ... :  -1.35 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 38 35 1 37 10 ... :  -1.42 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 38 1 35 10 ... :  -1.54 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 38 1 35 37 10 ... :  -1.69 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 35 38 1 37 10 ... :  -2.45 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 1 35 38 37 10 ... :  -2.50 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 1 38 35 10 ... :  -2.78 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 35 38 1 10 ... :  -2.85 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-37-|-35-1-38-10-|-28-...
    #>   Alternative orders:
    #>   ... 37 1 35 38 10 28 ... :    0.00 ( linkage phases: ... 1 1 1 1 4 ... )
    #>   ... 37 35 1 38 10 28 ... :   -0.25 ( linkage phases: ... 1 1 1 1 4 ... )
    #>   ... 37 38 35 1 10 28 ... :   -1.35 ( linkage phases: ... 1 1 1 1 4 ... )
    #>   ... 37 38 1 35 10 28 ... :   -1.54 ( linkage phases: ... 1 1 1 1 4 ... )
    #>   ... 37 1 38 35 10 28 ... :   -2.78 ( linkage phases: ... 1 1 1 1 4 ... )
    #>   ... 37 35 38 1 10 28 ... :   -2.85 ( linkage phases: ... 1 1 1 1 4 ... )
    #>
    #> ...-35-|-1-38-10-28-|-26-...
    #>   Alternative orders:
    #>   ... 35 1 38 10 28 26 ... :    0.00 ( linkage phases: ... 1 1 1 4 2 ... )
    #>   ... 35 38 1 10 28 26 ... :   -2.60 ( linkage phases: ... 1 1 1 4 2 ... )
    #>
    #> ...-1-|-38-10-28-26-|-42-... OK
    #>
    #> ...-38-|-10-28-26-42-|-6-... OK
    #>
    #> ...-10-|-28-26-42-6-|-39-...
    #>   Alternative orders:
    #>   ... 10 28 26 42 6 39 ... :    0.00 ( linkage phases: ... 4 2 3 1 1 ... )
    #>   ... 10 28 26 6 42 39 ... :   -2.30 ( linkage phases: ... 4 2 3 1 1 ... )
    #>
    #> ...-28-|-26-42-6-39-|-41-...
    #>   Alternative orders:
    #>   ... 28 26 42 6 39 41 ... :    0.00 ( linkage phases: ... 2 3 1 1 1 ... )
    #>   ... 28 26 6 42 39 41 ... :   -2.30 ( linkage phases: ... 2 3 1 1 1 ... )
    #>
    #> ...-26-|-42-6-39-41-|-40-...
    #>   Alternative orders:
    #>   ... 26 42 6 39 41 40 ... :    0.00 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 26 6 42 39 41 40 ... :   -2.30 ( linkage phases: ... 3 1 1 1 1 ... )
    #>
    #> ...-42-|-6-39-41-40-|-15-... OK
    #>
    #> ...-6-|-39-41-40-15-|-5-... OK
    #>
    #> ...-39-|-41-40-15-5-|-11-...
    #>   Alternative orders:
    #>   ... 39 41 40 15 5 11 :    0.00 ( linkage phases: ... 1 1 1 1 1 )
    #>   ... 39 41 40 5 15 11 :   -2.57 ( linkage phases: ... 1 1 1 1 1 )
    #>
    #> 41-|-40-15-5-11
    #>   Alternative orders:
    #>   ... 41 40 15 5 11 :    0.00 ( linkage phases: ... 1 1 1 1 )
    #>   ... 41 40 11 5 15 :   -0.82 ( linkage phases: ... 1 1 1 1 )
    #>   ... 41 40 5 15 11 :   -2.57 ( linkage phases: ... 1 1 1 1 )
    #>   ... 41 40 11 15 5 :   -2.58 ( linkage phases: ... 1 1 1 1 )

No better order was observed.

As we made for LG2, we can remove some doubtful markers accordinly with the graphic, try to positioned them again and decide if and where we will maintain them.

    LG1_test_seq <- drop_marker(LG1_frame, c(10,11,28,42))
    LG1_test_map <- map(LG1_test_seq)

    rf_graph_table(LG1_test_map)

    LG1_extend <- try_seq(LG1_test_map,10)
    LG1_test <- make_seq(LG1_extend,15) # We choose to remove this marker
    LG1_extend <- try_seq(LG1_test_map,11)
    LG1_test <- make_seq(LG1_extend,22) # We choose to remove this marker
    LG1_extend <- try_seq(LG1_test_map,28)
    LG1_test <- make_seq(LG1_extend,15)
    LG1_extend <- try_seq(LG1_test,42)
    LG1_final <- make_seq(LG1_extend,17)

Print it:

    LG1_final
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 34 SNP5               0.00           a |  | b       a |  | b
    #> 33 SNP3              12.27           a |  | b       a |  | b
    #> 32 SNP2              18.45           a |  | b       a |  | b
    #> 30 M30               21.21           a |  | b       a |  | b
    #> 12 M12               22.22           b |  | a       c |  | a
    #> 31 SNP1              27.77           a |  | b       a |  | b
    #>  3 M3                51.05           o |  | a       o |  | o
    #> 14 M14               64.18           a |  | o       b |  | o
    #>  2 M2                72.22           o |  | o       o |  | a
    #> 36 SNP7              96.70           b |  | a       b |  | a
    #> 37 SNP8             113.11           b |  | a       b |  | a
    #> 35 SNP6             128.00           b |  | a       b |  | a
    #>  1 M1               132.41           b |  | a       b |  | a
    #> 38 SNP9             138.81           b |  | a       b |  | a
    #> 28 M28              162.61           a |  | o       b |  | o
    #> 26 M26              194.99           a |  | b       d |  | c
    #> 42 SNP13            210.41           b |  | a       b |  | a
    #>  6 M6               216.83           b |  | a       b |  | a
    #> 39 SNP10            223.00           b |  | a       b |  | a
    #> 41 SNP12            239.44           b |  | a       b |  | a
    #> 40 SNP11            256.55           b |  | a       b |  | a
    #> 15 M15              298.29           o |  | a       o |  | b
    #>  5 M5               303.30           o |  | o       o |  | a
    #>
    #> 23 markers            log-likelihood: -1470.969

    rf_graph_table(LG1_final)

As an option, different algorithms to order markers could be applied:

    LG1_ser <- seriation(LG1)
    #>
    #> order obtained using SERIATION algorithm:
    #>
    #>  37 10 36 28 38 35 1 2 14 3 12 30 33 32 31 34 42 6 26 40 41 39 11 15 5
    #>
    #> calculating multipoint map using tol =  1e-04 .
    LG1_rcd <- rcd(LG1)
    #>
    #> order obtained using RCD algorithm:
    #>
    #>  2 14 34 32 33 30 12 31 11 15 5 3 10 1 35 38 36 37 28 26 6 39 42 40 41
    #>
    #> calculating multipoint map using tol =  1e-04 .
    LG1_rec <- record(LG1)
    #>
    #> order obtained using RECORD algorithm:
    #>
    #>  34 33 32 30 12 31 14 2 36 37 1 35 38 28 10 3 11 5 15 40 41 39 6 26 42
    #>
    #> calculating multipoint map using tol 1e-04 .
    LG1_ug  <- ug(LG1)
    #>
    #> order obtained using UG algorithm:
    #>
    #>  15 5 11 3 10 1 36 37 38 35 2 14 28 33 34 31 12 32 30 26 6 42 39 41 40
    #>
    #> calculating multipoint map using tol  1e-04 .

There are some differences between the results. Seriation did not provide good results in this case. See Mollinari et al. (2009) for an evaluation of these methods.

# Using the recombinations and the reference genome informations

In our example, we have reference genome chromosome and position informations for some of the markers, here we will examplify one method of using this informations to help build the genetic map.

With the `CHROM` informations in the input file, you can identify markers belonging to some chromosome using the function `make_seq` with the `rf_2pts` object. For example, assign the string `"1"` for the second argument to get chromosome 1 makers. The output sequence will be automatically ordered by `POS` informations.

    CHR1 <- make_seq(twopts, "1")
    CHR1
    #>
    #> Number of markers: 12
    #> Markers in the sequence:
    #> SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13
    #>
    #> Parameters not estimated.
    CHR2 <- make_seq(twopts, "2")
    CHR3 <- make_seq(twopts, "3")

## Adding markers with no reference genome informations

According to `CHROM` informations we have three defined linkage groups, now we can try to group the markers without chromossome informations to them using recombination informations. For this, we can use the function `group_seq`:

    CHR_mks <- group_seq(input.2pts = twopts, seqs = "CHROM", unlink.mks = mark_no_dist,
                          rm.repeated = TRUE)
    #>    Selecting markers:
    #>    group    1
    #>     .........................
    #>    group    2
    #>     .......
    #>    group    3
    #>     .....
    #>    group    4
    #>     ..
    #>    Selecting markers:
    #>    group    1
    #>     .......
    #>    group    2
    #>     .............
    #>    group    3
    #>     .......
    #>    group    4
    #>     ..
    #>    Selecting markers:
    #>    group    1
    #>     .................
    #>    group    2
    #>     .............
    #>    group    3
    #>     .....

The function works as the function `group`, but considering preexisting sequences. Setting `seqs` argument with the string `"CHROM"`, it will considered the preexisting sequences according to `CHROM` information. You can also indicate others preexisting sequences if it make sense for your study. For that, you should inform a list with objects of class `sequences`, as the example:

    CHR_mks <- group_seq(input.2pts = twopts, seqs = list(CHR1=CHR1, CHR2=CHR2, CHR3=CHR3),
                          unlink.mks = mark_no_dist, rm.repeated = TRUE)

In this case, the command had the same effect of the previous, because we indicate chromossome sequences, but others sequences can be used.

The `unlink.mks` argument receive a object of class `sequence`, this define which markers will be tested to group with the sequences in `seqs`. In our example, we will indicate only the markers with no segregation distortion, using the sequence `mark_no_dist`. It is also possible to use the string `"all"` to test all the remining markers at the `rf_2pts` object.

In some cases, the same marker can group to more than one sequence, those markers will be considered `repeated`. We can choose if we want to remove or not (`TRUE/FALSE`) them of the output sequences, with the argument `rm.repeated`. Anyway, their numbers will be informed at the list `repeateds` in the output object. In the example case, there are no repeated markers. However, if they exists, it could indicate that their groups actually constitute the same group. Also, genotyping erros can generate repeated markers. Anyway, they deserves better investigations.

We can access detailed information about the results just printing:

    CHR_mks
    #>   This is an object of class 'group_seq'
    #>   It was generated from the object "bins_example"
    #>
    #>   Criteria used to assign markers to groups:
    #>     LOD = 3.688802 , Maximum recombination fraction = 0.5
    #>
    #>   No. markers in input sequences:
    #>                        CHR1 :   12 markers
    #>                        CHR2 :   2 markers
    #>                        CHR3 :   8 markers
    #>
    #>   No. unlinked input markers:   27 markers
    #>
    #>   No. markers in output sequences:
    #>                        CHR1 :   25 markers
    #>                        CHR2 :   7 markers
    #>                        CHR3 :   17 markers
    #>   No. unlinked:                 0 markers
    #>   No. repeated:                 0 markers
    #>
    #>   Printing output sequences:
    #>   Group CHR1 : 25 markers
    #>     SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13 M1 M2 M3 M5 M6 M10 M11 M12 M14 M15 M26 M28 M30
    #>
    #>   Group CHR2 : 7 markers
    #>     SNP14 SNP16 M7 M8 M13 M18 M22
    #>
    #>   Group CHR3 : 17 markers
    #>     SNP17 SNP18 SNP20 SNP21 SNP22 SNP23 SNP24 SNP25 M4 M9 M16 M20 M21 M23 M24 M27 M29
    #>
    #>   Unlinked markers: 0 markers
    #>
    #>
    #>   Repeated markers: 0  markers
    #>

Also, we can access the numbers of repeated markers with:

    CHR_mks$repeated
    #> [1] NA

The same way, we can access the output sequences:

    CHR_mks$sequences$CHR1
    #>
    #> Number of markers: 25
    #> Markers in the sequence:
    #> SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13 M1 M2 M3
    #> M5 M6 M10 M11 M12 M14 M15 M26 M28 M30
    #>
    #> Parameters not estimated.
    # or
    CHR_mks$sequences[[1]]
    #>
    #> Number of markers: 25
    #> Markers in the sequence:
    #> SNP1 SNP2 SNP3 SNP5 SNP6 SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13 M1 M2 M3
    #> M5 M6 M10 M11 M12 M14 M15 M26 M28 M30
    #>
    #> Parameters not estimated.

For this function, optional arguments are `LOD` and `max.rf`, which define thresholds to be used when assigning markers to linkage groups. If none provided (default), criteria previously defined for the object `rf_2pts` are used.

Now we can order the markers in each group as we made before in (Genetic mapping of linkage group 1,2 and 3). As showed, we can choose different approaches to order the markers.

To order those groups, first we will use `order_seq` function to access a preliminary order and after, we will edit some markers position or remove some of them according with they color pattern in `rf_graph_table` graphic, and other parameters as likelihood and map size.

## Genetic mapping of linkage group 1 (with reference genome informations)

    CHR1_ord <- order_seq(CHR_mks$sequences$CHR1)
    CHR1_frame <- make_seq(CHR1_ord, "force")

    rf_graph_table(CHR1_frame) # graphic not showed

The group is similar to that builded before with only recombinations informations. We will better explore differences in a latter step. Only marker `11` do not follow exactly the expected color pattern, then we will try to repositioned it.

    CHR1_test_seq <- drop_marker(CHR1_frame, 11)
    CHR1_test_map <- map(CHR1_test_seq)
    CHR1_add11_seq <- try_seq(CHR1_test_map, 11)
    #> 11 --> M11   : .........................
    CHR1_add11 <- make_seq(CHR1_add11_seq, 25) # marker 11 was placed at the same position as before

Based in those results, we decide to not include marker 11 in our map.

    CHR1_test_map
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 34 SNP5               0.00           a |  | b       a |  | b
    #> 33 SNP3              12.27           a |  | b       a |  | b
    #> 30 M30               15.58           a |  | b       a |  | b
    #> 12 M12               16.59           b |  | a       c |  | a
    #> 32 SNP2              20.15           a |  | b       a |  | b
    #> 31 SNP1              28.31           a |  | b       a |  | b
    #>  3 M3                51.17           o |  | a       o |  | o
    #> 14 M14               64.54           a |  | o       b |  | o
    #>  2 M2                72.44           o |  | o       o |  | a
    #> 36 SNP7              96.32           b |  | a       b |  | a
    #> 35 SNP6             109.13           b |  | a       b |  | a
    #>  1 M1               113.53           b |  | a       b |  | a
    #> 38 SNP9             119.59           b |  | a       b |  | a
    #> 37 SNP8             136.22           b |  | a       b |  | a
    #> 10 M10              149.87           a |  | a       o |  | b
    #> 28 M28              167.09           a |  | o       b |  | o
    #> 26 M26              199.46           a |  | b       d |  | c
    #> 42 SNP13            214.58           b |  | a       b |  | a
    #>  6 M6               220.93           b |  | a       b |  | a
    #> 39 SNP10            227.10           b |  | a       b |  | a
    #> 41 SNP12            243.56           b |  | a       b |  | a
    #> 40 SNP11            260.69           b |  | a       b |  | a
    #> 15 M15              302.93           o |  | a       o |  | b
    #>  5 M5               307.95           o |  | o       o |  | a
    #>
    #> 24 markers            log-likelihood: -1507.316

    rf_graph_table(CHR1_test_map)

    CHR1_final <- CHR1_test_map

Checking for better orders:

    ripple_seq(CHR1_final)
    #> 34-33-30-12-|-32-...
    #>   Alternative orders:
    #>    34 33 12 30 32 ... :    0.00 ( linkage phases: 1 4 4 1 ... )
    #>    34 33 30 12 32 ... :   -0.25 ( linkage phases: 1 1 4 4 ... )
    #>
    #> ...-34-|-33-30-12-32-|-31-...
    #>   Alternative orders:
    #>    34 33 12 30 32 31 ... :    0.00 ( linkage phases:  1 4 4 1 1 ... )
    #>    34 33 30 12 32 31 ... :   -0.25 ( linkage phases:  1 1 4 4 1 ... )
    #>    34 33 32 30 12 31 ... :   -0.59 ( linkage phases:  1 1 1 4 4 ... )
    #>    34 32 33 30 12 31 ... :   -1.88 ( linkage phases:  1 1 1 4 4 ... )
    #>    34 33 30 32 12 31 ... :   -2.14 ( linkage phases:  1 1 1 4 4 ... )
    #>    34 33 32 12 30 31 ... :   -2.74 ( linkage phases:  1 1 4 4 1 ... )
    #>
    #> ...-33-|-30-12-32-31-|-3-...
    #>   Alternative orders:
    #>   ... 33 12 30 32 31 3 ... :    0.00 ( linkage phases: ... 4 4 1 1 3 ... )
    #>   ... 33 30 12 32 31 3 ... :   -0.25 ( linkage phases: ... 1 4 4 1 3 ... )
    #>   ... 33 32 30 12 31 3 ... :   -0.59 ( linkage phases: ... 1 1 4 4 3 ... )
    #>   ... 33 30 32 12 31 3 ... :   -2.14 ( linkage phases: ... 1 1 4 4 3 ... )
    #>   ... 33 32 12 30 31 3 ... :   -2.74 ( linkage phases: ... 1 4 4 1 3 ... )
    #>
    #> ...-30-|-12-32-31-3-|-14-...
    #>   Alternative orders:
    #>   ... 30 12 32 31 3 14 ... :    0.00 ( linkage phases: ... 4 4 1 3 3 ... )
    #>   ... 30 32 12 31 3 14 ... :   -1.89 ( linkage phases: ... 1 4 4 3 3 ... )
    #>
    #> ...-12-|-32-31-3-14-|-2-... OK
    #>
    #> ...-32-|-31-3-14-2-|-36-... OK
    #>
    #> ...-31-|-3-14-2-36-|-35-... OK
    #>
    #> ...-3-|-14-2-36-35-|-1-... OK
    #>
    #> ...-14-|-2-36-35-1-|-38-...
    #>   Alternative orders:
    #>   ... 14 2 36 35 1 38 ... :    0.00 ( linkage phases: ... 2 3 1 1 1 ... )
    #>   ... 14 2 36 1 35 38 ... :   -1.27 ( linkage phases: ... 2 3 1 1 1 ... )
    #>
    #> ...-2-|-36-35-1-38-|-37-...
    #>   Alternative orders:
    #>   ... 2 38 1 35 36 37 ... :    0.00 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 36 35 1 38 37 ... :   -0.99 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 38 35 1 36 37 ... :   -1.15 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 35 1 38 36 37 ... :   -1.16 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 36 38 35 1 37 ... :   -1.18 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 36 38 1 35 37 ... :   -1.45 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 36 35 38 1 37 ... :   -2.21 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 2 36 1 35 38 37 ... :   -2.25 ( linkage phases: ... 3 1 1 1 1 ... )
    #>
    #> ...-36-|-35-1-38-37-|-10-...
    #>   Alternative orders:
    #>   ... 36 37 1 35 38 10 ... :   0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 35 1 38 10 ... :  -0.25 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 35 1 38 37 10 ... :  -1.23 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 38 35 1 10 ... :  -1.35 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 38 35 1 37 10 ... :  -1.42 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 38 1 35 10 ... :  -1.54 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 38 1 35 37 10 ... :  -1.69 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 35 38 1 37 10 ... :  -2.45 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 1 35 38 37 10 ... :  -2.50 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 1 38 35 10 ... :  -2.78 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 36 37 35 38 1 10 ... :  -2.85 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-35-|-1-38-37-10-|-28-...
    #>   Alternative orders:
    #>   ... 35 1 38 37 10 28 ... :    0.00 ( linkage phases: ... 1 1 1 1 4 ... )
    #>   ... 35 38 1 37 10 28 ... :   -1.22 ( linkage phases: ... 1 1 1 1 4 ... )
    #>
    #> ...-1-|-38-37-10-28-|-26-... OK
    #>
    #> ...-38-|-37-10-28-26-|-42-... OK
    #>
    #> ...-37-|-10-28-26-42-|-6-... OK
    #>
    #> ...-10-|-28-26-42-6-|-39-...
    #>   Alternative orders:
    #>   ... 10 28 26 42 6 39 ... :    0.00 ( linkage phases: ... 4 2 3 1 1 ... )
    #>   ... 10 28 26 6 42 39 ... :   -2.30 ( linkage phases: ... 4 2 3 1 1 ... )
    #>
    #> ...-28-|-26-42-6-39-|-41-...
    #>   Alternative orders:
    #>   ... 28 26 42 6 39 41 ... :    0.00 ( linkage phases: ... 2 3 1 1 1 ... )
    #>   ... 28 26 6 42 39 41 ... :   -2.30 ( linkage phases: ... 2 3 1 1 1 ... )
    #>
    #> ...-26-|-42-6-39-41-|-40-...
    #>   Alternative orders:
    #>   ... 26 42 6 39 41 40 ... :    0.00 ( linkage phases: ... 3 1 1 1 1 ... )
    #>   ... 26 6 42 39 41 40 ... :   -2.30 ( linkage phases: ... 3 1 1 1 1 ... )
    #>
    #> ...-42-|-6-39-41-40-|-15-... OK
    #>
    #> ...-6-|-39-41-40-15-|-5-... OK
    #>
    #> 39-|-41-40-15-5
    #>   Alternative orders:
    #>   ... 39 41 40 15 5 :    0.00 ( linkage phases: ... 1 1 1 1 )
    #>   ... 39 41 40 5 15 :   -0.81 ( linkage phases: ... 1 1 1 1 )

## Genetic mapping of linkage group 2 (with reference genome informations)

    CHR2_ord <- order_seq(CHR_mks$sequences$CHR2)
    CHR2_frame <- make_seq(CHR2_ord, "force")

    rf_graph_table(CHR2_frame) # graphic not showed

As did before, we will not change markers positions of this group.

    CHR2_final <- CHR2_frame

## Genetic mapping of linkage group 3 (with reference genome informations)

    CHR3_ord <- order_seq(CHR_mks$sequences$CHR3)
    CHR3_frame <- make_seq(CHR3_ord, "force")

    rf_graph_table(CHR3_frame) # graphic not showed

Here, marker `23`, `27` and `29` have color pattern too different of the expected, removing them could influentiate in other markers ordering. Then we will remove them and search for a new order.

    CHR3_test_seq <- drop_marker(CHR3_frame, c(23,27, 29))
    CHR3_test_ord <- order_seq(CHR3_test_seq)
    CHR3_test_map <- make_seq(CHR3_test_ord, "force")

    rf_graph_table(CHR3_test_map) #graphic not showed

Trying to add markers `23`, `27` and `29` again.

    CHR3_add23_seq <- try_seq(CHR3_test_map, 23)
    CHR3_add23 <- make_seq(CHR3_add23_seq, 5) # Marker 23 removed of the map
    CHR3_add27_seq <- try_seq(CHR3_test_map, 26)
    CHR3_add27 <- make_seq(CHR3_add27_seq, 1) # Marker 27 was better positioned
    CHR3_add29_seq <- try_seq(CHR3_add27, 28)
    CHR3_add29 <- make_seq(CHR3_add29_seq, 1) # Marker 29 increase the map size disproportionately, it was removed from the map

    CHR3_final <- CHR3_add27
    rf_graph_table(CHR3_final, inter = FALSE)

Checking for better orders:

    ripple_seq(CHR3_final)
    #> 26-16-20-4-|-21-... OK
    #>
    #> ...-26-|-16-20-4-21-|-48-... OK
    #>
    #> ...-16-|-20-4-21-48-|-9-... OK
    #>
    #> ...-20-|-4-21-48-9-|-46-... OK
    #>
    #> ...-4-|-21-48-9-46-|-45-...
    #>   Alternative orders:
    #>   ... 4 21 48 9 46 45 ... :    0.00 ( linkage phases: ... 2 2 1 1 1 ... )
    #>   ... 4 21 48 46 9 45 ... :   -0.58 ( linkage phases: ... 2 2 1 1 1 ... )
    #>
    #> ...-21-|-48-9-46-45-|-47-...
    #>   Alternative orders:
    #>   ... 21 48 9 46 45 47 ... :   0.00 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 21 48 46 9 45 47 ... :  -0.58 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 21 48 45 9 46 47 ... :  -0.80 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 21 48 9 45 46 47 ... :  -0.81 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 21 45 48 9 46 47 ... :  -2.52 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 21 45 46 9 48 47 ... :  -2.52 ( linkage phases: ... 2 1 1 1 1 ... )
    #>   ... 21 48 45 46 9 47 ... :  -2.97 ( linkage phases: ... 2 1 1 1 1 ... )
    #>
    #> ...-48-|-9-46-45-47-|-50-...
    #>   Alternative orders:
    #>   ... 48 9 46 45 47 50 ... :    0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 9 46 47 45 50 ... :   -0.44 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 46 9 45 47 50 ... :   -0.58 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 45 9 46 47 50 ... :   -0.80 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 9 45 46 47 50 ... :   -0.81 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 47 46 9 45 50 ... :   -1.30 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 9 45 47 46 50 ... :   -2.66 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 47 45 9 46 50 ... :   -2.73 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 48 45 46 9 47 50 ... :   -2.97 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-9-|-46-45-47-50-|-24-...
    #>   Alternative orders:
    #>   ... 9 46 45 47 50 24 ... :    0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 9 46 47 45 50 24 ... :   -0.44 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 9 45 46 47 50 24 ... :   -0.81 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 9 45 47 46 50 24 ... :   -2.66 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-46-|-45-47-50-24-|-49-...
    #>   Alternative orders:
    #>   ... 46 45 47 50 24 49 ... :    0.00 ( linkage phases: ... 1 1 1 1 1 ... )
    #>   ... 46 47 45 50 24 49 ... :   -0.44 ( linkage phases: ... 1 1 1 1 1 ... )
    #>
    #> ...-45-|-47-50-24-49-|-52-... OK
    #>
    #> ...-47-|-50-24-49-52-|-51-...
    #>   Alternative orders:
    #>   ... 47 50 24 49 52 51 :    0.00 ( linkage phases: ... 1 1 1 1 1 )
    #>   ... 47 52 49 24 50 51 :   -0.40 ( linkage phases: ... 1 1 1 1 1 )
    #>   ... 47 50 24 52 49 51 :   -2.76 ( linkage phases: ... 1 1 1 1 1 )
    #>   ... 47 49 52 24 50 51 :   -2.80 ( linkage phases: ... 1 1 1 1 1 )
    #>
    #> 50-|-24-49-52-51
    #>   Alternative orders:
    #>   ... 50 24 49 52 51 :    0.00 ( linkage phases: ... 1 1 1 1 )
    #>   ... 50 24 52 49 51 :   -2.76 ( linkage phases: ... 1 1 1 1 )

# Drawing the genetic maps

Once all linkage groups were obtained using both strategies, we can draw a simple map for each strategy using the function `draw_map`.

Drawing map builded with only recombinations informations

    map1 <- list(LG1_final, LG2_final, LG3_final)
    draw_map(map1, names = TRUE, grid = TRUE, cex.mrk = 0.7)

Drawing map builded with reference genome and recombinations informations

    map2 <- list(CHR1_final, CHR2_final, CHR3_final)
    draw_map(map2, names = TRUE, grid = TRUE, cex.mrk = 0.7)

We also can draw a maps comparing corresponding linkage groups in each strategy:

    CHR1_comp <- list(LG1_final, CHR1_final)
    draw_map(CHR1_comp, names = TRUE, grid = TRUE, cex.mrk = 0.7)

Markers `M1` and `SNP2` are in different position between the strategies results for CHR1.

    CHR2_comp <- list(LG3_final, CHR2_final)
    draw_map(CHR2_comp, names = TRUE, grid = TRUE, cex.mrk = 0.7)

Both strategies produced the same result for CHR2 (the map are only inverted).

    CHR3_comp <- list(LG2_final, CHR3_final)
    draw_map(CHR3_comp, names = TRUE, grid = TRUE, cex.mrk = 0.7)

There are a invertion between markers `SNP17` and `SNP18` and the marker `M29` was removed in te second strategy.

Or groups alone:

    draw_map(CHR1_final, names = TRUE, grid = TRUE, cex.mrk = 0.7)

It is obvious that function `draw_map` draws a very simple graphic representation of the genetic map. But once the distances and the linkage phases are estimated, better map figures can be drawn by the user with any appropriate software. There are several free software that can be used, such as `MapChart` (Voorrips, 2002).

# Map estimation for an arbitrary order

If, for any reason, one wants to estimate parameters for a given linkage map (e.g., for other orders on published papers), it is possible to define a sequence and use the `map` function. For example, for markers `M30`, `M12`, `M3`, `M14` and `M2`, in this order, use

    any_seq <- make_seq(twopts, c(30, 12, 3, 14, 2))
    (any_seq_map <- map(any_seq))
    #>
    #> Printing map:
    #>
    #> Markers           Position           Parent 1       Parent 2
    #>
    #> 30 M30                0.00           a |  | b       a |  | b
    #> 12 M12                1.00           b |  | a       c |  | a
    #>  3 M3                20.57           o |  | a       o |  | o
    #> 14 M14               33.63           a |  | o       b |  | o
    #>  2 M2                41.70           o |  | o       o |  | a
    #>
    #> 5 markers            log-likelihood: -320.9012

This is a subset of the first linkage group. When used this way, the `map` function searches for the best combination of phases between markers and prints the results.

Furthermore, a sequence can also have user-defined linkage phases. The next example shows (incorrect) phases used for the same order of markers:

    any_seq <- make_seq(twopts, c(30, 12, 3, 14, 2), phase = c(4, 1, 4, 3))
    (any_seq_map <- map(any_seq))

If one needs to add or drop markers from a predefined sequence, functions `add_marker` and `drop_marker` can be used. For example, to add markers 4 to 8 to `any_seq`.

    (any_seq <- add_marker(any_seq, 4:8))
    #>
    #> Number of markers: 10
    #> Markers in the sequence:
    #> M30 M12 M3 M14 M2 M4 M5 M6 M7 M8
    #>
    #> Parameters not estimated.

Removing markers 3, 4, 5, 12 and 30 from `any_seq`:

    (any_seq <- drop_marker(any_seq, c(3, 4, 5, 12, 30)))
    #>
    #> Number of markers: 5
    #> Markers in the sequence:
    #> M14 M2 M6 M7 M8
    #>
    #> Parameters not estimated.

After that, the map needs to be re-estimated.

# Session Info

    sessionInfo()
    #> R version 3.4.0 (2017-04-21)
    #> Platform: x86_64-pc-linux-gnu (64-bit)
    #> Running under: Ubuntu 16.04 LTS
    #>
    #> Matrix products: default
    #> BLAS: /usr/lib/libblas/libblas.so.3.6.0
    #> LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
    #>
    #> locale:
    #>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    #>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
    #>  [5] LC_MONETARY=pt_BR.UTF-8    LC_MESSAGES=en_US.UTF-8
    #>  [7] LC_PAPER=pt_BR.UTF-8       LC_NAME=C
    #>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    #> [11] LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] onemap_2.1.1  rmarkdown_1.6 knitr_1.17
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] Rcpp_0.12.13     magrittr_1.5     maps_3.1.1       munsell_0.4.3
    #>  [5] colorspace_1.3-2 rlang_0.1.1      stringr_1.2.0    plyr_1.8.4
    #>  [9] tcltk_3.4.0      fields_9.0       tools_3.4.0      grid_3.4.0
    #> [13] tkrplot_0.0-23   spam_1.4-0       gtable_0.2.0     htmltools_0.3.6
    #> [17] yaml_2.1.14      lazyeval_0.2.0   rprojroot_1.2    digest_0.6.12
    #> [21] tibble_1.3.3     reshape2_1.4.2   ggplot2_2.2.1    codetools_0.2-15
    #> [25] evaluate_0.10.1  labeling_0.3     stringi_1.1.5    compiler_3.4.0
    #> [29] scales_0.4.1     backports_1.1.0

# References

Buetow, K. H., Chakravarti, A. Multipoint gene mapping using seriation. I. General methods. American Journal of Human Genetics 41, 180-188, 1987.

Doerge, R.W. Constructing genetic maps by rapid chain delineation. Journal of Agricultural Genomics 2, 1996.

Mollinari, M., Margarido, G. R. A., Vencovsky, R. and Garcia, A. A. F. Evaluation of algorithms used to order markers on genetics maps. Heredity 103, 494-502, 2009.

Tan, Y., Fu, Y. A novel method for estimating linkage maps. Genetics 173, 2383-2390, 2006.

Van Os H, Stam P, Visser R.G.F., Van Eck H.J. RECORD: a novel method for ordering loci on a genetic linkage map. Theor Appl Genet 112, 30-40, 2005.

Voorrips, R.E. MapChart: software for the graphical presentation of linkage maps and QTLs. Journal of Heredity 93, 77-78, 2002.

Wu, R., Ma, C.X., Painter, I. and Zeng, Z.-B. Simultaneous maximum likelihood estimation of linkage and linkage phases in outcrossing species. Theoretical Population Biology 61, 349-363, 2002a.

Wu, R., Ma, C.-X., Wu, S. S. and Zeng, Z.-B. Linkage mapping of sex-specific differences. Genetical Research 79, 85-96, 2002b.