Skip to content

Commit 855e801

Browse files
implement calling community_leiden from igraph v1.2.7
2 parents cba1a18 + 326ebde commit 855e801

File tree

14 files changed

+209
-153
lines changed

14 files changed

+209
-153
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
^\ .DS_Store$
2222
revdep
2323
images
24+
lastMiKTeXException
2425

2526
## Files to ignore when building package
2627

@@ -46,3 +47,4 @@ images
4647
^vignettes/bash_py_time$
4748
^revdep$
4849
^aarhus_mplex.rda$
50+
^CRAN-SUBMISSION$

DESCRIPTION

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: leiden
22
Type: Package
33
Title: R Implementation of Leiden Clustering Algorithm
4-
Version: 0.4.1.9001
5-
Date: 2021-07-27
4+
Version: 0.4.2
5+
Date: 2022-05-01
66
Authors@R: c(person("S. Thomas", "Kelly", email = "tomkellygenetics@gmail.com", role = c("aut", "cre", "trl")),
77
person("Vincent A.", "Traag", email = "v.a.traag@cwts.leidenuniv.nl", role = c("com")))
88
Description: Implements the 'Python leidenalg' module to be called in R.
@@ -16,21 +16,20 @@ Imports:
1616
methods,
1717
reticulate,
1818
Matrix,
19-
igraph (> 1.2.6)
19+
igraph (>= 1.2.7)
2020
Encoding: UTF-8
2121
LazyData: false
22-
RoxygenNote: 7.1.1
22+
RoxygenNote: 7.1.2
2323
Suggests:
2424
bipartite,
2525
covr,
2626
data.table,
2727
devtools,
2828
graphsim,
2929
knitr,
30-
multiplex,
31-
multinet,
3230
markdown,
3331
multiplex,
32+
multinet,
3433
network,
3534
RColorBrewer,
3635
remotes,

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ importFrom(igraph,graph_from_adjacency_matrix)
2222
importFrom(igraph,is.igraph)
2323
importFrom(igraph,is_bipartite)
2424
importFrom(igraph,is_directed)
25-
importFrom(igraph,is.named)
25+
importFrom(igraph,is_named)
2626
importFrom(igraph,is_weighted)
2727
importFrom(igraph,laplacian_matrix)
2828
importFrom(igraph,membership)

NEWS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# leiden 0.4.2
2+
3+
* migrates bug fixes to conda environment and limit on total cells to refactored package
4+
5+
* allows calling igraph::community_leiden for supported parameters (requires igraph v1.2.7 or later)
6+
7+
* automatically calls native R version of leiden rather than Python to improve performance
8+
19
# leiden 0.4.1
210

311
* migrates changes to retain on CRAN to leiden 0.4.0 (alpha)
@@ -6,6 +14,23 @@
614

715
* migrate to calling community_leiden in igraph
816

