View source: R/createPhewasTable.R
createPhewasTable | R Documentation |
Deprecated, please see createPhenotypes
.
This function takes a data frame with three columns: id, icd9 codes, and counts. It returns a wide table with ICD-9 codes translated into phewas codes. It can optionally use the PheWAS exclusion criteria. Results can be formatted as true/false for a specified threshold or as summed continuous counts.
createPhewasTable(id.icd9.count, min.code.count = 2, add.exclusions = T,
translate = T, aggregate.fun = sum, id.gender)
id.icd9.count |
Data frame with three columns: id, ICD-9 character string, and count. |
min.code.count |
The minimum code count to be considered a case. NA results in a continuous output. |
add.exclusions |
Apply PheWAS exclusions to phecodes. |
translate |
Should the input be translated to phecodes? This requires ICD-9 code input. |
aggregate.fun |
Aggregate function for duplicated phenotypes (phecodes, etc) in an individual. |
id.gender |
If supplied, restrict the phecodes by gender. This should be a data frame with the first column being the id and the second the gender, "M" or "F", of the individual. Individuals with any other specification will have all gender specific phenotypes set to NA. |
By default, this function returns a wide format data frame with boolean phenotypes suitable for PheWAS analysis. Specifying a min.code.count=NA
will permit continuous code count phenotypes.
The default exclusions can be skipped with add.exclusions=F
. In conjuntion with translate=F
(and optionally adjusting min.code.count
and aggregate.fun
), one can use this function as a simple reshaping wrapper.
A data frame. The first column contains the supplied id for each individual (preserving the name of the original column). The following columns are all present phewas codes. They contain T/F/NA for case/control/exclude or continuous/NA if min.code.count was NA.
Robert Carroll Laura Wiley
#Simple example
id_icd9_count=data.frame(id=c(1,2,2,2,3),icd9=c("714","250.11","714.1","714","250.11"),
count=c(1,5,1,1,0))
createPhewasTable(id_icd9_count)
#Complex example
ex=generateExample(n=500,hit="335")
#Extract the icd9 data
id.icd9.count=ex$id.icd9.count
#Create the phecode table for a PheWAS
phenotypes=createPhewasTable(id.icd9.count)
phenotypes[1:10,1:10]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.