devtools::install_github("sambaala/linkspotter")
library(linkspotter)
First, take a look at the documentation:
help(package="linkspotter")
Examples are carried out on “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(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
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] "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)