Installing and loading the package

devtools::install_github("sambaala/linkspotter")
library(linkspotter)

Usage

First, take a look at the documentation:

help(package="linkspotter")

Examples are carried out on “iris” data.

Calculate the MaxNMI between two variables

maxNMI(iris$Sepal.Length,iris$Petal.Length)
## [1] 0.6992338

Extract a correlation matrix from the correlation dataframe

The Pearson correlation matrix:

corMatrixPearson=corCouplesToMatrix(x1_x2_val = corCouples[,c('X1','X2',"pearson")])
print(corMatrixPearson)
##              Petal.Length Petal.Width Sepal.Length Sepal.Width Species
## Petal.Length    1.0000000   0.9628654    0.8717538  -0.4284401      NA
## Petal.Width     0.9628654   1.0000000    0.8179411  -0.3661259      NA
## Sepal.Length    0.8717538   0.8179411    1.0000000  -0.1175698      NA
## Sepal.Width    -0.4284401  -0.3661259   -0.1175698   1.0000000      NA
## Species                NA          NA           NA          NA       1

The MaxNMI matrix:

corMatrixMaxNMI=corCouplesToMatrix(x1_x2_val = corCouples[,c('X1','X2',"MaxNMI")])
print(corMatrixMaxNMI)
##              Petal.Length Petal.Width Sepal.Length Sepal.Width   Species
## Petal.Length    1.0000000   0.8351786    0.6992338   0.3789867 0.8702060
## Petal.Width     0.8351786   1.0000000    0.6113692   0.3904720 0.8920899
## Sepal.Length    0.6992338   0.6113692    1.0000000   0.2033015 0.4873895
## Sepal.Width     0.3789867   0.3904720    0.2033015   1.0000000 0.2606311
## Species         0.8702060   0.8920899    0.4873895   0.2606311 1.0000000

Clustering of variables using a correlation matrix

cl=clusterVariables(correlationMatrix = corMatrixMaxNMI)
print(cl)
##            var group
## 1 Petal.Length     1
## 2  Petal.Width     2
## 3 Sepal.Length     3
## 4  Sepal.Width     4
## 5      Species     2

Visualize the graph using Pearson correlation

linkspotterGraph(corDF = corCouples, variablesClustering = cl, corMethod = "pearson", minCor = 0.25, smoothEdges = FALSE, dynamicNodes = FALSE)

Visualize the graph using MaxNMI

linkspotterGraph(corDF = corCouples, variablesClustering = cl, corMethod = "MaxNMI", minCor = 0.25, smoothEdges = F, dynamicNodes = TRUE)

Launch the costumizable user interface

linkspotterUI(dataset = iris, corDF = corCouples, variablesClustering = cl, appTitle = "Linkspotter example")

Additional features

Complete Linkspotter computation:

lsiris=linkspotterComplete(iris)
## [1] "Number of variables: 5"
## [1] "Number of couples: 10"
## [1] "Number of observations: 150"
## [1] "Duration estimation: 00:00:00"
## [1] "Start time: 2017-05-24 11:48:34"
## [1] "Correlations computation finished: 2017-05-24 11:48:35"
## [1] "Clustering computation finished: 2017-05-24 11:48:35"
## [1] "Total Computation time: 1.130 secs"

Complete Linkspotter computation from an external file:

lsiris=linkspotterOnFile("iris.csv")
summary(lsiris)
summary(lsiris)
##                     Length Class        Mode     
## computationTime      1     -none-       character
## run_it               5     shiny.appobj list     
## dataset              5     data.frame   list     
## corDF               10     data.frame   list     
## corMatrices          5     -none-       list     
## corGroups            2     data.frame   list     
## clusteringCorMethod  1     -none-       character
## defaultMinCor        1     -none-       numeric  
## defaultCorMethod     1     -none-       character
## corMethods           5     -none-       character

Then launch the user interface using:

lsiris$launchShiny()

Help:

help(linkspotterComplete)