Linkspotter is a package of the R software that mainly allows to calculate and visualize using a graph all the bivariate links of a dataset.
Its main features are:
It also offers a customizable user interface, allowing to:
Available link coefficients are:
library(devtools)
install_github("sambaala/linkspotter")
Behind a proxy:
library(devtools)
library(httr)
set_config(
use_proxy(url="<my_proxy>", port=<my_proxy_port>)
)
install_github("sambaala/linkspotter")
Load the package:
library(linkspotter)
Take a look at the documentation:
help(package="linkspotter")
The examples are carried out using “iris” data.
maxNMI(iris$Sepal.Length,iris$Petal.Length)
## [1] 0.6992338
corCouples<-multiBivariateCorrelation(iris)
print(corCouples)
## id X1 X2 typeOfCouple pearson spearman
## 1 1 Sepal.Length Sepal.Width num.num -0.1175698 -0.1667777
## 2 2 Sepal.Length Petal.Length num.num 0.8717538 0.8818981
## 3 3 Sepal.Length Petal.Width num.num 0.8179411 0.8342888
## 4 4 Sepal.Length Species num.fact NA NA
## 5 5 Sepal.Width Petal.Length num.num -0.4284401 -0.3096351
## 6 6 Sepal.Width Petal.Width num.num -0.3661259 -0.2890317
## 7 7 Sepal.Width Species num.fact NA NA
## 8 8 Petal.Length Petal.Width num.num 0.9628654 0.9376668
## 9 9 Petal.Length Species num.fact NA NA
## 10 10 Petal.Width Species num.fact NA NA
## kendall mic MaxNMI correlationType
## 1 -0.07699679 0.2770503 0.2033015 negative
## 2 0.71851593 0.7682996 0.6992338 positive
## 3 0.65530856 0.6683281 0.6113692 positive
## 4 NA NA 0.4873895 nominal
## 5 -0.18599442 0.4391362 0.3789867 negative
## 6 -0.15712566 0.4354146 0.3904720 negative
## 7 NA NA 0.2606311 nominal
## 8 0.80689069 0.9182958 0.8351786 positive
## 9 NA NA 0.8702060 nominal
## 10 NA NA 0.8920899 nominal
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
cl<-clusterVariables(corMatrix = corMatrixMaxNMI)
print(cl)
## var group
## 1 Petal.Length 1
## 2 Petal.Width 2
## 3 Sepal.Length 3
## 4 Sepal.Width 4
## 5 Species 2
linkspotterGraph(corDF = corCouples, variablesClustering = cl,
corMethod = "pearson", minCor = 0.25, smoothEdges = FALSE,
dynamicNodes = FALSE)
linkspotterGraph(corDF = corCouples, variablesClustering = cl,
corMethod = "MaxNMI", minCor = 0.25, smoothEdges = F,
dynamicNodes = TRUE)
linkspotterUI(dataset = iris, corDF = corCouples,
variablesClustering = cl, appTitle = "Linkspotter example")
Complete Linkspotter computation:
lsiris<-linkspotterComplete(iris)
## [1] "Number of variables: 5"
## [1] "Number of couples: 10"
## [1] "Number of observations: 150"
## [1] "Start time: 2018-07-19 10:15:14"
## [1] "Correlations computation finished: 2018-07-19 10:15:15"
## [1] "Clustering computation finished: 2018-07-19 10:15:15"
## [1] "Total Computation time: 1.047 secs"
Complete Linkspotter computation from an external file:
lsiris<-linkspotterOnFile("iris.csv")
summary(lsiris)
summary(lsiris)
## Length Class Mode
## computationTime 1 -none- character
## launchShiny 1 -none- function
## 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)
Linskpotter UI example on ‘iris’ data
The variables corresdond to the nodes and their links correspond to the edges. Node color depends on the clustering. Edge color depends on the correlation direction quantitative couples (blue: positive correlatuion, red: negative correlation).
It produces the following:
Its type depends on the nature of the corresponding link:
It displays all the measurements calculated for the link corresponding to the clicked edge. When at least one of the variables is qualitative, only the MaxNMI has a value.
It produces the following:
Its type depends on the nature of the corresponding variable:
Its type depends on the nature of the variable:
This tab displays 2 tables:
The Correlation coefficient option allows you to choose the coefficient of correlation to be considered among those calculated initially.
Linkspotter uses and combine features coming from several other R packages, namely infotheo, minerva, energy, mclust, shiny, visNetwork, rAmCharts, ggplot2 and Hmisc.