knitr::opts_chunk$set(comment = NA,
  fig.path = '04_figures_aim3_lmm/',
  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. chmi.phen() load data by group and aim. duplicate & relevel t2_point to obtain t2_pont_lm.

# load data
dat_lm <- chmi.phen(group = 'mfi', aim_chmi = 'aim_3')

# 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. 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 = 3,
    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/03_aim3_lmm.RData')


mvazquezs/chmitools documentation built on May 1, 2020, 2:06 a.m.