-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-consensus-network-construction.Rmd
152 lines (124 loc) · 4.04 KB
/
03-consensus-network-construction.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
author: V. Keith Hughitt
date: "`r format(Sys.time(), '%d %B, %Y')`"
params:
settings: ""
title: "Consensus Co-expression Network Construction"
version: ""
analysis_dirname: "03-consensus-network-construction"
title: "`r params$title` (`r params$version`)"
output:
html_document:
toc: true
number_sections: true
pdf_document:
toc: true
number_sections: true
latex_engine: xelatex
---
Introduction
============
The goal of this analysis is to construct a consensus co-expression network by
summing the adjacency matrices for multiple network parameterizations, and then
compare the effect of pruning low-confidence network edges and genes at various
thresholds.
See the "Consensus co-expression network" analysis for a more thorough
explanation of the basic approach, and some alternative methods for
constructing the consensus network.
Methods
=======
```{r load_libraries, message = FALSE, results = 'hide'}
library(annotables)
library(biomaRt)
library(clusteval)
library(data.table)
library(digest)
library(doParallel)
library(plyr)
library(dynamicTreeCut)
library(DT)
library(flashClust)
library(foreach)
library(goseq)
library(gplots)
library(heatmaply)
library(hpgltools)
library(igraph)
library(knitr)
library(knitcitations)
library(reshape2)
library(tools)
library(tidyverse)
source('../../2015/00-shared/R/annotations.R')
source('../../2015/00-shared/R/enrichment_analysis.R')
source('../../2015/00-shared/R/filtering.R')
source('../../2015/00-shared/R/util.R')
source('../../2015/00-shared/R/wgcna.R')
```
```{r child='child/00-shared-setup.Rmd'}
```
```{r knitr_settings}
# 2019-02-25 knitr settings set in child rmd not preserved
opts_knit$set(root.dir = base_dir,
verbose = TRUE,
error = FALSE)
opts_chunk$set(fig.path = output_figprefix,
dev = c('png', 'cairo_pdf'),
dev.args = list(pdf = list(family = "DejaVu Sans")),
error = FALSE,
fig.width = 6,
fig.height = 6,
fig.retina = 1,
dpi = 600,
cache.path = cache_dir)
```
```{r child='../../2015/00-shared/Rmd/init/load_counts.Rmd'}
```
```{r child='../../2015/00-shared/Rmd/init/load_host_annotations.Rmd', eval = CONFIG$target == 'host'}
```
```{r child='../../2015/00-shared/Rmd/init/load_pathogen_annotations.Rmd', eval = CONFIG$target == 'pathogen'}
```
```{r child='child/03-build-consensus-net.Rmd'}
```
```{r child='child/03-consensus-net-functional-enrichment.Rmd'}
```
```{r child='child/03-filtered-consensus-net-comparison.Rmd'}
```
```{r child='child/03-filtered-consensus-net-results.Rmd'}
```
Results
=======
```{r child='child/03-consensus-net-vs-indiv-nets.Rmd'}
```
```{r child='child/03-consensus-net-vs-indiv-nets-human-grn.Rmd', eval = CONFIG$target == 'host'}
```
```{r save_tables}
# save tables to output dir
write.csv(table_1, file = file.path(output_tabledir, paste0('table_01_', output_suffix, '.csv')),
quote = FALSE, row.names = FALSE)
```
System Information
==================
```{r sysinfo}
sessionInfo()
```
```{r git_commit}
# manuscript-specific code (https://github.com/elsayed-lab/manuscript-coex-networks)
system('git rev-parse --short HEAD', intern = TRUE)
# shared code (https://github.com/elsayed-lab/manuscript-shared-rnaseq)
system('git --git-dir=$UMD/2015/00-shared/.git rev-parse --short HEAD', intern = TRUE)
```
```{r save_output, include = FALSE}
# free up memory for pandoc conversion
rm(adjmat, filtered_adjmat)
suppressMessages(gc())
# Give rmarkdown some time to finish convern and then copy original rmarkdown
# along with output images and HTML to archive location
html_filepath <- file.path(output_prefix, paste0('network_construction_', MANUSCRIPT_CONFIG$output_prefix, '.html'))
pdf_filepath <- sub('html', 'pdf', html_filepath)
if (opts_knit$get("rmarkdown.pandoc.to") == 'latex') {
system(sprintf('(sleep 60 && mv 03-consensus-network-construction.pdf %s) &', pdf_filepath))
} else {
system(sprintf('(sleep 60 && mv 03-consensus-network-construction.html %s) &', html_filepath))
}
```