R/tidy_exwas_result.R

Defines functions tidy_exwas_result

Documented in tidy_exwas_result

tidy_exwas_result <- function(x) {

  # transform rownames into 1st row
  tidy_fit <- tibble::rownames_to_column(x, var = "Exposure") %>%

    # pick the row for an exposure only, ignore coef. for
    # intercept and confounders
    .[2, ] %>%
    dplyr::mutate(CI = stringr::str_c(round(`2.5 %`, 2), round(`97.5 %`, 2), sep = "; "),
           estCI = stringr::str_c(round(estimate, 2), " (", CI, ")", sep = ""),
           p_value = round(p.value, 3)) %>%
    dplyr::select(-c(std.error, statistic, df, p.value)) %>%
    dplyr::rename(Estimate = estimate, conf_low = "2.5 %", conf_high = "97.5 %")

  return(tidy_fit)
}
groovearmada/exwas documentation built on May 29, 2019, 12:02 a.m.