countsToVariables: Convert counts table to variables

View source: R/transformationFunctions.R

countsToVariablesR Documentation

Convert counts table to variables

Description

countsToVariables converts counts table to additional variables.

Usage

countsToVariables(counts, dictionary, na.value = NA, nacols.rm = TRUE)

Arguments

counts

Data frame with counts, such as returned by hlaCallsToCounts function. First column should contain samples IDs, following columns should contain counts (natural numbers including zero).

dictionary

Path to file containing variables dictionary or data frame. See details for further explanations.

na.value

Vector of length one speciyfing value for variables with no matching entry in dictionary. Default is to use 0.

nacols.rm

Logical indicating if result columns that contain only NA should be removed.

Details

dictionary file should be a tsv format with header and two columns. First column should be named "Name" and hold variable name, second should be named "Expression" and hold expression used to identify variable (eg. "KIR2DL3 & ! KIR2DL2" will match all samples with KIR2DL3 and without KIR2DL2). Optionally a data frame formatted in the same manner can be passed instead.

Dictionaries shipped with the package:

kir_haplotypes

KIR genes to KIR haplotypes dictionary.

Value

Data frame with variable number of columns. First column named "ID" corresponds to "ID" column in counts, further columns hold indicators for converted variables. 1 and 0 code presence and absence of a variable respectively.

Examples

countsToVariables(MiDAS_tut_KIR, "kir_haplotypes")


Genentech/MiDAS documentation built on Feb. 5, 2024, 11:52 a.m.