kharchenkolab / leidenalg Goto Github PK
View Code? Open in Web Editor NEWImplements the Leiden algorithm via an R interface
Implements the Leiden algorithm via an R interface
How about making it broader and including all communities from Conos here? I'm a particularly big fan of the rleiden
community.
Hi!
I have run leidenAlg::leiden.community()
on the exact same graph g
and with identical seeds on Windows and on Linux and the results differ. Is there a known reason (and maybe even fix) for this?
Cheers,
Marie
Code:
set.seed(168575)
partition <- leidenAlg::leiden.community(graph = g, n.iterations = 50)
Expected behaviour: partition is the same when running code on Windows and Linux.
Observed behaviour: partition is different.
hi,
Sorry to interrupt you,but i ran into a issue when i run this code in R:
mini_visium <- doLeidenCluster(gobject = mini_visium,
resolution = 0.4, n_iterations = 1000)
a problem occurs :
Error in py_run_file_impl(file, local, convert) :
ModuleNotFoundError: No module named 'leidenalg'
Detailed traceback:
File "", line 10, in
File "D:\Win10 System\Documents\R\win-library\4.1\reticulate\python\rpytools\loader.py", line 44, in _import_hook
level=level
And using conda, i found this: leidenalg is there!!!
And then i tried this : Although leidenalg , pandas AND pillow is in my evrironment,but only pandas could be uesed.
Could you please help sovle this problem?
Hi @evanbiederstedt ,
I'm trying to install leidenAlg on R-4.1.2 (libxml2, glpk and gmp are installed). Compilation goes fine, but the last step returns
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘leidenAlg’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/vpetukhov/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-leidenAlg/00new/leidenAlg/libs/leidenAlg.so':
/home/vpetukhov/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-leidenAlg/00new/leidenAlg/libs/leidenAlg.so: undefined symbol: igraph_rngtype_mt19937
The same result goes on my local laptop with Gentoo and on a server with RedHat 8. Do you have any idea how to debug this?
If I run devtools::load_all()
, I can check the compilation files. Then, nm -D /tmp/Rtmpxafa69/pkgload32db541a1f34/leidenAlg.so
shows that there is indeed a symbol U igraph_rngtype_mt19937
.
And output of ldd /tmp/Rtmpxafa69/pkgload32db541a1f34/leidenAlg.so
is the following:
linux-vdso.so.1 (0x00007ffcac358000)
libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/libstdc++.so.6 (0x00007f9fa16b8000)
libm.so.6 => /lib64/libm.so.6 (0x00007f9fa15e4000)
libR.so => /usr/lib64/R/lib/libR.so (0x00007f9fa10d1000)
libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/libgcc_s.so.1 (0x00007f9fa10b6000)
libc.so.6 => /lib64/libc.so.6 (0x00007f9fa0ec3000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9fa1933000)
libblas.so.3 => /usr/lib64/libblas.so.3 (0x00007f9fa0e1e000)
libreadline.so.8 => /lib64/libreadline.so.8 (0x00007f9fa0dc3000)
libpcre2-8.so.0 => /usr/lib64/libpcre2-8.so.0 (0x00007f9fa0d26000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f9fa0cfb000)
libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f9fa0ce2000)
libz.so.1 => /lib64/libz.so.1 (0x00007f9fa0cc4000)
libtirpc.so.3 => /lib64/libtirpc.so.3 (0x00007f9fa0c9b000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f9fa0c94000)
libicuuc.so.69 => /usr/lib64/libicuuc.so.69 (0x00007f9fa0a86000)
libicui18n.so.69 => /usr/lib64/libicui18n.so.69 (0x00007f9fa0744000)
libgomp.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/libgomp.so.1 (0x00007f9fa0702000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f9fa06fd000)
libgfortran.so.5 => /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/libgfortran.so.5 (0x00007f9fa0441000)
libtinfow.so.6 => /lib64/libtinfow.so.6 (0x00007f9fa03f6000)
libicudata.so.69 => /usr/lib64/libicudata.so.69 (0x00007f9f9e89b000)
libquadmath.so.0 => /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/libquadmath.so.0 (0x00007f9f9e851000)
I tried to randomly tweak Makevars with no success.
Hi,
I've been using the rleiden.community() function for clustering detection. However, I've noticed that when I run the same analysis multiple times, results tend to change. I also tried to set a seed, but even with the same seed results change.
Do you have any suggestion on how to prevent this behavior and make results reproducible?
Thank you.
Hi, hanks for this great package! I cant seem to install it on a Mac though. Here is the sessionInfo and the errors.
sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_1.2.6 Matrix_1.3-3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lattice_0.20-44 png_0.1-7 shinyWidgets_0.6.0 assertthat_0.2.1 rprojroot_2.0.2
[7] digest_0.6.27 utf8_1.2.1 mime_0.10 R6_2.5.0 plyr_1.8.6 evaluate_0.14
[13] ggplot2_3.3.3 pillar_1.6.0 rlang_0.4.11 sortable_0.4.4 jquerylib_0.1.4 learnr_0.10.1
[19] sccore_0.1.3 reticulate_1.20 grr_0.9.5 rmarkdown_2.8 stringr_1.4.0 htmlwidgets_1.5.3
[25] munsell_0.5.0 tinytex_0.31 shiny_1.6.0 compiler_4.0.5 httpuv_1.6.1 xfun_0.22
[31] pkgconfig_2.0.3 clipr_0.7.1 htmltools_0.5.1.1 tidyselect_1.1.1 tibble_3.1.1 gridExtra_2.3
[37] dendextend_1.15.1 fansi_0.4.2 viridisLite_0.4.0 withr_2.4.2 crayon_1.4.1 dplyr_1.0.6
[43] later_1.2.0 Matrix.utils_0.9.8 grid_4.0.5 jsonlite_1.7.2 xtable_1.8-4 gtable_0.3.0
[49] lifecycle_1.0.0 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1 stringi_1.5.3 reshape2_1.4.4
[55] viridis_0.6.1 promises_1.2.0.1 bslib_0.2.4 ellipsis_0.3.2 generics_0.1.0 vctrs_0.3.8
[61] RColorBrewer_1.1-2 tools_4.0.5 glue_1.4.2 markdown_1.1 purrr_0.3.4 shinycssloaders_1.0.0
[67] parallel_4.0.5 fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-1 knitr_1.33 sass_0.3.1
library(leidenAlg)
Loading required package: Matrix
Loading required package: igraph
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
Error: package or namespace load failed for ‘leidenAlg’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg/libs/leidenAlg.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg/libs/leidenAlg.so, 6): Library not loaded: @rpath/igraph.so
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/leidenAlg/libs/leidenAlg.so
Reason: image not found
devtools::install_github('kharchenkolab/leidenAlg', build_vignettes = TRUE)
Downloading GitHub repo kharchenkolab/leidenAlg@HEAD
✓ checking for file ‘/private/var/folders/sy/gp7_zd0918j429vrk56lxvgw0000gn/T/RtmpOElSu6/remotes5c113b358a16/kharchenkolab-leidenAlg-0db1cdf/DESCRIPTION’ ...
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -o leidenAlg.so RcppExports.o leiden.o -L/usr/lib/ -L. -lpthread -lstdc++ -lleidenalg -lm -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm /Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph/libs/igraph.so -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
ld: warning: directory not found for option '-L/usr/local/opt/gettext/lib'
ld: warning: directory not found for option '-L/usr/local/opt/llvm/lib'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [leidenAlg.so] Error 1
ERROR: compilation failed for package ‘leidenAlg’
Thanks for any and all help!
Best
Hi, I am having issues installing leidenAlg in a conda environment on macOS. The installation is looking for an igraph.so file where only igraph.dylib is available, since I'm on macOS.
I also looked at #5, but all mentioned dependencies are installed within the conda environment.
Can you maybe help out?
Support is much appreciated.
> install.packages('leidenAlg')
...
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
clang-12: error: no such file or directory: '/.../miniconda3/envs/scib-R/lib/R/library/igraph/libs/igraph.so'
make: *** [/.../miniconda3/envs/scib-R/lib/R/share/make/shlib.mk:6: leidenAlg.dylib] Error 1
ERROR: compilation failed for package ‘leidenAlg’
* removing ‘/.../miniconda3/envs/scib-R/lib/R/library/leidenAlg’
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS/LAPACK: /.../miniconda3/envs/scib-R/lib/R/lib/libRblas.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_1.2.9
I'm experimenting the leidenalg community detection and have noticed that weights is not affecting the results? also i have inverted weights to double check and still, weights not doing a noticeable impact on the results. my cods:
optimiser = la.Optimiser()
optimiser.set_rng_seed(0)
partitions = la.ModularityVertexPartition(g, weights='weights')
diff = 1
_ = datetime.datetime.now().timestamp()
while diff > 0 and (datetime.datetime.now().timestamp() - _) < 30:
diff = optimiser.optimise_partition(partitions)
My question is: am I missing something?
Dear team,
I am trying to run infercnv which runs well till it gets to the step when it needs leidenalg. I installed leidenalg via pip install and it is installed but I consistently get an ImportError that leidenalg module is not found. So , I installed leindenAlg and loaded it successfully in R but I am still getting the same error that R can't see the package?.
Any suggestions from your side, please?.
I have asked leidenalg team and infercnv as well
Thanks
We're changing the layout of igraph objects. This leads to check failures in your package, see https://github.com/igraph/rigraph/blob/f-igraph-t-idx-revdepcheck/revdep/problems.md and igraph/rigraph#789 for details.
To reproduce, please install the development version of igraph via
# install.packages("pak")
pak::pak("igraph/rigraph")
and run R CMD check
on your package.
We plan to release an igraph update on June 12, two weeks from now. Can you please send an update to CRAN that fixes the checks?
This package seems to use its own copy of igraph. The error happens in R_SEXP_to_igraph()
which still assumes the old format. Please retrieve an edgelist on the R side and construct your igraph object on the C/C++ side.
Happy to help.
Hi
I have some problems loading the package. The following error message appears:
`The following object is masked from ‘package:base’:
union
Error: package or namespace load failed for ‘leidenAlg’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/leidenAlg/libs/leidenAlg.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/leidenAlg/libs/leidenAlg.so, 6): Library not loaded: @rpath/igraph.so
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/leidenAlg/libs/leidenAlg.so
Reason: image not found`
R. Version()
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 6.2
year 2019
month 12
day 12
svn rev 77560
language R
version.string R version 3.6.2 (2019-12-12)
nickname Dark and Stormy Night
Any tips?
In the leiden.cpp source code, can we add another level of for loop to run it multiple times with the random number being updated? and after the while loop ends, access the quality or modularity so we can finally pick the best result. This is something that Seurat's louvain implementation has and I figured this should also be helpful for running Leiden.
Thanks,
Yichen
When supplying an unweighted graph (for example, the output of igraph::graph_from_adj_list
) I get:
Error in find_partition(graph, igraph::E(graph)$weight, resolution, n.iterations) :
Not compatible with requested type: [type=NULL; target=double].
This is fixed if I manually set all weights to 1. It would be nice if this were the default behavior for unweighted graphs. Otherwise great implementation!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.