17+
# leiden 0.3.10
18+
19+
* removes limitation on number of cells (disables scientific notation within function call): resolves #12
20+
21+
* resolves conflict between base and r-reticulate conda environments on loading: resolves #20
22+
23+
* updates conda environment in interactive sessions only for compliance to CRAN checks
24+
25+
* resolves formatting error in Rmarkdown vignettes (https://github.com/yihui/knitr/issues/2057)
26+
27+
* update testing for bipartite graphs for compatibility with newer version
28+
29+
# leiden 0.3.9
30+
31+
Updates maintainer contact details.
32+
>>>>>>> master
33+
934
# leiden 0.3.8
1035

1136
* bug fixes for vignettes to retain on CRAN

R/find_partition.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ run_bipartite_partitioning <- function(py_graph,
2222
seed = NULL,
2323
n_iterations = 2L,
2424
max_comm_size = 0L){
25+
# disable printing numerals in scientific notation
26+
oo <- options(scipen = 100000000000)
27+
# restore options when function terminates
28+
on.exit(options(oo))
29+
2530
#import python modules with reticulate
2631
numpy <- import("numpy", delay_load = TRUE)
2732
leidenalg <- import("leidenalg", delay_load = TRUE)
@@ -85,8 +90,12 @@ n_iterations = 2L,
8590
max_comm_size = 0L,
8691
degree_as_node_size = TRUE,
8792
legacy = FALSE
88-
degree_as_node_size = TRUE
8993
) {
94+
# disable printing numerals in scientific notation
95+
oo <- options(scipen = 100000000000)
96+
# restore options when function terminates
97+
on.exit(options(oo))
98+
9099
#import python modules with reticulate
91100
numpy <- import("numpy", delay_load = TRUE)
92101
leidenalg <- import("leidenalg", delay_load = TRUE)
@@ -289,6 +298,11 @@ max_comm_size = 0L,
289298
degree_as_node_size = TRUE,
290299
legacy = FALSE
291300
) {
301+
# disable printing numerals in scientific notation
302+
oo <- options(scipen = 100000000000)
303+
# restore options when function terminates
304+
on.exit(options(oo))
305+
292306
#import python modules with reticulate
293307
numpy <- import("numpy", delay_load = TRUE)
294308
leidenalg <- import("leidenalg", delay_load = TRUE)

R/leiden.R

Lines changed: 129 additions & 90 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Leiden Algorithm
22

3-
## leiden development version 0.4.1
3+
## leiden version 0.4.2
44

55
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/leiden)](https://cran.r-project.org/package=leiden)
66
[![Travis Build Status](https://travis-ci.com/TomKellyGenetics/leiden.svg?branch=master)](https://travis-ci.com/TomKellyGenetics/leiden)
@@ -283,16 +283,16 @@ Please cite this implementation R in if you use it:
283283
```
284284
To cite the leiden package in publications use:
285285
286-
S. Thomas Kelly (2021). leiden: R implementation of the Leiden algorithm. R
287-
package version 0.4.0 https://github.com/TomKellyGenetics/leiden
286+
S. Thomas Kelly (2022). leiden: R implementation of the Leiden algorithm. R
287+
package version 0.4.2 https://github.com/TomKellyGenetics/leiden
288288
289289
A BibTeX entry for LaTeX users is
290290
291291
@Manual{,
292292
title = {leiden: R implementation of the Leiden algorithm},
293293
author = {S. Thomas Kelly},
294-
year = {2021},
295-
note = {R package version 0.4.0},
294+
year = {2022},
295+
note = {R package version 0.4.2},
296296
url = {https://github.com/TomKellyGenetics/leiden},
297297
}
298298
```

cran-comments.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,24 @@
55
* rhub (release) Ubuntu Linux 16.04 LTS, R-release, GCC
66
* Fedora (devel) Linux, R-devel, clang, gfortran
77
* MacOS 10.14.6 R 3.6.1
8-
* MacOS 10.15.7 R 4.1.0
8+
* MacOS 10.15.7 R 4.2.0
99

1010
## R CMD check results
1111

1212
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
1313

1414
## Updates
1515

16-
Changes to vignettes to address the following issue:
16+
Updates calling native R version in igraph v1.2.7 when applicable.
17+
Significant performance improvements are expected without python
18+
dependencies for some parameters.
1719

18-
Specifically, please see the problems for the Debian-based checks for
19-
r-devel.
20-
21-
These are from
22-
23-
\item \code{matrix(x, n, m)} now warns in more cases where
24-
\code{length(x)} differs from than \code{n * m}; suggested by Abby
25-
Spurdle and Wolfgang Huber in Feb 2021 on the R-devel mailing
26-
list.
27-
28-
This warning can be turned into an error by setting environment
29-
variable \env{_R_CHECK_MATRIX_DATA_} to \samp{TRUE}: \command{R
30-
CMD check --as-cran} does so unless it is already set.
31-
32-
in current r-devel, where the Debian-based checks are now performed with
33-
_R_CHECK_MATRIX_DATA_=TRUE.
20+
Breaking changes are possible with the new implementation.
21+
A legacy mode with setting the random seed is supported
22+
to reproduce previous results.
3423

3524
## Python integration
3625

26+
Python is a soft dependency which is still required for some functions but is not essential for core functionality any longer. It is retained for backwards compatibility.
27+
3728
Vignettes are disabled when python is not available. This works on Linux test environments (with python available) and windows test environments (without python or pip packages).

inst/CITATION

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@ citHeader("To cite the leiden package in publications use:")
33
citEntry(entry = "Manual",
44
title = "leiden: R implementation of the Leiden algorithm",
55
author = personList(as.person("S. Thomas Kelly")),
6-
<<<<<<< HEAD
7-
year = "2020",
8-
note = "R package version 0.4.0",
6+
year = "2022",
7+
note = "R package version 0.4.2",
98
url = "https://github.com/TomKellyGenetics/leiden",
109

1110
textVersion =
12-
paste("S. Thomas Kelly (2020). leiden: R implementation of the Leiden algorithm. R package version 0.4.0",
13-
=======
14-
year = "2021",
15-
note = "R package version 0.3.8",
11+
paste("S. Thomas Kelly (2020). leiden: R implementation of the Leiden algorithm. R package version 0.4.2",
12+
year = "2022",
13+
note = "R package version 0.4.2",
1614
url = "https://github.com/TomKellyGenetics/leiden",
17-
18-
textVersion =
19-
paste("S. Thomas Kelly (2021). leiden: R implementation of the Leiden algorithm. R package version 0.3.8",
20-
>>>>>>> master
2115
"https://github.com/TomKellyGenetics/leiden")
2216
)
2317

tests/testthat/test_bipartite.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ skip_if_no_python <- function() {
6363
testthat::skip("leidenalg not available for testing")
6464
}
6565

66-
66+
set.seed(9000)
6767
test_that("run with CPMVertexPartition.Bipartite", {
6868
skip_if_no_python()
6969
partition <- leiden(bipartite_graph,
@@ -78,6 +78,7 @@ test_that("run with CPMVertexPartition.Bipartite", {
7878
bipartite_graph
7979
})
8080

81+
set.seed(9000)
8182
test_that("run with CPMVertexPartition.Bipartite and degree as node size", {
8283
skip_if_no_python()
8384
partition <- leiden(bipartite_graph,
@@ -86,22 +87,23 @@ test_that("run with CPMVertexPartition.Bipartite and degree as node size", {
8687
degree_as_node_size = TRUE,
8788
seed = 9001)
8889
expect_length(partition, length(V(bipartite_graph)))
89-
expect_equal(sort(unique(partition)), c(1, 2))
90+
expect_equal(sort(unique(partition)), c(1, 2, 3, 4))
9091
expect_equal(partition,
91-
c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1,
92-
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2))
92+
c(1, 1, 1, 1, 1, 1, 3, 4, 3, 3, 2, 2, 2, 2, 2, 2, 4, 4, 1, 1,
93+
1, 1, 1, 1, 3, 3, 4, 2, 4, 2, 2, 2))
9394
})
9495

96+
set.seed(9000)
9597
test_that("run with ModularityVertexPartition.Bipartite", {
9698
skip_if_no_python()
9799
partition <- leiden(bipartite_graph,
98100
partition_type = "ModularityVertexPartition.Bipartite",
99101
resolution_parameter = 0.01,
100102
seed = 9001)
101103
expect_length(partition, length(V(bipartite_graph)))
102-
expect_equal(sort(unique(partition)), c(1, 2))
104+
expect_equal(sort(unique(partition)), c(1, 2, 3, 4))
103105
expect_equal(partition,
104-
c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1,
105-
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2))
106+
c(1, 1, 1, 1, 1, 1, 3, 4, 3, 3, 2, 2, 2, 2, 2, 2, 4, 4, 1, 1,
107+
1, 1, 1, 1, 3, 3, 4, 2, 4, 2, 2, 2))
106108
})
107109

0 commit comments

Comments
 (0)