R package:blupADC-功能4

目录

简介

🦄大家好,这一节主要给大家讲述的是如何使用blupADC中的函数来进行系谱数据处理。blupADC提供的trace_pedigree函数,可以帮助我们非常方便的对系谱数据进行多种处理:包括系谱重命名、系谱追溯及系谱纠错等。

示例

💖同样的,我们还是用一个小例子来简单的看下该函数的用法

library(blupADC)
pedigree_result=trace_pedigree(
                input_pedigree=origin_pedigree,   #provided pedigree data object
                output_pedigree_tree=TRUE  # output pedigree tree
                )                 

我们可以通过str查看函数的输出结果,如下所示:

str(pedigree_result)
## List of 5
##  $ ped          : chr [1:15945, 1:3] "DD19348310" "DD19386807" "DD19119705" "DD16007415" ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : NULL
##   .. ..$ : chr [1:3] "Offspring" "Sire" "Dam"
##  $ rename_ped   :'data.frame':	15945 obs. of  6 variables:
##   ..$ Offspring   : chr [1:15945] "DD19348310" "DD19386807" "DD19119705" "DD16007415" ...
##   ..$ Generation  : num [1:15945] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ Offspring_Id: int [1:15945] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ Sire_Id     : num [1:15945] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ Dam_Id      : num [1:15945] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ Order       : int [1:15945] 1 2 3 4 5 6 7 8 9 10 ...
##  $ pedigree_tree: chr [1:15945, 1:15] "DD19348310" "DD19386807" "DD19119705" "DD16007415" ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : NULL
##   .. ..$ : chr [1:15] "Offspring" "Sire" "Dam" "SireSire" ...
##  $ error_id_set :List of 4
##   ..$ error_duplicated_id: chr [1:24] "DD19119705" "DD20488904" "DD20153801" "DD20376912" ...
##   ..$ error_sex_id: chr "DD13006182"
##   ..$ error_breed_id: NULL
##   ..$ error_birth_date_id: NULL

可以很明显的看到,输出结果包括以下几个部分:

  • ped: 经过处理后(纠错、追溯等)的原始系谱数据且未进行重命名
  • rename_ped: 经过处理(纠错、追溯等)且重命名的系谱数据。第1列为原始系谱ID,第2列为个体在系谱中的代数,第3-5列为重命名后的系谱数据
  • pedigree_tree:个体的系谱树矩阵。可以通过设置 pedigree_tree_depth指定系谱树包含的代数,默认不输出系谱树(节省时间)
  • error_id_set: 系谱记录错误个体数据集。根据错误的种类可以分为以下4个子集
    • error_duplicated_id: 相同的个体,父母却不相同
    • error_sex_id: 个体同时出现在父亲列和母亲列
    • error_breed_id: 个体和父母的品种不相同(仅针对特殊格式)
    • error_birth_date_id: 个体的出生日期要早于父母的出生日期(需在系谱的第四列提供个体的出生日期)

下面,我们将具体讲解trace_pedigree函数中各种参数的含义:

参数详解

💥基础参数

  • 参数1:input_pedigree

用户提供的系谱数据,data.framematrix类型。

💌用户提供系谱数据需为以下几种格式中的一种,包括:

  • 3列系谱格式:
OffspringSireDam
DD19575312DD18768902DD16376015
DD19513112DD18768902DD17111017
DD20348012DD19132207DD19234510
DD20361110DD19331001DD19293112
DD20471212DD19331001DD19320808
DD20564818DD19331001DD19311009
  • 4列系谱格式:
OffspringSireDamBirth_Date
DD19575312DD18768902DD1637601520200101
DD19513112DD18768902DD1711101720200102
DD20348012DD19132207DD1923451020200103
DD20361110DD19331001DD1929311220200104
DD20471212DD19331001DD1932080820200105
DD20564818DD19331001DD1931100920200106
  • 多列系谱格式:
OffspringSireDamSireSireDamSireSireSireSire
DD20231905DD19581002DD18750810DD16785512DD15507717DD14008512
DD20458701DD19564302DD18925809DD15349017DD15245411DD16771212
DD20324707DD19232903DD18571012DD16794714DD16744412DD16714516
DD19288609DD18713408DD18552609DD15180015DD15479214DD15243711
DD16222012DD15145005DD15378812DD14110014DD15501518DD15206217
DD17684713DD16672107DD15122311DD15505715DD15347415DD16383111

Note:需要注意的是,当系谱为多列时,用户必须要设置 multi_col=TRUE, 并且系谱的列名需要标注为特殊形式,e.g. SireSire:父亲的父亲, SirSireSire:父亲的父亲的父亲.

系谱数据中缺失值可以设置为: NA或0

同样的,为了便于用户操作,用户还可以直接提供本地系谱数据的路径和名称

  • 参数2:input_pedigree_path

本地系谱数据的路径,character类型。

  • 参数3:input_pedigree_name

本地系谱数据的名称,character类型。

  • 参数4:multi_col

是否将提供的多列系谱转换到3列,logical类型。如果用户提供的系谱数据包含多列,那么用户必须设置multi_col

  • 参数5:trace_id

在追溯系谱时,所追溯的个体集, character 类型. 默认为 NULL , 即追溯系谱中的所有个体

  • 参数6:trace_generation

在追溯系谱时,所追溯的最大代数, numeric 类型。默认为 NULL , 即追溯系谱中的全部代数。

  • 参数7:trace_birth_date

追溯出生日期不早于指定日期的个体,numeric类型。个体出生日期早于用户提供的出生日期将会被排除在系谱追溯过程中。

  • 参数8:output_pedigree_path

系谱输出到本地的路径,character类型。

  • 参数9:output_pedigree_name

系谱输出到本地的名称,character类型。

💨进阶参数

  • 参数10:dup_error_check

检查相同个体的父母却不相同的错误,logical类型,默认为TRUE。

  • 参数11:sex_error_check

检查个体同时出现在父亲列和母亲列的错误,logical类型,默认为TRUE。

  • 参数12:birth_date_error_check

检查个体出生日期早于父母的错误,logical类型,默认为FALSE。

  • 参数13:output_pedigree_tree

是否输出系谱树,logical类型,默认为FALSE。

  • 参数14:pedigree_tree_depth

系谱树的深度(系谱代数),numeric类型,默认为3。

梅全顺
梅全顺
博士后

My research interests include genomic selection and machine learning in animal breeding.