select_snps: Select SNPs

View source: R/select_snps.R

select_snpsR Documentation

Select SNPs

Description

Select SNPs

Usage

select_snps(
  data,
  snp_selector,
  base_output_filename = plinkr::get_plinkr_tempfilename(),
  plink_options = plinkr::create_plink_options(),
  verbose = FALSE
)

Arguments

data

the data source, which can be:

  • PLINK text data, as created by create_plink_text_data.

  • PLINK binary data, as created by create_plink_bin_data.

  • PLINK2 binary data, as created by create_plink2_bin_data.

  • PLINK text filenames, as created by create_plink_text_filenames.

  • PLINK binary filenames, as created by create_plink_bin_filenames.

  • PLINK2 binary filenames, as created by create_plink2_bin_filenames.

  • data to be used by assoc, as created by create_assoc_data

  • data to be used by assoc_qt, as created by create_assoc_qt_data

snp_selector

a SNP selector, a way to select one or more SNPs. See create_snps_selector for all SNP selectors.

base_output_filename

the base of the filenames that are used as output for PLINK/PLINK2

plink_options

options to run PLINK, as created by create_plink_options

verbose

the verbosity of a function. Set to TRUE for more output. Use check_verbose to detect if this argument is valid.

Value

a plink_bin_data (see check_plink_bin_data)

Author(s)

Richèl J.C. Bilderbeek

See Also

To select samples/individuals, use select_samples

There are multiple SNP selector checking functions, see create_snps_selector for an overview

Examples

if (is_plink_installed()) {
  # Use PLINK files
  plink_bin_filenames <- create_plink_bin_filenames(
    bed_filename = get_plinkr_filename("select_snps.bed"),
    bim_filename = get_plinkr_filename("select_snps.bim"),
    fam_filename = get_plinkr_filename("select_snps.fam")
  )

  # Select a single SNP
  single_snp_selector <- create_single_snp_selector(
    snp = "snp_4"
  )
  plink_bin_data <- select_snps(
    data = plink_bin_filenames,
    snp_selector = single_snp_selector
  )

  # Select 2 random SNPs
  random_snps_selector <- create_random_snps_selector(
    n_snps = 3
  )
  plink_bin_data <- select_snps(
    data = plink_bin_filenames,
    snp_selector = random_snps_selector
  )

  # Select a SNP range
  snp_range_selector <- create_snp_range_selector(
    snp_from = "snp_2",
    snp_to = "snp_7"
  )
  plink_bin_data <- select_snps(
    data = plink_bin_filenames,
    snp_selector = snp_range_selector
  )

  # Seleect a window around a SNP: 3 SNPs, with 'snp_5' in the middle
  snp_window_selector <- create_snp_window_selector(
    snp = "snp_5",
    window_kb = 0.003
  )
  plink_bin_data <- select_snps(
    data = plink_bin_filenames,
    snp_selector = snp_window_selector
  )
}

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