Introduction to mineral-chemistry network analysis in dragon

Stephanie J. Spielman

2020-11-05

The dragon (Deep-time Redox Analysis of the Geobiology Ontology Network) library provides a Shiny Application (Chang et al. 2020) for examining mineral-chemistry networks over deep time on Earth, with a specific application of investigating biologically-relevant evolution of element redox states as recorded in the mineral record. These networks are built using open-source data from the Mineral Evolution Database (Golden et al. 2019). dragon uses the igraph (Csardi and Nepusz 2006) and visNetwork (Almende, Benoit, and Titouan 2019) libraries to construct user-friendly interactive networks that can be manipulated and explored in the browser and exported as publication-ready figures.

Citing dragon

If you use dragon, please cite the following publications:

Or, in LaTeX:

# dragon
@article{  ,
  author  = {Spielman, Stephanie J. and Moore, Eli K.},   
  title   = {dragon: A New Tool for Exploring Redox Evolution Preserved in the Mineral Record},      
    journal = {Frontiers in Earth Science},      
    volume  = {8},    
    pages   = {414},
    year    = {2020},
    url     = {https://doi.org/10.3389/feart.2020.585087}
}

# MED 
@inproceedings{ ,
    location = {Phoenix, Arizona},
    title = {Mineral Evolution Database: Data-Driven Age Assignment, How Does a Mineral Get an Age?},
    url = {https://doi.org/10.1130/abs/2019AM-334056},
    booktitle = {{GSA} Annual Meeting},
    year = 2019,
    author = {Golden, Joshua J. and Downs, Robert T. and Hazen, Robert M. and Pires, Alexander J. and Ralph, Jolyon}
}

Obtaining dragon

dragon can be used freely online. Please visit the dragon github page at https://github.com/sjspielman/dragon, which will contain the current link to the free online dragon server without any download.

Alternatively, the current release of dragon can be installed from CRAN, or the bleeding edge development version can be installed using the remotes library:

## Install from CRAN:
install.packages("dragon")

## Install from github (current release)
#install.packages("remotes")
remotes::install_github("sjspielman/dragon")


## Install from github for experimental features:
#install.packages("remotes")
remotes::install_github("sjspielman/dragon", ref = "dev")

To run dragon locally on your computer after installing the package, simply load the library and issue either command, run_dragon() or run_app():

## Launch application
library(dragon)
run_dragon() ## run_app() also works!

Building your network

By default dragon will used a cached and pre-processed version of the MED data. Upon launch, you will be greeted with a prompt indicating the status of the MED data used, with an option to update to the most recent MED data if the cache is out of date. If you elect to update the data, please be patient!! The download will take several minutes or more depending on your internet connection.

Once you acknowledge the prompt, you can proceed to build your network using the sidebar panel. Options and specifications for network construction are described below:

Network construction specifications

These input options are used to specify which elements and minerals will be included in the constructed network. Once you have set these options, click the “Initialize Network” button. When clicked, dragon will build and display your network (unless you turned the display off per settings below). You can change your network settings at any time, including changing the focal elements, without having to click this button again during a given dragon session.

Network styling specifications

dragon contains extremely flexibility functionality for styling your network to your liking, as follows. You can change these settings at any time while using dragon, and the updated settings will be automatically applied to your network.

Network layout and clustering options

This menu item allows you to specifiy network layout and clustering algorithms, as follows:

  • Network layout: Use this menu to select an initial layout for the network. The “Force-directed” layout algorithms are stochastic, so you can also specify a Seed for reproducibility purposes.
    • CAUTION! The “Dynamic physics layout” option can, for larger networks, produce substantial amounts of visual noise which may trigger photosensitive users.
  • Network community detection (clustering) algorithm: You can select one of the two approaches “Louvain” (Blondel et al. 2008) or “Leading eigenvector” (Newman 2006) to perform community clustering on your network.

Node colors

Here you can select color schemes for element and mineral nodes (Color elements/minerals based on:“). Most simply, you can choose a single color for all nodes of a given group, or you can choose a data attribute according to which nodes of a given group will be colored. When an attribute is selected (”Color elements/minerals based on:"), you will have the choice of several colorblind-friendly palettes offered by the RColorBrewer package (Neuwirth 2014).

When coloring nodes by an attribute, it is possible that some nodes will not have an associated attribute value, i.e. there may be some “NAs.” The field Color to use for missing for unknown values can be used to select how nodes with missing information will be colored. Notably, this selected color will also be used for any NAs associated with “Edge Colors” (keep reading!).

Alternatively, you can choose to turn on the option Color all nodes by community cluster, which will override any element- or mineral-specific color scheme specified. All nodes will be colored according to their community cluster, using a colorblind-friendly palette of your choosing. The option to choose a community cluster palette will appear if this option is turned on.

Color individual elements

dragon can also apply specific colors to a set of element nodes of interest, on top of any color scheme specified under “Node Colors.” First, you can turn on the option Highlight focal element(s) to specifically color your network’s focal element(s) by a chosen color. Second, you can highlight any set of elements you would like to emphasize using the dropdown menu Highlight a set of elements and choosing an associated color.

Node Sizes

Similar to node colors, you can either select a single size for element and mineral nodes each, or you can set the size for each node type according to a given attribute. All size settings can be scaled up or down using the associated slider. Unlike the node colors where some attributes may have missing data, however, it is guaranteed that no attributes used for node sizing have any NAs.

Further, note that one of the sizing options for elements is “Number of known element localities.” This quantity is based strictly on the number of localities where the element’s associated minerals have been found in the specified network.

Node Shapes

Here, you can change the shape for element and mineral nodes. In particular, you can also disable the shape for element nodes and select the “Text only (no shape)” option. When this is selected, element node color and size will still be based on the specifications under “Node Colors”, “Color Individual Elements”, and “Node Sizes.” Do not use the “Element font color” (keep reading!) to style text-only element nodes.

Node Labels and Font

Here, you can modify element node label color, as well as mineral node label color and font size. Due to specific details of how the visNetwork library handles element nodes, the element node size itself controls the element font size. Therefore, to resize element labels, please resize element nodes. Note further that the “Element font color” should only be used when element nodes have either a circle or square shape; it will have no effect when the element shape is text only.

By default, mineral node names are hidden as they are usually very long and contribute mostly visual noise. However, you can show mineral node names (and select the font color!) using the widgets “Mineral font color” and “Mineral font size”. Unlike element nodes, the font color and size for mineral nodes is independent of the shape’s size.

Edge attributes

Under thus menu item, you can set the edge color scheme as well as edge thickness. The edge color scheme specification is similar to that for node colors: You can either select a single color for all edges, or color edges according to a given attribute with a colorblind-friendly palette. Again, if an attribute is selected, some edges may have missing information. Please use the “Color to use for missing for unknown values” widget under the “Node Colors” menu item to specify the NA color to use.

Network Interaction Options

The final sidebar menu item controls how you interact with the network by allowing you to change the default visNetwork settings. None of these options will effect the network contents or styling.

  • Node selection highlight degree
    • This specifies how many connected nodes will be emphasized when you click a node. The default degree of “2” means all nodes within 2 degrees of separation ($$2 edges) will be emphasized.
  • Emphasize on hover
    • When turned on (default), nodes will be emphasized when the cursor hovers over them.
  • Hide edges when dragging nodes
    • When turned on (default), edges will visually disappear when re-positioning a node, and they will re-appear after you drag the node to its new location. This option increases the speed of the interactive network rendering, so we recommend keeping it on!
  • Drag network in frame
    • When turned on (default), you can reposition the entire network by clicking and dragging. When turned off, you can reposition individual nodes but not the network as a whole.
  • Scroll in network frame to zoom
    • When turned on (default), scrolling on your mouse will zoom in and out of the network.
  • Show navigation buttons
    • When turned on (not the default), a set of green buttons will appear in the network display frame which can be used to re-position and zoom in/out of the network.

Exporting your network

Below the interactive network are several buttons to export the network and its associated metadata:

Finally, you can export the network image itself. On one hand, it is possible to directly right-click on the interactive network and click “Save Image As.” This will save the network image exactly as it appears within dragon. Unfortunately, there are known limitations with visNetwork (itself a wrapper for the vis.js Javascript library) that prevent high-resolution image export. We therefore offer a separate approach for exporting the network image: We convert the visNetwork-formatted network display styled in the browser into a fully styled igraph object, which can be exported and visualized at high resolution. To use this approach…

Analyzing the minerals in your network

Under the tab “Analyze Network Minerals,” dragon will construct simple linear regressions to analyze the relationships among mineral properties in the network you have built. Note that this tab is also responsive to the inputs in the sidebar panel. If you change the network fundamentals (e.g. focal elements or age range), the analysis will change as well.

To perform a linear regression, specify a predictor (aka “explanatory” or “independent”) variable and a response (aka “dependent”) variable. The modeling results will be reported on the right side of the screen. If you select “Community cluster” as the predictor variable, a Tukey test will also be performed to perform pairwise comparisons of all clusters considered, so you will see two tables of results. A visualization of your model will appear below the table(s), and you can use style the plot according to various options that appear left of the visualization. You can also export this image using the “Download Plot” button.

There are several caveats to be aware of when conducting analyses in this tab:



References

Almende, B. V., T. Benoit, and R. Titouan. 2019. VisNetwork: Network Visualization Using ’Vis.js’ Library. https://CRAN.R-project.org/package=visNetwork.

Blondel, Vincent D., Jean-Loup Guillaume, Renaud Lambiotte, and Etienne Lefebvre. 2008. “Fast Unfolding of Communities in Large Networks.” Journal of Statistical Mechanics: Theory and Experiment 2008 (10): P10008. https://doi.org/10.1088/1742-5468/2008/10/P10008.

Chang, Winston, Joe Cheng, JJ Allaire, Yihui Xie, and Jonathan McPherson. 2020. Shiny: Web Application Framework for R. https://CRAN.R-project.org/package=shiny.

Csardi, Gabor, and Tamas Nepusz. 2006. “The Igraph Software Package for Complex Network Research.” InterJournal Complex Systems: 1695. https://igraph.org.

Golden, Joshua J., Robert T. Downs, Robert M. Hazen, Alexander J. Pires, and Jolyon Ralph. 2019. “Mineral Evolution Database: Data-Driven Age Assignment, How Does a Mineral Get an Age?” In GSA Annual Meeting. Phoenix, Arizona. https://doi.org/10.1130/abs/2019AM-334056.

Neuwirth, Erich. 2014. RColorBrewer: ColorBrewer Palettes. https://CRAN.R-project.org/package=RColorBrewer.

Newman, M. E. J. 2006. “Finding Community Structure in Networks Using the Eigenvectors of Matrices.” Physical Review E 74 (3): 036104. https://doi.org/10.1103/PhysRevE.74.036104.