Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.6%) to scientific vocabulary
Last synced: 11 months ago
·
JSON representation
Repository
Diffusion distance and geometry R package
Basic Info
- Host: GitHub
- Owner: gbertagnolli
- Language: R
- Default Branch: main
- Homepage: https://gbertagnolli.github.io/diffudist
- Size: 6.38 MB
Statistics
- Stars: 5
- Watchers: 1
- Forks: 5
- Open Issues: 1
- Releases: 0
Created about 5 years ago
· Last pushed about 2 years ago
Metadata Files
Readme
README.Rmd
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
warn = -1,
comment = "#>",
fig.path = "man/figures/"
)
```
# diffudist
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://github.com/gbertagnolli/diffudist/actions)
[](https://CRAN.R-project.org/package=diffudist)
## Overview
The `diffudist` package provides several functions for evaluating the diffusion distance between nodes of a complex network.
## Installation
```{r, echo = 4:6, eval = FALSE}
# Install from CRAN
install.packages("diffudist")
# Or the development version from GitHub
# install.packages("devtools")
devtools::install_github("gbertagnolli/diffudist")
```
## Usage
Additionally to `diffudist` you will also need the `igraph` package, because the main arguments of the functions in `diffudist` are networks as `igraph` objects.
```{r}
library(diffudist)
library(igraph)
library(ggplot2)
igraph_options(
vertex.frame.color = "white",
vertex.color = "#00B4A6",
label.family = "sans-serif")
```
### Examples
```{r plot-g, fig.width=6, fig.height=6}
N <- 100
g <- sample_pa(N, directed = FALSE)
deg_g <- degree(g)
vertex_labels <- 1:N
vertex_labels[which(deg_g < quantile(deg_g, .9))] <- NA
plot(g, vertex.label = vertex_labels, vertex.size = 6 + 10 * (deg_g - min(deg_g)) / max(deg_g))
```
```{r}
D <- get_distance_matrix(g, tau = 2, type = "Normalized Laplacian", verbose = FALSE)
# or, for short:
# get_DDM(g, tau = 2, type = "Normalized Laplacian", verbose = FALSE)
MERW_Pt <- get_diffusion_probability_matrix(g, tau = 2, type = "MERW")
```
The probability transition matrix returned from `get_diffusion_probability_matrix` (or its shortened version `get_diffu_Pt`) is the matrix $e^{-\tau L_{\text{rw}}}$. The diffusion dynamics is controlled by the specific Laplacian matrix $L_{\text{rw}} = I - T_{\text{rw}}$, where $T_{\text{rw}}$ is the jump matrix of the discrete-time random walk corresponding to our continuous-time dynamics.
Let us check that `MERW_Pt` is an actual stochastic (transition) matrix, i.e., that its rows are probability vectors
```{r}
if (sum(MERW_Pt) - N > 1e-6) {
print("MERW_Pt is not a stochastic matrix")
} else {
print("MERW_Pt is a stochastic matrix")
}
```
Compute diffusion distances from the Probability matrix `MERW_Pt` as follows:
```{r}
if (requireNamespace("parallelDist", quietly = TRUE)) {
# parallel dist
D_MERW <- as.matrix(parallelDist::parDist(MERW_Pt))
} else {
# dist
D_MERW <- as.matrix(stats::dist(MERW_Pt))
}
```
#### Plot distance matrix
And finally plot the distance matrices (requires `ggplot2` and `ggdengro`)
```{r plot_CRW, fig.width=11, fig.height=7, warning=FALSE}
plot_distance_matrix(D, show_dendro = FALSE) +
scale_y_discrete(breaks = vertex_labels[!is.na(vertex_labels)])
```
```{r plot_MERW, fig.width=11, fig.height=7}
plot_distance_matrix(D_MERW, show_dendro = FALSE) +
scale_y_discrete(breaks = vertex_labels[!is.na(vertex_labels)])
```
Adding the hierarchical clustering, i.e., visualising a dendrogram.
```{r plots-with-dendro, fig.width=11, fig.height=7, warning=FALSE}
plot_distance_matrix(D)
plot_distance_matrix(D_MERW)
```
## References
Bertagnolli, G., & De Domenico, M. (2021). _Diffusion geometry of multiplex and interdependent systems_. Physical Review E, 103(4), 042301. [DOI: 10.1103/PhysRevE.103.042301](https://doi.org/10.1103/PhysRevE.103.042301), [arXiv: 2006.13032](https://arxiv.org/abs/2006.13032), [my-website](https://gbertagnolli.github.io/publication/ml-diffusion/).
Owner
- Name: Giulia
- Login: gbertagnolli
- Kind: user
- Location: Bolzano, Italy
- Company: Free University of Bozen-Bolzano
- Website: gbertagnolli.github.io
- Twitter: GiuliaTtt
- Repositories: 4
- Profile: https://github.com/gbertagnolli
Junior Assistant Professor at the Free University of Bozen (IT), passionate about geometries, stats, data, and (open) code.
GitHub Events
Total
Last Year
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Giulia Bertagnolli | g****i@g****m | 16 |
Issues and Pull Requests
Last synced: almost 2 years ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 2.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- cbknox (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 194 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
cran.r-project.org: diffudist
Diffusion Distance for Complex Networks
- Homepage: https://gbertagnolli.github.io/diffudist/
- Documentation: http://cran.r-project.org/web/packages/diffudist/diffudist.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
- Status: removed
-
Latest release: 1.0.1
published over 3 years ago
Rankings
Forks count: 11.3%
Stargazers count: 22.5%
Average: 26.4%
Dependent packages count: 29.8%
Downloads: 32.7%
Dependent repos count: 35.5%
Maintainers (1)
Last synced:
over 1 year ago
Dependencies
DESCRIPTION
cran
- R >= 3.5.0 depends
- Matrix * imports
- Rcpp >= 1.0.7 imports
- expm * imports
- ggdendro * imports
- ggplot2 * imports
- grid * imports
- igraph * imports
- reshape2 * imports
- rlang * imports
- stats * imports
- viridis * imports
- cowplot * suggests
- knitr * suggests
- parallelDist * suggests
- rmarkdown * suggests
- strex * suggests
- tidyr * suggests