select_samples: Select samples/individuals

View source: R/select_samples.R

select_samplesR Documentation

Select samples/individuals

Description

Select samples/individuals from data

Usage

select_samples(
  data,
  sample_selector,
  sample_ids_filename = plinkr::get_plinkr_tempfilename(pattern = "sample_ids_",
    fileext = ".txt"),
  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

sample_selector

a sample/individual selector, a way to select one or more samples/individuals. See create_samples_selector for all sample selectors.

sample_ids_filename

name of a file to store sample_ids (see check_sample_ids) to

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

  • If data is a plink_bin_data (see check_plink_bin_data), a plink_bin_data

  • If data is a assoc_qt_data (see check_assoc_qt_data), a assoc_qt_data

Author(s)

Richèl J.C. Bilderbeek

See Also

To select SNPs, use select_snps

There are multiple sample selector checking functions, see create_samples_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 sample
  single_sample_selector <- create_single_sample_selector(
    fid = "C",
    iid = "1"
  )
  plink_bin_data <- select_samples(
    data = plink_bin_filenames,
    sample_selector = single_sample_selector
  )

  # Select 2 random samples
  random_samples_selector <- create_random_samples_selector(
    n_samples = 2
  )
  plink_bin_data <- select_samples(
    data = plink_bin_filenames,
    sample_selector = random_samples_selector
  )
}

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