knitr::opts_chunk$set(comment = NA,
  fig.path = '06_figures_aim3_lmm_out/',
  fig.width = 20,
  fig.height = 12,
  results = 'markup',
  tidy = F,
  message = F,
  warning = F,
  echo = F)
alpha <- 0.05

r packages

library(moonBook)
library(devtools)
# mac
  load_all('~/Documents/git/chmitools')
# home
# source('~/git/myR_setup/myR.profile')

load data

Main bullet points in load data section. duplicate & relevel t2_point to obtain t2_pont_lm. chmi.phen() load data by group and aim, plus argument fold_change.

# load data
  dat_lm <- chmi.phen(group = 'mfi', aim_chmi = 'aim_3') %>%
    filter(gr_hbs != 'naive') %>%
    droplevels()

# relevel
  dat_lm <- within(dat_lm, {
    gr_hbs <- relevel(gr_hbs, ref = 'AA')
  })

# double variable `t2_point`
  dat_lm <- dat_lm %>%
    mutate(t2_point_lm = as.numeric(
    ifelse(t2_point == 'C-1', 0,
    ifelse(t2_point == 'D7', 7,
    ifelse(t2_point == 'D13', 13,
    ifelse(t2_point == 'D19', 19,
    ifelse(t2_point == 'D28', 28, NA)))))))


# table descriptive
# tab_1 <- mytable(t2_point ~ dataset + isotype_igg + gr_hbs, data = dat_lm)
#   tab_2 <- mytable(isotype_igg ~ dataset + t2_point + gr_hbs, data = dat_lm)

betas & p_values in lmm models

Bullet points in summary() section of lmm models. chmi.stat.lmm_mods() obtain raw and adjusted p-values. naive group in gr_hbs are excluded. * we are used p.adjust() function to adjust p-values by Benjamini & Hochberg method.

# list
  l_vars <- c('isotype_igg', 'antigen')

# lmm models
  tab_3 <- chmi.stat.lmm_mods(dat_lm,
    group_by = l_vars,
    n_levels = 2,
    format_pval = T)

# list for 'tab_3'
l_estim <- tab_3[[1]] %>% select(contains('est')) %>% names()
# l_pvals <- tab_3[[1]] %>% select(contains('pval')) %>% names()

# 'tab_3' datatable
  datatable(tab_3[[1]], class = c('compact cell-border stripe hover'),
    extensions = c('Buttons', 'FixedColumns'),
    filter = 'top',
    options = list(dom = 'Blftip',
      pageLength = 30,
      buttons = c('copy', 'csv'),
      scrollX = TRUE,
      text = 'Download')) %>%
    formatRound(l_estim, 3)

save in r_data folder

# save
save.image(file = '/Users/migvazquez/Documents/git/chmitools/projects/03_aim3/r_data/06_aim3_lmm_out.RData')


mvazquezs/chmitools documentation built on March 21, 2019, 4:19 p.m.