phewas_ext | R Documentation |
This function will perform a PheWAS analysis, optionally adjusting for other variables. It is parallelized using the base package parallel.
phewas_ext(phenotypes, genotypes, data, covariates=NA, outcomes, predictors,
cores=1, additive.genotypes=T,
method="glm", strata=NA, factor.contrasts=contr.phewas,
return.models=F, min.records=20, MASS.confint.level=NA, quick.confint.level)
phenotypes |
The names of the outcome variables in data under study. These can be logical (for logistic regression) or continuous (for linear regression) columns. |
genotypes |
The names of the prediction variables in data under study. |
data |
Data frame containing all variables for the anaylsis. |
covariates |
The names of the covariates to appear in every analysis. |
outcomes |
An alternate to |
predictors |
An alternate to |
cores |
The number of cores to use in the parallel socket cluster implementation. If |
additive.genotypes |
Are additive genotypes being supplied? If so, it will attempt to calculate allele frequencies and HWE values. Default is TRUE. |
method |
Determines the statistical method to check associations. One of: 'glm', 'clogit', 'lrt', or 'logistf'. If clogit, requires the If lrt, an atomic vector of |
strata |
Name of the grouping / strat column necessary for clogit. |
factor.contrasts |
Contrasts used for factors to generate names used in clogit. |
return.models |
Return a list the complete models, with the names equal to the string formula used to create them, as well as the results. Default is FALSE. |
min.records |
The minimum number of records to perform a test. For logistic regression, there must be at least this number of each cases and controls, for linear regression this total number of records. Default is 20. |
MASS.confint.level |
Uses the |
quick.confint.level |
Calculate a confidence interval based on |
These results can be directly plotted using the phewasManhattan
function, assuming that models are not returned. If they are, the results
item of the returned list needs to be used.
The following are the default rows included in the returned data frame. The attributes of the returned data frame contain additional information about the anaylsis. If a model did not have sufficient cases or controls for analysis or failed to converge, NAs will be reported and a note will be added in the note field.
phenotype |
The outcome under study |
snp |
The predictor under study |
adjustment |
The one off adjustment used |
beta |
The beta coefficient for the predictor |
SE |
The standard error for the beta coefficient |
lower.p |
The lower bound of the quick confidence interval, if requested |
upper.p |
The upper bound of the quick confidence interval, if requested |
lower |
The lower bound of the |
upper |
The upper bound of the |
OR |
For logistic regression, the odds ratio for the predictor |
p |
The p-value for the predictor |
type |
The type of regression model used |
n_total |
The total number of records in the analysis |
n_cases |
The number of cases in the analysis (logical outcome only) |
n_controls |
The number of controls in the analysis (logical outcome only) |
HWE_p |
The Hardy-Weinberg equilibrium p-value for the predictor, assuming 0,1,2 allele coding |
allele_freq |
The allele frequency in the predictor for the coded allele |
n_no_snp |
The number of records with a missing predictor |
note |
Additional warning or error information |
If there are any requested significance thresholds, boolean variables will be included reporting significance.
If return.models=T
, a list is returned. The named item results
contains the above data frame. The named item models
contains a list of the models generated in the analysis. To distinguish models, the list is named by the full formula used in generation.
Robert Carroll
createPhewasTable
#Generate some example data
ex=generateExample(hit="335")
#Extract the two parts from the returned list
id.icd9.count=ex$id.icd9.count
genotypes=ex$genotypes
#Create the PheWAS code table- translates the icd9s, adds exclusions,
#and reshapes to a wide format
phenotypes=createPhewasTable(id.icd9.count)
#Join the data
data=inner_join(phenotypes,genotypes)
#Run the PheWAS
results=phewas_ext(phenotypes=names(phenotypes)[-1],
genotypes=names(genotypes)[-1],data=data,cores=4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.