Skip to content

Commit 0829dca

Browse files
author
dirmeier
committed
added gif
1 parent b5003d8 commit 0829dca

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1 align="center"> diffusr </h1>
1+
# diffusr <img src="https://rawgit.com/dirmeier/diffusr/master/inst/fig/diffusion.gif" align="right" width="160px"/>
22

33
[![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
44
[![Build Status](https://travis-ci.org/dirmeier/diffusr.svg?branch=master)](https://travis-ci.org/dirmeier/diffusr)
@@ -14,15 +14,15 @@ Network diffusion algorithms in R.
1414
`diffusr` implements several algorithms for network diffusion such as *Markov random walks with restarts* and *weighted neighbor classification*. Network diffusion has been studied extensively in bioinformatics, e.g. in the field of cancer gene prioritization. Network diffusion algorithms generally spread information, e.g. encoded as node weights, along the edges of a graph to other nodes. These weights can for example be interpreted as temperature, an initial amount of water, the activation of neurons in the brain, or the location of a random surfer in the internet. The information (node weights) is iteratively propagated to other nodes until a equilibrium state or stop criterion occurs.
1515

1616
## Installation
17-
17+
1818
Install `diffusr` using:
1919
```{r}
2020
install.packages("diffusr")
2121
```
2222

2323
Alternatively use the latest version from github:
2424
```{r}
25-
devtools::install_github("dirmeier/diffusr")
25+
devtools::install_github("dirmeier/diffusr")
2626
```
2727

2828
## Usage

inst/fig/diffusion.R

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
library(igraph)
3+
library(ggraph)
4+
library(dplyr)
5+
library(viridis)
6+
library(animation)
7+
8+
graph <- igraph::barabasi.game(n=6, power=5)
9+
10+
V(graph)$color <- ovl[2]
11+
V(graph)[[1]]$color <-ovl[12]
12+
g1 <- ggraph(graph) +
13+
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") +
14+
geom_node_point(color=V(graph)$color, size=25) +
15+
theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black')
16+
17+
V(graph)$color <- ovl[3]
18+
V(graph)[[1]]$color <-ovl[11]
19+
g2 <- ggraph(graph) +
20+
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") +
21+
geom_node_point(color=V(graph)$color, size=25) +
22+
theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black')
23+
V(graph)$color <- ovl[4]
24+
V(graph)[[1]]$color <-ovl[10]
25+
g3 <- ggraph(graph) +
26+
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") +
27+
geom_node_point(color=V(graph)$color, size=25) +
28+
theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black')
29+
V(graph)$color <- ovl[5]
30+
V(graph)[[1]]$color <-ovl[9]
31+
g4 <- ggraph(graph) +
32+
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") +
33+
geom_node_point(color=V(graph)$color, size=25) +
34+
theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black')
35+
V(graph)$color <- ovl[6]
36+
V(graph)[[1]]$color <-ovl[8]
37+
g5 <- ggraph(graph) +
38+
geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") +
39+
geom_node_point(color=V(graph)$color, size=25) +
40+
theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black')
41+
42+
43+
gif <- function() {
44+
lapply(list(g1, g2, g3, g4, g5), function(i) {
45+
print(i)
46+
})
47+
}
48+
saveGIF(gif(), interval = .8, movie.name="diffusion.gif")

inst/fig/diffusion.gif

57.3 KB
Loading

src/neighbors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void nearest_neighbor_dijkstra_(std::set<int>& nei,
143143
{
144144
visited[cn.first] = true;
145145
}
146-
// add as neighbor with index + 1, cause neighbors are indexed
146+
// add as neighbor with index + 1, cause neighbors are indexe
147147
// starting from 1 in R
148148
nei.insert(cn.first + 1);
149149
// add current node to priority queue

0 commit comments

Comments
 (0)