analysis/scripts/tables/peb_interactions.R

# load libraries
library(WGCNA)
library(xtable)
library(tidyverse)

# load data
load('data/rkip_wgcna.rda')

# global variables
tables_dir = 'manuscript/tables'

# generate table
exportNetworkToVisANT(net$adj, threshold = .1) %>%
  filter(from %in% split(ann$symbol, ann$category)$pebp) %>%
  left_join(genes, by = c('to'='symbol')) %>%
  left_join(ann, by = c('to'='symbol')) %>%
  filter(category != 'pebp') %>%
  mutate(from = paste('\\emph{', from, '}', sep = ''),
         to = paste('\\emph{', to, '}', sep = '')) %>%
  group_by(color, from, category) %>%
  summarise(gene = paste(unique(to), collapse = ', ')) %>%
  spread(category, gene) %>%
  ungroup() %>%
  mutate(color = ifelse(duplicated(color), '', color)) %>%
  setNames(c('Module', 'PEB', 'Autophagy', 'EMT')) %>%
  xtable(caption = 'PEB interactions with autophagy and EMT.',
         label = 'tab:peb_interactions',
         align = 'cllp{.4\\textwidth}p{.3\\textwidth}') %>%
  print(include.rownames = FALSE,
        booktabs = TRUE,
        caption.placement = 'top',
        table.placement = 'H',
        sanitize.text.function = identity,
        comment = FALSE,
        file = paste(tables_dir, 'peb_interactions.tex', sep = '/'))
BCMSLab/rkip documentation built on May 17, 2019, 2:14 a.m.