-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-individual-network-similarity.Rmd
127 lines (101 loc) · 3.23 KB
/
02-individual-network-similarity.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
---
author: V. Keith Hughitt
date: "`r format(Sys.time(), '%d %B, %Y')`"
params:
settings: ""
title: "Similarity of individual co-expression networks"
version: ""
analysis_dirname: "02-individual-network-similarity"
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
---
```{r load_libraries, message=FALSE}
library(annotables)
library(dplyr)
library(gplots)
library(ggplot2)
library(knitr)
library(readr)
library(RColorBrewer)
library(clusteval)
library(irr)
library(mclust)
library(viridis)
# heatmap font sizes
heatmap_cex <- 0.5
```
```{r child='child/02-indiv-net-similarity-overview.Rmd'}
```
# Setup
```{r child='child/00-shared-setup.Rmd'}
```
```{r settings}
# edge weight quantile cutoff to use when comparing ratio of overlap for top edges
# in each network
EDGE_WEIGHT_QUANTILE_CUTOFF <- 0.90
```
**Load individual networks**
First, we will load the co-expression network ranking from the most recent round of optimization.
```{r compute_enrichment_scores}
networks <- MANUSCRIPT_CONFIG$networks
if (CONFIG$target == 'host') {
# Host (GO, CPDB, Marbach)
networks$enrichment_score = as.vector((1/3) * (scale(networks$total_go_pval) +
scale(networks$total_cpdb_pval) +
scale(networks$total_marbach_pval)))
} else {
# Parasite (GO)
networks$enrichment_score = as.vector(scale(networks$total_go_pval))
}
# add rank column and sort rank
networks = networks %>%
arrange(desc(enrichment_score))
networks$rank = 1:nrow(networks)
```
```{r select_networks}
# number of networks to compare
num_networks <- min(MANUSCRIPT_CONFIG$num_networks, nrow(networks))
# Get N randomly selected networks
networks <- networks[sample(1:nrow(networks), num_networks), ]
# Get top N highest-scoring networks
#networks <- head(networks %>% arrange(desc(enrichment_score)), num_networks)
```
# Methods & Results
```{r child='child/02-indiv-net-module-similarity.Rmd'}
```
```{r child='child/02-indiv-net-permuted-network-similarity.Rmd'}
```
```{r child='child/02-indiv-net-edge-similarity.Rmd'}
```
# System Information
```{r}
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}
# 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('individual-network-similarity_', MANUSCRIPT_CONFIG$output_prefix, '.html'))
pdf_filepath <- sub('html', 'pdf', html_filepath)
if (opts_knit$get("rmarkdown.pandoc.to") == 'latex') {
system(sprintf('(sleep 30 && mv 02-individual-network-similarity.pdf %s) &', pdf_filepath))
} else {
system(sprintf('(sleep 30 && mv 02-individual-network-similarity.html %s) &', html_filepath))
}
```
```{r}
# total running time
Sys.time() - time_start
```