Skip to content

Commit

Permalink
v0.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gagolews committed Dec 26, 2020
1 parent a8c62f8 commit 396162c
Show file tree
Hide file tree
Showing 35 changed files with 99 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install libcurl4-openssl-dev python3-rpy2 libmlpack-dev r-base-dev python3-dev pandoc
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'devtools', 'testthat', 'emstreeR', 'knitr'))"
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'devtools', 'tinytest', 'emstreeR', 'knitr'))"
sudo Rscript -e "devtools::install_github('gagolews/Rd2rst')"
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt --upgrade; fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install libcurl4-openssl-dev python3-rpy2 libmlpack-dev r-base-dev
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'devtools', 'testthat', 'emstreeR'))"
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'devtools', 'tinytest', 'emstreeR'))"
- name: Test and check R
run: |
sudo make r-test
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ cache-*
coverage.xml
.coverage
htmlcov

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: genieclust
Type: Package
Title: The Genie++ Hierarchical Clustering Algorithm with Noise Points Detection
Version: 0.9.5
Date: 2020-09-23
Date: 2020-12-26
Authors@R: c(
person("Marek", "Gagolewski",
role = c("aut", "cre", "cph"),
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ r-check: r
Rscript -e 'devtools::check(cran=TRUE, remote=TRUE, manual=TRUE)'

r-test: r
Rscript -e 'options(width=120); source("devel/testthat.R")'

Rscript -e 'options(width=120); source("devel/tinytest.R")'

r-build:
Rscript -e 'Rcpp::compileAttributes()'
Expand Down
6 changes: 5 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# `genieclust` Package NEWS


## genieclust 0.9.5 (under development)
## genieclust 0.9.5 (2020-12-26)

- [Python] `nmslib` is now required.

- [R] switched to `tinytest` for unit testing.

- [R] fixed the examples that relied on a now-changed API of `emstreeR`.


## genieclust 0.9.4 (2020-07-31)

Expand Down
4 changes: 2 additions & 2 deletions R/mst.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ emst_mlpack <- function(X, verbose=FALSE)
if (requireNamespace("emstreeR", quietly=TRUE)) {

if (!verbose)
capture.output({mst <- emstreeR::mlpack_mst(X)})
capture.output({mst <- emstreeR:::mlpack_mst(X)})
else
mst <- emstreeR::mlpack_mst(X)
mst <- emstreeR:::mlpack_mst(X)

structure(t(mst),
class="mst",
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ difficult-to-set `eps` parameter.
Author and Contributors
-----------------------

Author and Maintainer: `Marek Gagolewski <https://www.gagolewski.com>`_
Author and maintainer: `Marek Gagolewski <https://www.gagolewski.com>`_

Contributors of the code from the original R package `genie`:
`Anna Cena <https://cena.rexamine.com>`_,
Expand Down
18 changes: 13 additions & 5 deletions devel/sandbox_scanpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
import scanpy as sc
sc.set_figure_params(dpi=100)
ad = sc.datasets.pbmc3k()

sc.pp.filter_genes(ad, min_cells=10)
ad.layers['counts'] = ad.X.copy()
sc.pp.normalize_total(ad, target_sum=10000)
sc.pp.log1p(ad)
sc.pp.highly_variable_genes(ad, n_top_genes=1000, flavor='seurat_v3', subset=True, layer='counts')
sc.pp.scale(ad, max_value=8)
sc.pp.pca(ad)

sc.pp.neighbors(ad)

sc.tl.umap(ad)

sc.tl.louvain(ad, resolution=0.2)

X_hidim = ad.X
Expand All @@ -30,7 +31,7 @@
import genieclust
import numpy as np

g = genieclust.Genie(n_clusters=3, affinity='cosine')
g = genieclust.Genie(n_clusters=4, affinity='cosine', M=25, postprocess="all")
labels = g.fit_predict(X_hidim)
ad.obs['genie_labels'] = labels.astype(str)
sc.pl.umap(ad, color='genie_labels')
Expand All @@ -43,12 +44,12 @@
sc.pl.umap(ad, color='louvain')


mst = genieclust.internal.mst_from_distance(X_hidim, 'cosine')
mst = genieclust.internal.mst_from_distance(X_hidim)
genieclust.plots.plot_segments(mst[1], ad.obsm["X_umap"])


X_hidim_std = (X_hidim-X_hidim.mean(axis=0))/(X_hidim.std(axis=0))
g = genieclust.Genie(n_clusters=3, affinity='cosine', M=5, postprocess="merge")
X_hidim_std = (X_hidim-X_hidim.mean(axis=0))/(X_hidim.std(axis=0, ddof=1))
g = genieclust.Genie(n_clusters=3)
labels = g.fit_predict(X_hidim_std)
ad.obs['genie_labels_std'] = labels.astype(str)
sc.pl.umap(ad, color='genie_labels_std')
Expand All @@ -63,3 +64,10 @@
#sc.pl.umap(ad, color='genie_labels')
genieclust.plots.plot_segments(mst[1], ad.obsm["X_umap"])


from sklearn.decomposition import PCA
g = genieclust.Genie(n_clusters=3)
labels = g.fit_predict(PCA(20).fit_transform(X_hidim))
ad.obs['genie_labels'] = labels.astype(str)
sc.pl.umap(ad, color='genie_labels')

2 changes: 2 additions & 0 deletions devel/sphinx/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
`genieclust`: Fast and Robust Hierarchical Clustering with Noise Point Detection
================================================================================



**Genie finds meaningful clusters and is fast even on large data sets.**

-- by `Marek Gagolewski <https://www.gagolewski.com/>`_
Expand Down
1 change: 0 additions & 1 deletion devel/sphinx/rapi/comparing_partitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ Examples
adjusted_mi_score(y_true, y_pred)
normalized_accuracy(y_true, y_pred)
pair_sets_index(y_true, y_pred)
1 change: 0 additions & 1 deletion devel/sphinx/rapi/gclust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,3 @@ Examples
# Fast for low-dimensional Euclidean spaces:
if (require("emstreeR")) h <- gclust(emst_mlpack(X))
7 changes: 3 additions & 4 deletions devel/sphinx/rapi/inequity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Usage
Arguments
~~~~~~~~~

+-------+---------------------------------------+
| ``x`` | numeric vector of non-negative values |
+-------+---------------------------------------+
===== =====================================
``x`` numeric vector of non-negative values
===== =====================================

Details
~~~~~~~
Expand Down Expand Up @@ -72,4 +72,3 @@ Examples
bonferroni_index(c(0, 0, 10, 0, 0))
bonferroni_index(c(7, 0, 3, 0, 0))
bonferroni_index(c(6, 0, 3, 1, 0))
1 change: 0 additions & 1 deletion devel/sphinx/rapi/mst.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ Examples
data("iris")
X <- iris[1:4]
tree <- mst(X)
4 changes: 0 additions & 4 deletions devel/testthat.R

This file was deleted.

4 changes: 4 additions & 0 deletions devel/tinytest.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set.seed(123)
library("tinytest")
library("genieclust")
run_test_dir("devel/tinytest/")
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
library("testthat")
library("tinytest")
library("genieclust")
context("compare-partitions")

# More thorough tests are performed by pytest

Expand Down
5 changes: 2 additions & 3 deletions devel/testthat/test-gclust.R → devel/tinytest/test-gclust.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
library("testthat")
library("tinytest")
library("genieclust")
context("gclust")


verbose <- FALSE
Expand All @@ -20,7 +19,7 @@ if (require("genie")) {
#for (k in 2:20) expect_equal(adjusted_rand_score(cutree(h1, k), cutree(h2, k)), 1.0)
}

if (require("emstreeR")) {
if (suppressMessages(require("emstreeR"))) {
print(system.time(h2 <- gclust(emst_mlpack(X, verbose=verbose), verbose=verbose)))
#for (k in 2:20) expect_equal(adjusted_rand_score(cutree(h1, k), cutree(h2, k)), 1.0)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library("testthat")
library("tinytest")
library("genieclust")
context("inequity")


# More thorough tests are performed by pytest

Expand Down
4 changes: 2 additions & 2 deletions devel/testthat/test-mst.R → devel/tinytest/test-mst.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library("testthat")
library("tinytest")
library("genieclust")
context("mst")



set.seed(123)
Expand Down
2 changes: 2 additions & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
`genieclust`: Fast and Robust Hierarchical Clustering with Noise Point Detection
================================================================================



**Genie finds meaningful clusters and is fast even on large data sets.**

-- by `Marek Gagolewski <https://www.gagolewski.com/>`_
Expand Down
1 change: 0 additions & 1 deletion docs/_sources/rapi/comparing_partitions.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ Examples
adjusted_mi_score(y_true, y_pred)
normalized_accuracy(y_true, y_pred)
pair_sets_index(y_true, y_pred)
1 change: 0 additions & 1 deletion docs/_sources/rapi/gclust.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,3 @@ Examples
# Fast for low-dimensional Euclidean spaces:
if (require("emstreeR")) h <- gclust(emst_mlpack(X))
7 changes: 3 additions & 4 deletions docs/_sources/rapi/inequity.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Usage
Arguments
~~~~~~~~~

+-------+---------------------------------------+
| ``x`` | numeric vector of non-negative values |
+-------+---------------------------------------+
===== =====================================
``x`` numeric vector of non-negative values
===== =====================================

Details
~~~~~~~
Expand Down Expand Up @@ -72,4 +72,3 @@ Examples
bonferroni_index(c(0, 0, 10, 0, 0))
bonferroni_index(c(7, 0, 3, 0, 0))
bonferroni_index(c(6, 0, 3, 1, 0))
1 change: 0 additions & 1 deletion docs/_sources/rapi/mst.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ Examples
data("iris")
X <- iris[1:4]
tree <- mst(X)
Loading

0 comments on commit 396162c

Please sign in to comment.