xswap
Python library (C++ backend) for degree-preserving network randomization
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 3 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.1%) to scientific vocabulary
Keywords
Repository
Python library (C++ backend) for degree-preserving network randomization
Basic Info
- Host: GitHub
- Owner: hetio
- License: bsd-2-clause
- Language: C
- Default Branch: master
- Homepage: https://hetio.github.io/xswap/
- Size: 1.06 MB
Statistics
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 4
- Releases: 0
Topics
Metadata Files
README.md
XSwap: Fast degree-preserving network permutation
Full documentation: https://hetio.github.io/xswap/
XSwap is an algorithm for degree-preserving network randomization (permutation) [1].
Permuted networks can be used for a number of purposes in network analysis, including for generating counterfactual distributions of features when only the network's degree sequence is maintained or for computing a prior probability of an edge given only the network's degree sequence.
Overall, permuted networks allow one to quantify the effects of degree on analysis and prediction methods.
Understanding this effect is useful when a network's degree sequence is subject to biases.
This implementation is a modified version of the algorithm due to Hanhijärvi et al. with two additional parameters (allow_self_loops and allow_antiparallel), which enable greater generalizability to bipartite, directed, and undirected networks.
- Randomization Techniques for Graphs
Sami Hanhijärvi, Gemma C. Garriga, Kai Puolamäki
Proceedings of the 2009 SIAM International Conference on Data Mining (2009-04-30) https://doi.org/f3mn58
DOI: 10.1137/1.9781611972795.67
Usage examples
Permuting an edge list
```python
edges = [(0, 1), (1, 0)] permutededges, permutationstatistics = xswap.permuteedgelist( edges, allowselfloops=True, allowantiparallel=True, multiplier=10) permutededges [(0, 0), (1, 1)] permutationstatistics {'swapattempts': 20, 'sameedge': 10, 'selfloop': 0, 'duplicate': 1, 'undir_duplicate': 0, 'excluded': 0} ```
Computing degree-sequence based prior probabilities of edges existing
```python
edges = [(0, 1), (1, 0)] priorprobdf = xswap.prior.computexswappriors( edges, npermutations=10000, shape=(2, 2), allowselfloops=True, allowantiparallel=True) priorprobdf sourceid targetid edge sourcedegree targetdegree xswap_prior 0 0 0 False 1 1 0.5 1 0 1 True 1 1 0.5 2 1 0 True 1 1 0.5 3 1 1 False 1 1 0.5 ```
Choice of parameters
Bipartite networks
Bipartite networks should be indexed using the bi-adjacency matrix, meaning that the edge (0, 0) is from source node 0 to target node 0, and is not a self-loop.
Moreover, bipartite networks should be permuted using allow_self_loops=False and allow_antiparallel=True.
Directed and undirected networks
For non-bipartite networks, the decisions of allow_self_loops and allow_antiparallel are not always the same.
For undirected networks, set allow_antiparallel=False, as otherwise the edges (1, 0) and (0, 1), which represent the same edge, will be treated as separate.
Antiparallel edges may or may not be allowed for directed networks, depending on context.
Similarly, self-loops may or may not be allowed for directed or undirected networks, depending on the specific network being permuted.
Libraries
The XSwap library includes Roaring Bitmaps, available under the Apache 2.0 license.
Acknowledgments
Development of this project has largely taken place in the Greene Lab at the University of Pennsylvania. As an open source project under the hetio organization, this repository is grateful for its community of maintainers, contributors, and users.
This work is funded in part by the Gordon and Betty Moore Foundation’s Data-Driven Discovery Initiative through Grants GBMF4552 to Casey Greene, GBMF4560 to Blair Sullivan, and the National Institutes of Health’s National Human Genome Research Institute R01 HG010067.
Owner
- Name: Hetnets in Biomedicine
- Login: hetio
- Kind: organization
- Website: https://het.io
- Repositories: 9
- Profile: https://github.com/hetio
Repositories for hetnet-related research, tools, and datasets including Hetionet. By the teams of @dhimmel, @greenelab, & @sebaran
GitHub Events
Total
- Watch event: 2
Last Year
- Watch event: 2
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 7
- Total pull requests: 21
- Average time to close issues: 4 days
- Average time to close pull requests: 8 days
- Total issue authors: 3
- Total pull request authors: 2
- Average comments per issue: 1.57
- Average comments per pull request: 0.81
- Merged pull requests: 19
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- dhimmel (4)
- zietzm (2)
- vincerubinetti (1)
Pull Request Authors
- zietzm (19)
- dhimmel (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- numpy * test
- pandas * test
- pytest * test
- requests * test
- scipy * test
- setuptools * test