View source: R/script_v12-3_package.R
translate_header | R Documentation |
This function is used to translate non-standard column names
into the standard ones used by EWAS_QC
and other
functions.
translate_header(header, standard = c("PROBEID","BETA","SE","P_VAL"), alternative)
header |
character vector; the header to be translated. |
standard |
character vector; the names |
alternative |
translation table; see below for more information. |
The function takes the entries in standard
one by one, and
checks them against the translation table for alternatives.
It will report any missing standard headers, as well as
duplicate ones.
translate_header
returns an object of class 'list' with 6 components:
header_h |
character vector; the translated header. Unknown columns are included under their old names. |
missing_h |
character vector; the standard column names
that were not found. If none, this returns |
unknown_h |
character vector; column names that could not
be converted to a standard name. Note that these columns
are also included in |
header_N, missing_N, unknown_N |
integer; the lengths of the above three vectors |
The translation table must meet the following requirements:
2 columns, with the default column names (i.e. the ones in the standard argument) in the first column, and the alternatives in the second.
Multiple alternatives are allowed for a single standard name, but every alternative name must be in a separate row.
The alternatives must be capitalized.
No duplicate alternatives are allowed.
A header line is not required, and will be ignored if present.
The function will automatically capitalize the elements of
the header
argument (so the alternatives in the translation
table must also be capitalized). Also, elements that are not
in standard
will not be translated, even if they are present
in the translation table.
# For use in this example, the 2 sample files in the # extdata folder of the QCEWAS library will be copied # to your current R working directory ## Not run: file.copy(from = file.path(system.file("extdata", package = "QCEWAS"), "sample2.txt.gz"), to = getwd(), overwrite = FALSE, recursive = FALSE) file.copy(from = file.path(system.file("extdata", package = "QCEWAS"), "translation_table.txt"), to = getwd(), overwrite = FALSE, recursive = FALSE) sample_ewas <- read.table("sample2.txt.gz", header = TRUE, stringsAsFactors = FALSE, nrow = 10) colnames(sample_ewas) translation_table <- read.table("translation_table.txt", header = TRUE, stringsAsFactors = FALSE) sample_translation <- translate_header(header = colnames(sample_ewas), alternative = translation_table) sample_translation colnames(sample_ewas) <- sample_translation$header_h colnames(sample_ewas) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.