identify_column: Identify non-standard column names

Description Usage Arguments Details Value See Also Examples

View source: R/identify_column.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  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 2, 2019, 3:19 p.m.