Scripts to parse and analyze UK Biobank data.
Awk script to melt tab-delimited UK Biobank dataset, similar the melt function of the reshape2 R package.
The motivation for this script is to faciliate the convertion of large tab-delimited UK Biobank dataset to long format, or to melt the dataset. For a small dataset, please consider using the melt function of the reshape2 R package as it offers greater functionality.
awk -f melt_tab.awk ukb####.tab > ukb####.melt
Missing values (NA) are discarded.
Columns in tab-delimited output are:
- eid: Participant id.
- df: Data-field id.
- instnum: Instance number for given data-field (0-based).
- itemnum: Item number for given instance (0-based).
- value: Data-field value for given participant, instance number and item number.
Gawk script to subset tab-delimited UK Bionank dataset by list of user-supplied data-fields.
gawk -f fetch_tab.awk data-fields.txt ukb####.tab | gzip -c > ukb####_fetch.tab.gz
File data-fields.txt contains data-field identifiers, one per line. Example:
21022
52
34
31
Output is a subset of input UK Biobank dataset by the supplied data-fields. The format of the file remains tab-delimited, and data-fields retain original order. For each data-field, all instance and items are output. All participants are output.