identify_column: Identify non-standard column names

View source: R/identify_column.R

identify_columnR Documentation

Identify non-standard column names

Description

This function is a subroutine of translate_header and several other functions. It is used to translate non-standard column names into standard ones.

Usage

identify_column(std_name, alt_names, header)

Arguments

std_name

character string; the standard name for the data-column.

alt_names

translation table; with in the left column the standard name(s) and in the right column possible alternatives. See translate_header for more details.

header

the column names of the dataset. The names should be entirely in uppercase.

Details

The purpose of identify_column is essentially to look up in the translation table (alt_names) which of the names in header can be translated into std_name.

Value

An integer vector of the entry(s) in header (i.e. the column-numbers) that can be translated into std_name.

See Also

translate_header

Examples

  sample_data <-
    data.frame(SNP = paste("rs", 1:10, sep = ""),
               chrom = 2,
               effect = 1:10/10,
               misc = NA)
  sample_header <- toupper(names(sample_data))


  alt_headers <-
    data.frame(
      standard = c("MARKER", "MARKER", "CHR", "CHR"),
      alternative = c("MARKER", "SNP", "CHR", "CHROM"),
      stringsAsFactors = FALSE)
  
  identify_column(std_name = "EFFECT", alt_names = alt_headers,
                  header = sample_header)
  identify_column(std_name = "MARKER", alt_names = alt_headers,
                  header = sample_header)
  identify_column(std_name = "CHR", alt_names = alt_headers,
                  header = sample_header)
  identify_column(std_name = "MISC", alt_names = alt_headers,
                  header = sample_header)

QCGWAS documentation built on May 30, 2022, 5:05 p.m.