create_custom_trait: Create a custom trait in which the phenotype is determined in...

View source: R/create_custom_trait.R

create_custom_traitR Documentation

Create a custom trait in which the phenotype is determined in a custom way and the minor allele frequency is known.

Description

Create a custom trait in which the phenotype is determined in a custom way and the minor allele frequency is known.

Usage

create_custom_trait(
  phenotype = "custom",
  mafs = 0.25,
  n_snps = 1,
  calc_phenotype_function = calc_random_phenotype_values
)

Arguments

phenotype

one phenotype, named after its genetic background:

  • random the phenotype is a random value, i.e. there is no association between the genetics and this phenotype

  • additive the phenotype is perfectly additive (the nucleotides used are A and T as these are in the word 'additive'):

    • AA 11.0

    • AT 10.5

    • TT 10.0

mafs

one or more minor allele frequencies. These allele frequencies must be ordered decreasingly, i.e. the MAF is at the first position, where the even rarer alleles are at the second and third positions.

Note that PLINK cannot handle triallelic nor quadallelic SNPs: PLINK will give a warning that it is setting the rarest alleles to missing.

n_snps

the number of SNPs, as can be checked by check_n_snps

calc_phenotype_function

a function that calculate the phenotypes from genotypes. The input is the genetic data as a tibble, in which each row is an individual and the columns are the SNVs. The first two columns are named snv_1a, snv_1b and hold the genetic data for the first SNV of a diploid organism. If there are more SNVs, columns continue with names, snv_2a, snv_2b, snv_3a, snv_3b, etc. Nucleotides are in uppercase. The output must be the phenotypic values, as a numeric vector, which has the same length as the number of individuals. Use check_calc_phenotype_function to check a calc_phenotype_function.

Author(s)

Richèl J.C. Bilderbeek

Examples

# Create a custom trait that calculates the phenotypes randomly,
# regardless of the genotype.
# This is the same as using 'create_random_trait'
create_custom_trait(
  phenotype = "random",
  calc_phenotype_function = calc_random_phenotype_values
)

# Create a custom trait that calculates the phenotypes additively
# This is the same as using 'create_additive_trait'
create_custom_trait(
  phenotype = "additive",
  calc_phenotype_function = calc_additive_phenotype_values
)

# Create a custom trait that calculates the phenotypes from
# an epistatic interaction
# This is the same as using 'create_epistate_trait'
create_custom_trait(
  phenotype = "epistatic",
  calc_phenotype_function = calc_epistatic_phenotype_values,
  n_snps = 2
)

# A trivial trait, that shows the genotypes worked on
create_custom_trait(
  phenotype = "debug",
  calc_phenotype_function = function(snvs) {

    # Show the input
    message(paste0(knitr::kable(snvs), collapse = "\n"))

    # Return as much 1s as individuals
    rep(1, nrow(snvs))
  }
)


richelbilderbeek/plinkr documentation built on March 25, 2024, 3:18 p.m.