Skip to content

Mutual nearest neighbor graphs for population structure inference and visualization 🐙

License

Notifications You must be signed in to change notification settings

esteinig/netviewr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

netviewr

Overview

The netviewr package offers a set of operators and functions that make working with data-driven plots of igraph objects more pleasant by:

  • decorating graph objects with user data
  • translating data into graph attributes
  • plotting decorated graphs smoothly

Netviewr is built with its original application in mind, which is the visualization of genetic population structure and associated meta data from genome-wide single nucleotide polymorphisms (SNPs) for both eukaryotic and prokaryotic species. While it is not a suitable package for determining population structure, it can be used to effectively visualize data (traits, phenotypes, genotypes...) across population structures; it should be used in conjunction with other statistically more sophisticated tools like DAPC or Admixture.

Netviewr implements the same tasks and methods as the published version of NetView - except in modern R. If the new syntax feels weird, you can use all functions in base syntax, or if you need backward compatibility, the old version is still accessible.

Citation

If you are using netviewr for research applications, for now please cite:

Steinig et al. (2016) - Netview P: a network visualization tool to unravel complex population structure using genome‐wide SNPs - Molecular Ecology Resources 16 (1), 216-227

If you have trouble accessing the paper, have a look in the documentation folder.

Table of contents

v2.1.0

Install

# Install netviewr (not on CRAN yet)
# install.packages("netviewr")

# Development version from GitHub:
# install.packages("devtools")
devtools::install_github("esteinig/netviewr")

Population graph example

Build and plot a mutual k-nearest-neighbor graph from a (genetic) distance matrix.

matrix(rnorm(900), nrow=30) %>% netviewr::netview(k=20) %>% netviewr::plot_netview()

Base syntax is also supported.

dist_matrix <- matrix(rnorm(900), nrow=30)
g <- netviewr::netview(dist_matrix, k=20)
netviewr::plot_netview(g)

General graph example

Annotate a graph with data and plot the graph.

library(netviewr)

node_data <- tibble::tibble(x=letters[1:10], y=1:10)    # generate 10 x 2 node data tibble

g <- igraph::sample_gnm(n=10, m=15) %@%                 # generate random graph with 10 nodes
     node_data %@%                                      # decorate graph with node data tibble
     node_color(data='x', palette='BuGn') %@%           # decorate nodes with colors paletted by x
     node_size(data='y', min=5, max=8)                  # decorate nodes with values rescaled by y
     
g %>% plot_netview()                                    # plot decorated graph from magrittr pipe 

Plot examples

Contributions

We welcome any and all suggestions or pull requests. Please feel free to open an issue in the repository on GitHub.

About

Mutual nearest neighbor graphs for population structure inference and visualization 🐙

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published