Learn R Programming

tidypopgen (version 0.4.3)

indiv_het_obs: Estimate individual observed heterozygosity

Description

Estimate observed heterozygosity (H_obs) for each individual (i.e. the frequency of loci that are heterozygous in an individual).

Usage

indiv_het_obs(.x, as_counts = FALSE, ...)

# S3 method for tbl_df indiv_het_obs(.x, as_counts = FALSE, ...)

# S3 method for vctrs_bigSNP indiv_het_obs(.x, as_counts = FALSE, ...)

Value

either:

  • a vector of heterozygosities, one per individuals in the gen_tibble

  • a matrix with two columns, where the first is the number of heterozygous loci for each individual and the second is the number of missing values for each individual

Arguments

.x

a vector of class vctrs_bigSNP (usually the genotype column of a gen_tibble object), or a gen_tibble.

as_counts

logical, if TRUE, return a matrix with two columns: the number of heterozygotes and the number of missing values for each individual. These quantities can be useful to compute more complex quantities.

...

currently unused.

Examples

Run this code
example_gt <- load_example_gt("gen_tbl")

example_gt %>% indiv_het_obs()

# For observed heterozygosity as counts:
example_gt %>% indiv_het_obs(as_counts = TRUE)

Run the code above in your browser using DataLab