Regex Fold¶
The "regexFold"
transform gathers columns into key-value pairs using a regular
expression.
Parameters¶
asKey
-
Type: string
Default:
"sample"
asValue
Required-
Type: string[] | string
A new column name for the extracted values.
columnRegex
Required-
Type: string[] | string
A regular expression that matches to column names. The regex must have one capturing group that is used for extracting the key (e.g., a sample id) from the column name.
skipRegex
-
Type: string
An optional regex that matches to fields that should not be included in the new folded data objects.
Example¶
Given the following data:
SNP | foo.AF | bar.AF | baz.AF |
---|---|---|---|
rs99924582 | 0.3 | 0.24 | 0.94 |
rs22238423 | 0.92 | 0.21 | 0.42 |
... and configuration:
{
"type": "regexFold",
"columnRegex": ["^(.*)\\.AF$"],
"asValue": ["VAF"],
"asKey": "sample"
}
The matched columns are folded into new data objects. All others are left intact:
SNP | sample | VAF |
---|---|---|
rs99924582 | foo | 0.3 |
rs99924582 | bar | 0.24 |
rs99924582 | baz | 0.94 |
rs22238423 | foo | 0.92 |
rs22238423 | bar | 0.21 |
rs22238423 | baz | 0.42 |