summaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2023-02-10 15:15:17 +0100
committerRicardo Wurmus <rekado@elephly.net>2023-02-10 19:36:29 +0100
commit8340acfa5a22495cd17e37c01388010f93103adc (patch)
treeb715eb3802f26063a7c6c3caae09539dc03da1ee /gnu/packages
parent769346eef7e4d712cabb84179a62e877b9a69292 (diff)
gnu: Add python-phenograph.
* gnu/packages/bioinformatics.scm (python-phenograph): New variable.
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/bioinformatics.scm60
1 files changed, 60 insertions, 0 deletions
diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index 7ea856c157..c70dcdf93b 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -1255,6 +1255,66 @@ servers supporting the protocol.")
genomics data.")
(license license:bsd-3)))
+(define-public python-phenograph
+ (package
+ (name "python-phenograph")
+ (version "1.5.7")
+ (source (origin
+ (method url-fetch)
+ (uri (pypi-uri "PhenoGraph" version))
+ (sha256
+ (base32
+ "0nji449mzwgp1f87iknl5fmnjdkrhkfkapxvafxdw01s0jg8zcj6"))
+ (modules '((guix build utils)))
+ ;; Remove bundled binaries
+ (snippet
+ '(delete-file-recursively "phenograph/louvain"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ ;; This test can never succeed because Q_leiden is never set to
+ ;; anything other than None.
+ (add-after 'unpack 'disable-leiden-test
+ (lambda _
+ (substitute* "tests/test_cluster.py"
+ (("def test_run_leiden") "def _test_run_leiden"))))
+ (add-after 'unpack 'patch-louvain
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "phenograph/core.py"
+ (("lpath = os.path.*")
+ (string-append "lpath = \""
+ (dirname (search-input-file inputs "/bin/community"))
+ "\"\n"))
+ (("linux-(community|hierarchy|convert)" _ thing) thing)
+ ;; Do not write binaries, because the unmodified "convert"
+ ;; from louvain only knows how to process plain text files.
+ (("with open\\(filename \\+ \".bin\", \"w\\+b\"\\) as f:")
+ "with open(filename + \".bin\", \"w+\") as f:")
+ (("f.writelines\\(\\[e for t in zip\\(ij, s\\) for e in t\\]\\)")
+ "for [src, dest], weight in zip(ij, s): \
+f.write(src.astype(\"str\") + ' ' + \
+dest.astype(\"str\") + ' ' + \
+weight.astype(\"str\") + '\\n')")))))))
+ (inputs
+ (list louvain))
+ (propagated-inputs
+ (list python-leidenalg
+ python-numpy
+ python-psutil
+ python-scikit-learn
+ python-scipy))
+ (native-inputs
+ (list python-pytest))
+ (home-page "https://github.com/dpeerlab/PhenoGraph.git")
+ (synopsis "Graph-based clustering for high-dimensional single-cell data")
+ (description
+ "PhenoGraph is a clustering method designed for high-dimensional
+single-cell data. It works by creating a graph representing phenotypic
+similarities between cells and then identifying communities in this graph.")
+ (license license:expat)))
+
(define-public python-phylophlan
(package
(name "python-phylophlan")