Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/natbprice/radsets
:package: An R package for interactive, network-based visualizations of overlapping sets
https://github.com/natbprice/radsets
Last synced: 3 months ago
JSON representation
:package: An R package for interactive, network-based visualizations of overlapping sets
- Host: GitHub
- URL: https://github.com/natbprice/radsets
- Owner: natbprice
- License: mit
- Created: 2019-03-20T14:30:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-25T21:33:21.000Z (over 4 years ago)
- Last Synced: 2024-05-21T02:10:56.329Z (6 months ago)
- Language: R
- Homepage: https://natbprice.github.io/radsets/
- Size: 2.53 MB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.Rmd
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
bibliography: paper/paper.bib
---```{r setup, include=FALSE}
library(radsets)
library(tidyverse)
library(knitr)
local({
hook_plot = knit_hooks$get('plot')
knit_hooks$set(plot = function(x, options) {
x = paste(x, collapse = '.')
if (!grepl('\\.svg', x)) return(hook_plot(x, options))
# read the content of the svg image and write it out without
paste0('')
})
})
``````{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
echo = FALSE,
eval= TRUE,
message = FALSE,
warning = FALSE,
comment = "#>",
fig.path = "man/figures/README-"
)
```# radsets
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![Travis build status](https://travis-ci.org/natbprice/radsets.svg?branch=master)](https://travis-ci.org/natbprice/radsets)
[![Coverage status](https://codecov.io/gh/natbprice/radsets/branch/master/graph/badge.svg)](https://codecov.io/github/natbprice/radsets?branch=master)
[![License: CC0-1.0](https://img.shields.io/badge/License-CC0%201.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/1.0/)**Package Website:** https://natbprice.github.io/radsets/
**Source Code:** https://github.com/natbprice/radsets
### Problem
The **radsets** package is a solution to the problem of how to visualize large overlapping sets. In particular, when analyzing data with many overlapping sets it is difficult to draw insight from a Venn diagram. Moreover, it may be impossible to draw a Venn diagram that accurately reflects the size of set intersections.The solution implemented in the **radsets** package is a based on Radial Sets diagrams (see references). Radial Sets diagrams are an interactive, network-based visualization for the analysis of ovarlapping sets.
### MovieLens Example
The [MovieLens dataset](https://grouplens.org/datasets/movielens/20m/) [@harper2016movielens] includes
19 genre attributes for 27,000 movies.#### Radial Sets Diagram
A Radial Sets diagram created with the **radsets** package is shown below.The width of the links indicate the percent overlap (normalized by union) between each movie genre. The link color indicates the relative difference between the observed overlap and the expected overlap assuming marginal independence. The link color palette is diverging blue to red with red indicating overlaps that are larger than expected.
The size of the sections on the circumference are drawn to scale based on the size of each set (i.e., the number of items in each set regardless of overlap). However, since the sets overlap the section sizes can not be interpreted as a donut chart or pie chart. The set locations on the circumference have been optimized to place similar sets closer together, thereby minimizing length of thickest links.
The bars in each sector indicate the number of items unique to each set, shared with one other set, shared with two other sets, or shared with three or more other sets.
```{r examplePlot, dev = 'svg', fig.width = 10, fig.height = 10}
# Load sample data
data("movieSets")# Define set names (user specified)
setNames <- movieSets %>%
select(Action:Western) %>%
colnames()# Define ID column (user specified)
idName <- "movieId"# Define max degree (user specified)
maxDegree <- 4# Calculate set sizes
setSizes <-
getSetSizes(movieSets, setNames)# Calculate set sizes by degree
setSizesByDegree <-
getSetSizesByDegree(movieSets, setNames, idName)# Calculate edge data
setIntersections <-
getSetIntersections(movieSets, setNames, idName)# Optimize link order
optOrder <- optimizeLinkOrder(setSizes,
setSizesByDegree,
setIntersections,
linkThickness = "prop")# Create plot
buildRadialSetsPlot(
setSizes,
setSizesByDegree,
setIntersections,
linkThickness = "prop",
linkColor = "prop.relError",
linkColorPal = "RdBu",
reverseLinkPal = T,
setOrder = optOrder[c(14:19,1:13)],
colorScaleLim = c(-1,1),
colorScaleMapFun = "squish",
edgeWidthRange = c(1,8),
sectorColor = "white"
)
```In the diagram below, we focus on the crime genre. The links are now directional originating from the crime set and link thickness indicates the percent of crime movies that belong to the other genres.
```{r examplePlot2, dev = 'svg', fig.width = 10, fig.height = 10}
buildRadialSetsPlot(
setSizes,
setSizesByDegree,
setIntersections,
linkThickness = "prop",
linkColor = "prop.relError",
linkColorPal = "RdBu",
reverseLinkPal = T,
setOrder = optOrder[c(14:19,1:13)],
colorScaleLim = c(-1,1),
colorScaleMapFun = "squish",
edgeWidthRange = c(1,8),
sectorColor = "white",
focusSets = "Crime"
)
```#### Venn Euler Diagram
Radial sets are useful for visualizing relationships among variables which have many features in common. When the number of variables is small, simple venn diagrams can be useful. However, when the number of pairwise interactions is high, identifying patterns may be too difficult using simple visualizations. Moreover, it may not be possible to draw a venn diagam that accurately represents the overlap between sets. Here we use the [venneuler](https://cran.r-project.org/package=venneuler) package to illustrate the problem with using Venn diagrams when we are interested in many overlapping sets.```{r simpleVennDiag, dev = 'svg'}
library(venneuler)
m <- movieSets %>%
select(movieId, setNames) %>%
select(-movieId) %>%
select("Drama", "Romance", "Comedy")
v <- venneuler::venneuler(m)
plot(v)```
```{r complexVennDiag, dev = 'svg', fig.width = 7, fig.height = 7}
m <- movieSets %>%
select(movieId, setNames) %>%
select(-movieId)
v <- venneuler::venneuler(m)
plot(v)
```## Acknowledgements
Radial Sets diagrams were originally proposed by [@alsallakh2013radial]. The __radsets__ package is unaffiliated with these researchers and the visualizations produced differ slightly from the original design.This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS). No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall pthe fact of release constitute any such warranty. The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.
## References