Movatterモバイル変換


[0]ホーム

URL:


shinySBM package

Introduction

This vignette illustrates the use of the {shinySbm} package which isa shiny based graphical user interface (GUI) of the {sbm} package. Thesepackages are made to applyStochastic Block Models onnetwork dataset. This dataset can be in two format: edges list andconnection matrix. First we will see how to use the shiny application inthe package. And in the second part we will see how to use the externalfunctions asplotSbm() andvisSbm().

The shiny application:shinySbmApp()

shinySbmApp() function contain a {shiny} applicationwhich help to use and help to learn the basics of{sbm} package. Userscan import their data inside it and applyStochastic BlockModels. They can transform network data fromedgeslist toconnection matrix. Once the SBM ran,users can explore the different number of groups selected by {sbm}. Theycan get models outputs as: table of parameters, plots, interactivenetwork visuals, automatic reports (pdf or html) (French or English), Rscript to repeat the analysis outside of the app and tables of blockattributions.

The following code show how to runshinySbmApp() fromyour R console.

library(shinySbm)shinySbmApp()

When this is done your browser should load this page. From this pageyou can import your dataset by clicking on theBrowsebutton in embedded in red.

When you load it, the install helper (1) can showadvice to adjust the importation. For example here, we imported this setas anAdjacency or Incidence matrix but as we can seein (2), we imported an Edges list. So, we need tochange thenature of imported data.

When there is nowarnings any more, we can thenpress the buttonMatrix Builder, which will extractessential information from your dataset. If your used anedgeslist, anadjacency matrix will be built.

Once the matrix is correctly imported. You should go to theSBM application (1) page and thenclick on theRun SBM button (2). Whenthe calculation are done you will see a small summary from the currentmodel. The small moduleBlock settings allows you byclicking on the graph (or numeric input) to select another block numberand change the current model. You can also tune your SBM model from thispage with theMore Settings button.

Then it’s time to explore the visuals and outputs in the otherpages.

External functions

The following codes are built by theshinySbmAppapplication, pageReport with theRcode option. The next chunk is only made of {sbm} packagefunctions.

# Loading DatasetmyNetworkMatrix<- fungusTreeNetwork$fungus_tree# Fiting SBMmySbmModel<-estimateBipartiteSBM(netMat = myNetworkMatrix,model ='bernoulli',estimOptions =list(plot = F,verbosity =0))

See this vignette to learn more of {sbm}

vignette("SBM_fungus_tree_network")

The functionplotSbm is a convenient function that cantake as arguments: matrices or objects produced byestimateBipartiteSBM() andestimateSimpleSBM()of {sbm}. It then plot them in a nice matrix of tiles, that can beordered by blocks or not, transposed etc…

plotSbm(  mySbmModel,ordered =TRUE,transpose =TRUE,labels =c(row ='Fungus',col ='Trees'),plotOptions =list(showLegend =FALSE,showPredictions =TRUE  ))

The functionvisSbm is a convenient function that cantake as arguments objects produced byestimateBipartiteSBM() andestimateSimpleSBM()of {sbm} (it doesn’t take matrices). It make a {visNetwork} type objectthat represent the network condensed by blocks.

visSbm(x = mySbmModel,labels =c(row ='Fungus',col ='Trees'),directed =TRUE,settings =list(edge_threshold ='default',arrows =TRUE,arrow_start ='row'  ))

Thanks for your reading, if any question remain, contact us:shiny.sbm.dev@gmail.com

References

Package SBM

Chiquet J, Donnet S, Barbillon P (2023).sbm: StochasticBlockmodels. R package version 0.4.5,https://CRAN.R-project.org/package=sbm.

The demo dataset

Vacher, Corinne, Dominique Piou, and Marie-Laure Desprez-Loustau.“Architecture of an antagonistic tree/fungus network: the asymmetricinfluence of past evolutionary history.” PloS one 3.3 (2008): e1740.


[8]ページ先頭

©2009-2025 Movatter.jp