R package gpyramid has been designed for gene
pyrammiding in plant breeding.
The gene pyramidding was formulated by Servin et al. (2004) <DOI: 10.1534/genetics.103.023358>.
This document describes how to conduct the same calculation as Servin et al. (2004) in the R environment.
library(gpyramid)
library(ape)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following object is masked from 'package:ape':
#>
#> where
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, uniongene_dat <- util_haplo(line_df, target = "A", non_target = "B", hetero = "H", line_cul = "line")
gene_df1 <- gene_dat[[1]]
gene_df2 <- gene_dat[[2]]
line_id <- gene_dat[[3]]
colnames(gene_df1) <- line_id
colnames(gene_df2) <- line_id
gene_df1
#> x1 x2 x3 x4
#> [1,] 1 0 0 0
#> [2,] 0 1 0 0
#> [3,] 0 0 1 0
#> [4,] 0 0 0 1
gene_df2
#> x1 x2 x3 x4
#> [1,] 1 0 0 0
#> [2,] 0 1 0 0
#> [3,] 0 0 1 0
#> [4,] 0 0 0 1Fron candidate lines, findPset function returns the
parent sets for gene pyramidding.
In this example, only one parent set was returned.
calcCostAll function calculates the number of necessary
individuals and generations as the crossing cost for all the crossing
schemes.
Given parent sets for gene pyramidding, calCostAll
function simulates all the crossing schemes and calculates the number of
necessary individuals and generations as the cost of gene
pyramidding.
calcCostAll function returns the
gpyramid_all object, which contains information of all the
crossing schemes.
Here, getFromAll function get one crossing scheme from
gpyramid_all object.
rslt <- calcCostAll(line_comb_lis, gene_df1, gene_df2, recom_mat,
prob_total = 0.99, last_cross = T, last_selfing = T)
rslt$cost_all
#> # A tibble: 15 × 6
#> cross_id n_generation N_total n_parent line_comb_id TR_id
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 3 887 4 1 1
#> 2 2 2 2908 4 1 2
#> 3 3 3 714 4 1 3
#> 4 4 3 733 4 1 4
#> 5 5 3 650 4 1 5
#> 6 6 2 961 4 1 6
#> 7 7 3 650 4 1 7
#> 8 8 3 325 4 1 8
#> 9 9 3 325 4 1 9
#> 10 10 3 325 4 1 10
#> 11 11 3 887 4 1 11
#> 12 12 3 733 4 1 12
#> 13 13 2 1001 4 1 13
#> 14 14 3 714 4 1 14
#> 15 15 3 325 4 1 15Fig 4a in Servin et al. (2004) corresponds to
cross_id = 15 in the above gpyramid_all
object.
rslt_one <- getFromAll(rslt, cross_id = 15)
summary(rslt_one)
#> Number of necessary plants for each crossing
#>
#> nodeid n_plant
#> 1 node_6 1
#> 2 node_7 70
#> 3 node_5 84
#> 4 last cross 102
#> 5 last selfing 68
#>
#> Target haplotype of crossing
#>
#> nodeid=5
#> hap1 hap2
#> 1 0 1
#> 2 0 1
#> 3 0 1
#> 4 1 0
#>
#> nodeid=6
#> hap1 hap2
#> 1 1 0
#> 2 0 1
#> 3 0 0
#> 4 0 0
#>
#> nodeid=7
#> hap1 hap2
#> 1 0 1
#> 2 0 1
#> 3 1 0
#> 4 0 0
plot(rslt_one$topolo)
nodelabels()Fig 4b in Servin et al. (2004) corresponds to
cross_id = 6 in the above gpyramid_all
object.
rslt_one <- getFromAll(rslt, cross_id = 6)
summary(rslt_one)
#> Number of necessary plants for each crossing
#>
#> nodeid n_plant
#> 1 node_7 1
#> 2 node_6 1
#> 3 node_5 394
#> 4 last cross 500
#> 5 last selfing 65
#>
#> Target haplotype of crossing
#>
#> nodeid=5
#> hap1 hap2
#> 1 0 1
#> 2 1 0
#> 3 1 0
#> 4 0 1
#>
#> nodeid=6
#> hap1 hap2
#> 1 0 0
#> 2 1 0
#> 3 0 1
#> 4 0 0
#>
#> nodeid=7
#> hap1 hap2
#> 1 1 0
#> 2 0 0
#> 3 0 0
#> 4 0 1
plot(rslt_one$topolo)
nodelabels()Fig 4c in Servin et al. (2004) corresponds to
cross_id = 13 in the above gpyramid_all
object.
rslt_one <- getFromAll(rslt, cross_id = 13)
summary(rslt_one)
#> Number of necessary plants for each crossing
#>
#> nodeid n_plant
#> 1 node_7 1
#> 2 node_6 1
#> 3 node_5 837
#> 4 last cross 97
#> 5 last selfing 65
#>
#> Target haplotype of crossing
#>
#> nodeid=5
#> hap1 hap2
#> 1 1 0
#> 2 1 0
#> 3 0 1
#> 4 0 1
#>
#> nodeid=6
#> hap1 hap2
#> 1 1 0
#> 2 0 1
#> 3 0 0
#> 4 0 0
#>
#> nodeid=7
#> hap1 hap2
#> 1 0 0
#> 2 0 0
#> 3 1 0
#> 4 0 1
plot(rslt_one$topolo)
nodelabels()