-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
106 lines (84 loc) · 2.79 KB
/
README.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
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo=FALSE, message=FALSE, warning=FALSE}
knitr::opts_chunk$set(message=FALSE, warning=FALSE, comment="")
devtools::load_all(".")
library(igraph)
library(hypeR)
```
# hypeR Network Extension
[![hypeR](https://img.shields.io/badge/montilab-hypeR-0770d9?labelColor=000000)](https://github.com/montilab/hypeR)
[![](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![](https://img.shields.io/github/last-commit/montilab/hypeR-next.svg)](https://github.com/montilab/hypeR-next/commits/master)
An extension of hypeR for network enrichment through random walks.
### Installation
```{r, eval=FALSE}
devtools::install_github("montilab/hypeR-next")
```
```{r, eval=FALSE}
library(hypeR.next)
```
### Data
```{r}
data(ig)
```
This package works with undirected `igraph` objects or extensions of `igraph` objects.
```{r}
is(ig)
```
The following vertex attributes are expected at a minimum.
- `name` - Unique node labels
- `symbol` - Node symbols corresponding to the genesets you use
- `community`- Pre-detected community labels
- `color` - Community-specific colors
```{r}
head(igraph::as_data_frame(ig, what="vertices"))
```
```{r, fig.width=12, fig.height=6}
set.seed(1)
layout <- igraph::layout_with_graphopt(ig,
start=NULL,
niter=1000,
charge=0.005,
mass=30,
spring.length=0,
spring.constant=1,
max.sa.movement=5)
par(mar=c(0,0,0,0))
plot(ig,
vertex.size=4,
vertex.color="grey",
vertex.frame.color="black",
vertex.label=NA,
edge.width=1,
layout=layout)
```
### Network characterization through random walks
```{r}
library(hypeR)
genesets <- hypeR::msigdb_gsets("Homo sapiens", "H", clean=TRUE)
```
```{r}
ig.e <- enrich_communities_static(ig, genesets, restart=0.5, fdr=0.01, top=1)
```
```{r, fig.width=12, fig.height=8}
par(mar=c(0,0,0,0))
set.seed(1234)
plot(ig.e,
vertex.size=5,
vertex.label=V(ig.e)$enrichment,
vertex.color=adjustcolor(V(ig.e)$color, alpha.f=0.6),
vertex.frame.color=adjustcolor("#000000", alpha.f=0),
vertex.label.family="Helvetica",
vertex.label.color="black",
vertex.label.font=2,
vertex.label.cex=0.8,
vertex.label.dist=runif(vcount(ig.e), -0.25, 0.25),
edge.color=adjustcolor("#000000", alpha.f=0.2),
layout=layout)
```
Please read the documentation for a comprehensive overview of functionality.