match.kinship2pheno: Check any kinship matrix K against phenotypic data

View source: R/match_kinship2pheno.R

match.kinship2phenoR Documentation

Check any kinship matrix K against phenotypic data

Description

Assesses a given kinship matrix against the provided phenotypic data to determine if all genotypes are in the kinship matrix or not. It also reports which individuals match or are missing from one set or another. If requested, a reduced kinship matrix is generated that has only the matched individuals. The input kinship matrix can be a pedigree-based relationship matrix \boldsymbol{A}, a genomic-based relationship matrix \boldsymbol{G}, or a hybrid relationship matrix \boldsymbol{H}. Individual names should be assigned to rownames and colnames of input matrix.

Usage

match.kinship2pheno(
  K = NULL,
  pheno.data = NULL,
  indiv = NULL,
  clean = FALSE,
  ord = TRUE,
  mism = FALSE,
  message = TRUE
)

Arguments

K

Input of a kinship matrix in full form (n \times n) (default = NULL);

pheno.data

A data fame with the phenotypic data to assess (for n individuals) (default = NULL).

indiv

The string for the column name for genotypes/individuals in the phenotypic data (default = NULL).

clean

If TRUE, generates a new clean kinship matrix containing only the matched phenotyped individuals (default = FALSE).

ord

If TRUE, it will order the kinship matrix as in the phenotypic data, which is recommended for some downstream genomic analyses (default = TRUE).

mism

If TRUE, it generates data frames with matched and mismatched individual's names from the kinship matrix and the phenotypic data (default = FALSE).

message

If TRUE diagnostic messages are printed on screen (default = TRUE).

Value

A list with the following elements:

  • mismatchesK: a vector containing the names of the individuals from the provided kinship matrix that mismatch with the phenotypic data.

  • matchesK: a vector containing the names of the individuals from the provided kinship matrix that match with the phenotypic data.

  • mismatchesP: a vector containing the names of phenotyped individuals that mismatch with those from the kinship matrix.

  • matchesP: a vector containing the names of phenotyped individuals that match with those from the kinship matrix.

  • Kclean: a clean kinship matrix containing only the matched phenotyped individuals.

Examples

## Not run: 
# Get G matrix.
G <- G.matrix(M = geno.pine655, method = "VanRaden", na.string = "-9", sparseform = FALSE)$G
dim(G)

# Match G and the phenotype.
check <-
 match.kinship2pheno(
  K = G, pheno.data = pheno.pine,
  indiv = "Genotype",
  clean = TRUE, mism = TRUE)
ls(check)
length(check$matchesK)
length(check$mismatchesK)
length(check$matchesP)
length(check$mismatchesP)
dim(check$Kclean)

## End(Not run)

ASRgenomics documentation built on May 29, 2024, 12:03 p.m.