Comments (2)
Sorry for the late response.
Here's an example, you can subset the data using the "igraph" package. Personally I use a custom plotting function plot_directed
that I developed in R. You can install it on CRAN from the graphsim package. If you want to pass graph objects to other software such as Cytoscape I'm sure that igraph objects are supported for this:
http://cytoscape.org/RCy3/reference/createNetworkFromIgraph.html
https://www.bioconductor.org/packages/release/bioc/vignettes/RCy3/inst/doc/Cytoscape-and-iGraph.html
The resolution parameter depends on your cost function. It's documented in more detail in the Python version. Resolution profiling is not support in R currently.
https://leidenalg.readthedocs.io/en/stable/advanced.html?highlight=resolution#resolution-profile
library("leiden")
#> conda environment r-reticulate installed
#> python modules igraph and leidenalg installed
library("reticulate")
library("igraph")
#>
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#>
#> decompose, spectrum
#> The following object is masked from 'package:base':
#>
#> union
set.seed(9000)
adj_mat <- matrix(round(runif(10000, 0, 1)), 100, 100)
snn_graph <- graph_from_adjacency_matrix(adj_mat)
partition <- leiden(snn_graph)
partition
#> [1] 3 1 1 3 1 2 1 2 4 1 1 1 2 3 3 1 1 2 3 3 1 2 3 4 1 4 2 4 1 2 4 4 3 3 1 1 4
#> [38] 2 4 1 2 1 1 2 2 1 2 3 2 3 2 2 1 2 2 1 3 3 3 1 2 1 3 1 2 3 4 2 3 2 4 4 1 3
#> [75] 2 1 3 1 2 2 1 1 3 1 4 4 4 3 3 1 1 3 2 1 1 1 2 2 3 1
table(partition)
#> partition
#> 1 2 3 4
#> 35 27 24 14
module_1 <- subgraph(snn_graph, V(snn_graph)[partition == 1])
#> Warning in subgraph(snn_graph, V(snn_graph)[partition == 1]): At
#> structural_properties.c:2051 :igraph_subgraph is deprecated from igraph 0.6, use
#> igraph_induced_subgraph instead
module_1 <- induced_subgraph(snn_graph, V(snn_graph)[partition == 1])
module_1
#> IGRAPH 1b6f683 D--- 35 710 --
#> + edges from 1b6f683:
#> [1] 1-> 1 1-> 2 1-> 6 1-> 7 1-> 8 1-> 9 1->10 1->11 1->12 1->13 1->14 1->15
#> [13] 1->18 1->19 1->20 1->23 1->25 1->26 1->28 1->29 1->32 2-> 1 2-> 3 2-> 4
#> [25] 2-> 5 2-> 6 2-> 7 2-> 8 2->10 2->11 2->14 2->18 2->20 2->27 2->28 2->29
#> [37] 2->32 2->33 2->34 2->35 3-> 2 3-> 3 3-> 4 3-> 5 3-> 8 3->10 3->14 3->16
#> [49] 3->17 3->20 3->21 3->23 3->24 3->27 3->30 3->32 3->33 3->35 4-> 2 4-> 3
#> [61] 4-> 4 4-> 5 4-> 6 4->11 4->12 4->13 4->15 4->16 4->17 4->18 4->19 4->27
#> [73] 4->28 4->31 4->32 4->33 4->34 4->35 5-> 1 5-> 2 5-> 3 5-> 4 5-> 5 5-> 8
#> [85] 5->10 5->11 5->12 5->14 5->17 5->19 5->25 5->26 5->29 5->30 5->31 5->33
#> [97] 5->34 5->35 6-> 1 6-> 3 6-> 4 6-> 8 6->11 6->12 6->15 6->16 6->17 6->20
#> + ... omitted several edges
V(module_1)
#> + 35/35 vertices, from 1b6f683:
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#> [26] 26 27 28 29 30 31 32 33 34 35
plot(module_1)
graphsim::plot_directed(module_1, cex.arrow = 0.75, cex.node = 1.5, col.arrow = "grey50", fill.node = "lightblue")
graphsim::plot_directed(snn_graph, cex.arrow = 0.75, cex.node = 1.5, col.arrow = "grey50",
fill.node = c("lightblue", "grey75")[ifelse(partition==1, 1, 2)])
Created on 2021-03-26 by the reprex package (v0.3.0)
from leiden.
thank you,
I will try this.
from leiden.
Related Issues (20)
- "pandas" error while installing leiden (found what is wrong) HOT 5
- Limitation on the number of cells? HOT 13
- Error installing package HOT 13
- Reproducibility HOT 2
- Error updating package HOT 6
- Error while installing Leiden HOT 1
- Error in installing βleidenβ package HOT 2
- faulty r-reticulate conda environment HOT 10
- Multi_core/thread support HOT 2
- Error in r_to_py_impl(converted, convert = convert)
- install error, invalid pointer HOT 2
- RGL issue HOT 2
- install dependencies error
- Package installation segfault error on CentOS HOT 7
- Support attribute "consider_empty_community" of leidenalg.Optimiser HOT 1
- Installation errors HOT 2
- resolution parameter and number of iteration in leiden R package HOT 1
- Query about "NAs introduced by coercion to integer range" warning
- Leiden consistently unable to correctly identify installed dependencies
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leiden.