{"id":19839834,"url":"https://github.com/qdata/jointnets","last_synced_at":"2025-02-28T19:17:45.597Z","repository":{"id":56936795,"uuid":"139140136","full_name":"QData/JointNets","owner":"QData","description":"JointNets: an end-to-end R package for sparse high-dimensional Gaussian graphical model estimation, visualization, simulation and evaluation.","archived":false,"fork":false,"pushed_at":"2019-11-14T10:27:41.000Z","size":18550,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-11T11:26:37.070Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jointnets.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QData.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-29T11:12:25.000Z","updated_at":"2022-08-09T22:01:49.000Z","dependencies_parsed_at":"2022-08-21T07:20:37.094Z","dependency_job_id":null,"html_url":"https://github.com/QData/JointNets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FJointNets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FJointNets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FJointNets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FJointNets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QData","download_url":"https://codeload.github.com/QData/JointNets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241209587,"owners_count":19927737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T12:24:32.322Z","updated_at":"2025-02-28T19:17:45.572Z","avatar_url":"https://github.com/QData.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JointNets\n\n[JointNets](https://github.com/QData/JointNets) is an end-to-end R package for An end-to-end package for learning multiple sparse Gaussian graphical models and nonparanormal models from Heterogeneous Data with Additional Knowledge. This package supports joint estimation, visualization, simulation and evaluation.\n\n\nIt contains the following estimators:\n[SIMULE](https://link.springer.com/article/10.1007%2Fs10994-017-5635-7),\n[WSIMULE](https://arxiv.org/abs/1709.04090),\n[JEEK](https://arxiv.org/abs/1806.00548),\n[DIFFEE](https://arxiv.org/abs/1710.11223)\nand\n[kDiffNet](). \n\n\nTable of Contents\n====\n\n- [Installation](#installation)\n- [Usage](#Usage)\n    - [Estimation](#Estimation)\n        - [Methods](#Methods)\n        - [Dataset](#Dataset)\n        - [Joint Estimation](#Joint-Estimation)\n        - [Difference Estimation](#Difference-Estimation)\n    - [Visualization](#Visualization)\n        - [plot](#plot)\n        - [plotbrain](#plotbrain)\n        - [Demo](#Demo)\n        - [Sample plots](#Sample-plots)\n    - [Simulation and Evaluation](#Simulation-and-Evaluation)\n        - [Simulation](#Simulation)\n        - [Evaluation](#Evaluation)\n            - [F1](#F1)      \n            - [BIC](#BIC)   \n            - [AUC](#AUC)\n            - [Demo](#Demo)\n    - [GUI](#GUI)\n- [License](#License)\n- [Getting Help](#Getting-Help)\n\n# Installation\n1. From CRAN\n    ``` r\n    install.packages('JointNets', dependencies=TRUE)\n    library(JointNets)\n    ```\n\n2. From the GitHub repo. You need to first install the [devtools](https://CRAN.R-project.org/package=devtools) package\n\n    ``` r\n    install.packages(\"devtools\")\n    ```\n\n    Load the devtools package\n\n    ``` r\n    library(devtools)\n    ```\n\n    Install from Github\n\n    ``` r\n    install_github('QData/JointNets', dependencies = TRUE)\n    library(JointNets)\n    ```\n\n# Usage\n\n## Estimation\n### Methods\nJointNets currently support six estimators: [simule](https://link.springer.com/article/10.1007%2Fs10994-017-5635-7),\n[wsimule](https://arxiv.org/abs/1709.04090),\n[fasjem](https://arxiv.org/abs/1702.02715),\n[jeek](https://arxiv.org/abs/1806.00548),\n[diffee](https://arxiv.org/abs/1710.11223)\nand diffeek\nand they serve different estimation purposes:\n\n* joint estimation from multiple contexts:\n    * ```simule``` and ```fasjem```\n* joint estimation from multiple contexts, incorporating prior knowledge:\n    * ```wsimule``` and ```jeek```\n* difference estimation from two contexts:\n    * ```diffee```\n* difference estimation from two contexts, incorporating prior knowledge:\n    * ```diffeek```\n\n### Dataset\nEach estimator function takes input as a list of data matrices (for multiple contexts) or two separate data matrices (for difference estimation).\n\nThe data matrix should be arranged so that each row represents a cell of data (eg, matrix of size 500 x 20 represents 500 instances of data of dimensionality 20).\n\nJointNets comes with a couple of synthetic and real-world datasets for demonstration purposes.\n\nTo load them, please run:\n``` r\ndata(exampleData)                ## 2 contexts, dimensionality 100\ndata(cancer)                     ## 2 contexts, dimensionality 26\ndata(nip_37_data)                ## 2 contexts, dimensionality 37\ndata(ABIDE_aal116_timeseries)    ## 2 contexts, dimensionality 116\n```\n### Joint Estimation\n```simule```, ```fasjem```, ```wsimule``` and ```jeek``` are intended for joint estimation from **multiple** contexts.\n\nTake ```simule``` as an example.\n\nFirst load a dataset:\n``` r\ndata(nip_37_data)\n```\n\nThen simply run the function ```simule```:\n``` r\nresult = simule(\n  X = nip_37_data,\n  lambda = 0.13,\n  epsilon = 0.5,\n  covType = \"kendall\",\n  parallel = TRUE\n)\n```\n\nThe estimator ```simule``` will return to ```result``` a ```list``` of named elements:\n* ```result$graphs```\n  * a ```list``` of graphs for each context (in the format of covariance/correlation matrices)\n  * In this example, ```result$graphs``` is a list of two matrices of size 37x37\n* ```result$share```\n  * shared graph (in the format of covariance/correlation matrices) among multiple contexts\n  * In this example, ```result$share``` is a matrix of size 37x37\n  * ```$share``` is ```NULL``` for ```jeek``` and ```fasjem``` (They do not explicitly estimate for shared graph among contexts. For more details please read [FASJEM](https://arxiv.org/abs/1702.02715) and[JEEK](https://arxiv.org/abs/1806.00548))\n\nTo learn about the parameters for each estimator, please try run ```?``` followed by the estimator name in the R console:\n``` r\n?simule\n?wsimule\n?jeek\n?fasjem\n```\n\n### Difference Estimation\n`diffee` and `diffeek` are intended for difference estimation from **two** contexts.\n\nTake `diffee` as an example.\n\nFirst load a dataset:\n``` r\ndata(nip_37_data)\n```\n\nThen simply run the function ```diffee```:\n``` r\nresult = diffee(C = nip_37_data[[1]], D = nip_37_data[[2]] , lambda = 0.0035))\n```\n\nThe estimator ```diffee``` will return to ```result``` a ```list``` of named elements:\n* ```result$graphs```\n  * a ```list``` of the difference graph between two contexts (in the format of covariance/correlation matrix)\n  * In this example, ```result$graphs``` is a list of a **single** matrix of size 37x37\n* ```result$share```\n  * `NULL`\n  * Difference estimation doesn't produce shared graph among contexts. For more details please read [diffee](https://arxiv.org/abs/1710.11223)\n\nTo learn about the parameters for each estimator, please run ```?``` followed by the estimator name in the R console:\n``` r\n?diffee\n?diffeek\n```\n\n\n## Visualization\nJointNets provides a general purpose ```plot``` function as well as a specialized ```plotbrain``` for 3d brain graph visualization.\n\n`plot` and `plotbrain` are intended for results produced by any of the JointNets estimators.\n\n### plot\nTake the result from `simule` estimator as an example.\n\nFirst, produce a graph estimation:\n``` r\ndata(nip_37_data)\nresult = simule(\n  X = nip_37_data,\n  lambda = 0.13,\n  epsilon = 0.5,\n  covType = \"kendall\",\n  parallel = TRUE\n)\n```\n\nThen simply run `plot` on `result`. It will plot all graphs from the joint estimation with a descriptive title as well as color legend to distinguish between different contents/tasks.\n``` r\nplot(result)\n```\n\n\n\n`plot` extends `plot.igraph` from the [igraph](https://CRAN.R-project.org/package=igraph) package\nand there are a lot of options to view and manipulate the graph visualization.\n\nFor example:\n``` r\ngraph = returngraph(result)                                       ## get the graph from result\nlayout = layout_nicely(graph, dim = 2)                            ## produce a layout from graph\n\n## plot task specific graph from context 1 using layout\nplot(result, type = \"taskspecific\", subID = 1, layout = layout)\n\nnodeid = which(label %in% c(\"data\", \"probability\"))               ## obtain node id for data and probability\n\n## Zoom into the plot at nodes data and probability using the same layout\nplot(result, type = \"neighbour\", index = nodeid, layout = layout)\n```\n\nSince estimators in JointNets produce two types of estimation (difference and multiple), plot takes in slightly different parameters for each estimation.\n\nFor more details on the parameters in `plot`, please run ```?plot.``` followed by the estimator name in the R console.\n\nFor example:\n``` r\n?plot.simule\n```\n\n### plotbrain\n`plorbrain` is similar to `plot` but instead plots graph in 3d with a brain background as reference.\n\nPlease try `demo(brain)` or `?plotbrain.` followed by the estimator name to learn the function.\n\n### Demo\nJointNets provides demos for various estimators and visualization options.\n\nPlease try `demo()` with the estimator name. (eg, `demo(simule)`)\n\n\n### Sample plots\n\u003cimg src=\"JN_demo.png\" width=\"400\"\u003e\n\u003cimg src=\"JN_brain.png\" width=\"400\"\u003e\n\n## Simulation and Evaluation\nJointNets offers both a simulation and evaluation module for users to produce synthetic graphs and datasets and evaluate the effectiveness of the estimators based on the simulated ground truth.\n\n### Simulation\nSimulating sparse Gaussian graphical models (in the format of covariance/correlation matrix) as well as generating samples from the same graphical models are encapsulated in a single function `simulation`.\n\nTo simulate **3** related sparse Gaussian graphical models of dimensionality **20** and at the same time generate **100** slices of samples for each context:\n``` r\n## s and ss control sparsity of all graphs and shared graph, respectively\nsimulationresult = simulation(p = 20, n=c(100,100,100), seedNum = 37, s = 0.1, ss = 0.1)\n```\nThe function ```simulation``` will return to ```simulationresult``` a ```list``` of named elements:\n* ```$simulatedgraphs```\n  * a ```list``` of named elements `$graphs` and `$share`\n    * `$graphs` is a list of simulated graphs (in the format of covariance and correlation matrices)\n    * `$share` is the shared graph among all contexts\n* ```$simulatedsamples```\n  * a `list` of data matrices\n\nTo access graphs and samples from `simulationresult`:\n``` r\nsimulationresult$simulatedgraphs$graphs   ## access graphs\nsimulationresult$simulatedgraphs$share    ## access shared graph\nsimulationresult$simulatedsamples         ## access generated samples\n```\n### Evaluation\nJointNets offers three score-based metrics for graphical model estimation evaluation: `F1`, `BIC` and `AUC`.\n#### F1\nTo calculate F1 score from the estimation result obtained by `simule` and the ground truth:\n``` r\ntruth = simulationresult$simulatedgraphs\nresult = simule(simulationresult$simulatedsamples, 0.2, 0.5, covType = \"cov\", TRUE)\nF1(result,truth)\n```\n`F1` returns a list of scores for each graph and shared graph (if applicable).\n\n#### BIC\nTo obtain BIC score from the estimation result obtained by `simule` and the simulated samples:\n\n``` r\nBIC(simulationresult$simulatedsamples,result)\n```\n\n`BIC` returns a single score for the entire estimation (currently not support for difference estimation)\n\n#### AUC\nTo compute AUC score for a sequence of estimations with varying lambdas:\n\n``` r\nAUC_result = AUC(simulationresult, gm_method = \"simule\", lambdas = seq(0.1,2,0.05), epsilon = 1)\nAUC_result$auc\n```\n`AUC` returns a list of named elements:\n* `$auc`: AUC score for the sequence of estimation\n* `$fPM`: A list of False Positive Rates for each estimation\n* `$tPM`: A list of True Positive Rates for each estimation\n\nIt is also possible to plot the ROC curve from `AUC_result`:\n\n``` r\nplot(AUC_result$fPM,AUC_result$tPM, xlab = \"False Positive Rate\", ylab = \"True Positive Rate\", main = \"ROC\")\nlines(AUC_result$fPM[order(AUC_result$fPM)], AUC_result$tPM[order(AUC_result$fPM)], xlim=range(AUC_result$fPM), ylim=range(AUC_result$tPM))\n```\n\n\n### Demo\nFor information on using different scores functions, please try one the following:\n``` r\n?F1\n?BIC\n?AUC\n```\nFor more details on simulation and evaluation for various estimators in JointNets, please try:\n``` r\ndemo(evaluation)\n```\n## GUI\nJointNets also offers a simple GUI built in shiny for easy graph exploration.\n\nTo invoke the GUI:\n``` r\nplot_gui()\n```\n\u003cimg src=\"JN_GUI.PNG\" width=\"1000\"\u003e\n\nFor more details on how to use `plot_gui`, please try:\n``` r\n?plot_gui\n```\n\n\n# Getting Help\n\nPlease [open an issue](https://github.com/QData/JointNets/issues) here on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqdata%2Fjointnets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqdata%2Fjointnets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqdata%2Fjointnets/lists"}