1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
4 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages graph)
23 #:use-module (guix download)
24 #:use-module (guix git-download)
25 #:use-module (guix packages)
26 #:use-module (guix utils)
27 #:use-module (guix build-system cmake)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system python)
30 #:use-module (guix build-system r)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages gcc)
34 #:use-module (gnu packages bioconductor)
35 #:use-module (gnu packages bioinformatics)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages cran)
39 #:use-module (gnu packages graphviz)
40 #:use-module (gnu packages maths)
41 #:use-module (gnu packages multiprecision)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages python-web)
45 #:use-module (gnu packages python-xyz)
46 #:use-module (gnu packages statistics)
47 #:use-module (gnu packages swig)
48 #:use-module (gnu packages time)
49 #:use-module (gnu packages xml))
58 (uri (string-append "http://igraph.org/nightly/get/c/igraph-"
62 "1pxh8sdlirgvbvsw8v65h6prn7hlm45bfsl1yfcgd6rn4w706y6r"))))
63 (build-system gnu-build-system)
66 (list "--with-external-glpk"
67 "--with-external-blas"
68 "--with-external-lapack")))
74 ("openblas" ,openblas)
76 (home-page "http://igraph.org")
77 (synopsis "Network analysis and visualization")
79 "This package provides a library for the analysis of networks and graphs.
80 It can handle large graphs very well and provides functions for generating
81 random and regular graphs, graph visualization, centrality methods and much
83 (license license:gpl2+)))
85 (define-public python-igraph
86 (package (inherit igraph)
87 (name "python-igraph")
88 (version "0.7.1.post6")
92 (uri (pypi-uri "python-igraph" version))
95 "0xp61zz710qlzhmzbfr65d5flvsi8zf2xy78s6rsszh719wl5sm5"))))
96 (build-system python-build-system)
99 `(("igraph" ,igraph)))
101 `(("pkg-config" ,pkg-config)))
102 (home-page "http://pypi.python.org/pypi/python-igraph")
103 (synopsis "Python bindings for the igraph network analysis library")))
105 (define-public r-igraph
112 (uri (cran-uri "igraph" version))
115 "1jwjjl0l4054w05bik17p2d6rj3lx68iv716phajhnbbmckfnj0h"))))
116 (build-system r-build-system)
118 `(("gfortran" ,gfortran)))
125 `(("r-magrittr" ,r-magrittr)
126 ("r-matrix" ,r-matrix)
127 ("r-pkgconfig" ,r-pkgconfig)))
128 (home-page "http://igraph.org")
129 (synopsis "Network analysis and visualization")
131 "This package provides routines for simple graphs and network analysis.
132 It can handle large graphs very well and provides functions for generating
133 random and regular graphs, graph visualization, centrality methods and much
135 (license license:gpl2+)))
137 (define-public r-diffusionmap
139 (name "r-diffusionmap")
144 (uri (cran-uri "diffusionMap" version))
147 "11l4kbciawvli5nlsi4qaf8afmgk5xgqiqpdyhvaqri5mx0zhk5j"))))
148 (properties `((upstream-name . "diffusionMap")))
149 (build-system r-build-system)
151 `(("r-igraph" ,r-igraph)
152 ("r-matrix" ,r-matrix)
153 ("r-scatterplot3d" ,r-scatterplot3d)))
154 (home-page "https://www.r-project.org")
155 (synopsis "Diffusion map")
156 (description "This package implements the diffusion map method of data
157 parametrization, including creation and visualization of diffusion maps,
158 clustering with diffusion K-means and regression using the adaptive regression
160 (license license:gpl2)))
162 (define-public r-rgraphviz
169 (uri (bioconductor-uri "Rgraphviz" version))
172 "0bp6517xsih0wng2rgkh9z4r1afqhwl3h04z6ssm7p4cdj0ahm4y"))))
173 (properties `((upstream-name . "Rgraphviz")))
174 (build-system r-build-system)
175 ;; FIXME: Rgraphviz bundles the sources of an older variant of
176 ;; graphviz. It does not build with the latest version of graphviz, so
177 ;; we do not add graphviz to the inputs.
178 (inputs `(("zlib" ,zlib)))
180 `(("r-graph" ,r-graph)))
182 `(("pkg-config" ,pkg-config)))
183 (home-page "http://bioconductor.org/packages/Rgraphviz")
184 (synopsis "Plotting capabilities for R graph objects")
186 "This package interfaces R with the graphviz library for plotting R graph
187 objects from the @code{graph} package.")
188 (license license:epl1.0)))
190 (define-public r-rbiofabric
191 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
194 (name "r-rbiofabric")
195 (version (string-append "0.3-" revision "." (string-take commit 7)))
199 (url "https://github.com/wjrl/RBioFabric.git")
201 (file-name (string-append name "-" version "-checkout"))
204 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
205 (build-system r-build-system)
207 `(("r-igraph" ,r-igraph)))
208 (home-page "http://www.biofabric.org/")
209 (synopsis "BioFabric network visualization")
210 (description "This package provides an implementation of the function
211 @code{bioFabric} for creating scalable network digrams where nodes are
212 represented by horizontal lines, and edges are represented by vertical
214 (license license:expat))))
216 (define-public python-plotly
218 (name "python-plotly")
223 (uri (pypi-uri "plotly" version))
226 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
227 (build-system python-build-system)
229 '(#:tests? #f)) ; The tests are not distributed in the release
231 `(("python-decorator" ,python-decorator)
232 ("python-nbformat" ,python-nbformat)
233 ("python-pandas" ,python-pandas)
234 ("python-pytz" ,python-pytz)
235 ("python-requests" ,python-requests)
236 ("python-six" ,python-six)))
237 (home-page "https://plot.ly/python/")
238 (synopsis "Interactive plotting library for Python")
239 (description "Plotly's Python graphing library makes interactive,
240 publication-quality graphs online. Examples of how to make line plots, scatter
241 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
242 subplots, multiple-axes, polar charts, and bubble charts. ")
243 (license license:expat)))
245 (define-public python2-plotly
246 (package-with-python2 python-plotly))
255 (url "https://github.com/facebookresearch/faiss.git")
256 (commit (string-append "v" version))))
257 (file-name (git-file-name name version))
260 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
261 (modules '((guix build utils)))
264 (substitute* "utils.cpp"
265 (("#include <immintrin.h>")
266 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
268 (build-system cmake-build-system)
271 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
272 "-DBUILD_TUTORIAL=OFF") ; we don't need those
274 (modify-phases %standard-phases
275 (add-after 'unpack 'prepare-build
277 (let ((features (list ,@(let ((system (or (%current-target-system)
280 ((string-prefix? "x86_64" system)
281 '("-mavx" "-msse2" "-mpopcnt"))
282 ((string-prefix? "i686" system)
283 '("-msse2" "-mpopcnt"))
286 (substitute* "CMakeLists.txt"
288 (("-mpopcnt") "") ; only some architectures
291 (string-join features)
293 ;; Build also the shared library
294 (("ARCHIVE DESTINATION lib")
295 "LIBRARY DESTINATION lib")
298 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
299 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
300 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
301 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
302 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
305 ;; See https://github.com/facebookresearch/faiss/issues/520
306 (substitute* "IndexScalarQuantizer.cpp"
307 (("#define USE_AVX") ""))
309 ;; Make header files available for compiling tests.
311 (for-each (lambda (file)
312 (mkdir-p (string-append "faiss/" (dirname file)))
313 (copy-file file (string-append "faiss/" file)))
314 (find-files "." "\\.h$"))
318 (invoke "make" "-C" "tests"
319 (format #f "-j~a" (parallel-job-count)))))
320 (add-after 'install 'remove-tests
321 (lambda* (#:key outputs #:allow-other-keys)
322 (delete-file-recursively
323 (string-append (assoc-ref outputs "out")
327 `(("openblas" ,openblas)))
329 `(("googletest" ,googletest)))
330 (home-page "https://github.com/facebookresearch/faiss")
331 (synopsis "Efficient similarity search and clustering of dense vectors")
332 (description "Faiss is a library for efficient similarity search and
333 clustering of dense vectors. It contains algorithms that search in sets of
334 vectors of any size, up to ones that possibly do not fit in RAM. It also
335 contains supporting code for evaluation and parameter tuning.")
336 (license license:bsd-3)))
338 (define-public python-faiss
339 (package (inherit faiss)
340 (name "python-faiss")
341 (build-system python-build-system)
344 (modify-phases %standard-phases
345 (add-after 'unpack 'chdir
346 (lambda _ (chdir "python") #t))
347 (add-after 'chdir 'build-swig
348 (lambda* (#:key inputs #:allow-other-keys)
349 (with-output-to-file "../makefile.inc"
351 (let ((python-version ,(version-major+minor (package-version python))))
353 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
354 LIBS = -lpython~am -lfaiss
355 SHAREDFLAGS = -shared -fopenmp
356 CXXFLAGS = -fpermissive -std=c++11 -fopenmp -fPIC
357 CPUFLAGS = ~{~a ~}~%"
358 (assoc-ref inputs "python*") python-version
359 (assoc-ref inputs "python-numpy") python-version
361 (list ,@(let ((system (or (%current-target-system)
364 ((string-prefix? "x86_64" system)
365 '("-mavx" "-msse2" "-mpopcnt"))
366 ((string-prefix? "i686" system)
367 '("-msse2" "-mpopcnt"))
370 (substitute* "Makefile"
371 (("../libfaiss.a") ""))
372 (invoke "make" "cpu"))))))
375 ("openblas" ,openblas)
379 `(("python-matplotlib" ,python-matplotlib)
380 ("python-numpy" ,python-numpy)))
381 (description "Faiss is a library for efficient similarity search and
382 clustering of dense vectors. This package provides Python bindings to the