Skip to content

Commit 76f2ed1

Browse files
committed
Merge branch 'dev'
2 parents 0fb49c1 + d6015b2 commit 76f2ed1

20 files changed

+393
-227
lines changed

.cruft.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"template": "https://github.com/scverse/cookiecutter-scverse",
3-
"commit": "586b1652162ff7994b0070a034023d64289ae416",
4-
"checkout": "v0.3.1",
3+
"commit": "009f1b5205d007026e76b3dd79f57ad946947ceb",
4+
"checkout": null,
55
"context": {
66
"cookiecutter": {
77
"project_name": "FlowSOM",

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ __pycache__/
1818
/.pytest_cache/
1919
/.cache/
2020
/data/
21+
/node_modules/
2122

2223
# docs
2324
/docs/generated/

.pre-commit-config.yaml

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
exclude: "tests/data"
12
fail_fast: false
23
default_language_version:
34
python: python3
@@ -6,29 +7,18 @@ default_stages:
67
- push
78
minimum_pre_commit_version: 2.16.0
89
repos:
9-
- repo: https://github.com/psf/black
10-
rev: "23.11.0"
11-
hooks:
12-
- id: black
13-
- repo: https://github.com/asottile/blacken-docs
14-
rev: 1.16.0
15-
hooks:
16-
- id: blacken-docs
1710
- repo: https://github.com/pre-commit/mirrors-prettier
18-
rev: v3.1.0
11+
rev: v4.0.0-alpha.8
1912
hooks:
2013
- id: prettier
21-
# Newer versions of node don't work on systems that have an older version of GLIBC
22-
# (in particular Ubuntu 18.04 and Centos 7)
23-
# EOL of Centos 7 is in 2024-06, we can probably get rid of this then.
24-
# See https://github.com/scverse/cookiecutter-scverse/issues/143 and
25-
# https://github.com/jupyterlab/jupyterlab/issues/12675
26-
language_version: "17.9.1"
2714
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.1.5
15+
rev: v0.1.14
2916
hooks:
3017
- id: ruff
18+
types_or: [python, pyi, jupyter]
3119
args: [--fix, --exit-non-zero-on-fix]
20+
- id: ruff-format
21+
types_or: [python, pyi, jupyter]
3222
- repo: https://github.com/pre-commit/pre-commit-hooks
3323
rev: v4.5.0
3424
hooks:

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# FlowSOM
22

33
<!-- [![Tests][badge-tests]][link-tests] -->
4+
45
[![Documentation][badge-docs]][link-docs]
56

67
[badge-tests]: https://img.shields.io/github/actions/workflow/status/saeyslab/FlowSOM_Python/test.yaml?branch=main

docs/api.md

+44-10
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,63 @@
11
# API
22

3-
Import FlowSOM as:
3+
Import FlowSOM using the alias `fs` for convenience. Functions and classes can then be accessed as `fs.FlowSOM` or `fs.io.read_FCS`:
44

55
```
66
import flowsom as fs
77
```
88

99
The functionality is organised in subpackages:
10-
- `io` for reading and writing FCS files
11-
- `pp` for preprocessing
12-
- `tl` for tools
13-
- `pl` for plotting
1410

15-
The central class is `FlowSOM`.
11+
- `io` for reading and writing FCS files
12+
- `pp` for preprocessing
13+
- `tl` for tools
14+
- `pl` for plotting
1615

17-
## Reading
16+
The central class is `FlowSOM`, which can be instantiated as a class and is also the output of the convenience function `flowsom_clustering`:
17+
18+
```{eval-rst}
19+
.. module:: flowsom
20+
.. autosummary::
21+
:toctree: generated
1822
23+
flowsom.FlowSOM
24+
flowsom.flowsom_clustering
1925
```
26+
27+
## Reading
28+
29+
```{eval-rst}
30+
.. module:: flowsom.io
31+
.. currentmodule:: flowsom
32+
33+
.. autosummary::
34+
:toctree: generated
35+
2036
io.read_FCS
2137
```
2238

2339
## Preprocessing
2440

25-
```
41+
```{eval-rst}
42+
.. module:: flowsom.pp
43+
.. currentmodule:: flowsom
44+
45+
.. autosummary::
46+
:toctree: generated
47+
2648
pp.aggregate_flowframes
2749
pp.normalize_estimate_logicle
2850
```
2951

3052
## Tools
3153

32-
```
54+
```{eval-rst}
55+
.. module:: flowsom.tl
56+
.. currentmodule:: flowsom
57+
58+
.. autosummary::
59+
:toctree: generated
60+
3361
tl.ConsensusCluster
3462
tl.SOM
3563
tl.map_data_to_codes
@@ -45,7 +73,13 @@ The central class is `FlowSOM`.
4573

4674
## Plotting
4775

48-
```
76+
```{eval-rst}
77+
.. module:: flowsom.pl
78+
.. currentmodule:: flowsom
79+
80+
.. autosummary::
81+
:toctree: generated
82+
4983
pl.FlowSOMmary
5084
pl.plot_2D_scatters
5185
pl.plot_labels

docs/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ and [prettier][prettier-editors].
5151
## Writing tests
5252

5353
```{note}
54-
Remember to first install the package with `pip install '-e[dev,test]'`
54+
Remember to first install the package with `pip install -e '.[dev,test]'`
5555
```
5656

5757
This package uses the [pytest][] for automated testing. Please [write tests][scanpy-test-docs] for every function added

docs/notebooks/example.ipynb

+36-23
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@
464464
],
465465
"source": [
466466
"# Visualize data\n",
467-
"ax = plt.hist2d(ff_t[:,\"CD4\"].X.flatten(), ff_t[:,\"CD8\"].X.flatten(), bins=200, cmin = 1, cmap = \"jet\")\n",
467+
"ax = plt.hist2d(ff_t[:, \"CD4\"].X.flatten(), ff_t[:, \"CD8\"].X.flatten(), bins=200, cmin=1, cmap=\"jet\")\n",
468468
"plt.show()"
469469
]
470470
},
@@ -520,7 +520,7 @@
520520
}
521521
],
522522
"source": [
523-
"fsom = fs.FlowSOM(ff_t, cols_to_use, xdim = 10, ydim = 10, n_clus = 10)\n",
523+
"fsom = fs.FlowSOM(ff_t, cols_to_use, xdim=10, ydim=10, n_clus=10)\n",
524524
"fsom.mudata"
525525
]
526526
},
@@ -555,7 +555,7 @@
555555
}
556556
],
557557
"source": [
558-
"ff_clustered = fs.flowsom_clustering(ff_t, cols_to_use, xdim = 10, ydim = 10, n_clus = 10)\n",
558+
"ff_clustered = fs.flowsom_clustering(ff_t, cols_to_use, xdim=10, ydim=10, n_clus=10)\n",
559559
"ff_clustered"
560560
]
561561
},
@@ -666,8 +666,8 @@
666666
}
667667
],
668668
"source": [
669-
"p = fs.pl.plot_stars(fsom, background_values = fsom.get_cluster_data().obs.metaclustering)\n",
670-
"p"
669+
"p = fs.pl.plot_stars(fsom, background_values=fsom.get_cluster_data().obs.metaclustering)\n",
670+
"p.show()"
671671
]
672672
},
673673
{
@@ -706,7 +706,13 @@
706706
}
707707
],
708708
"source": [
709-
"p = fs.pl.plot_stars(fsom, background_values = fsom.get_cluster_data().obs.metaclustering, view = \"grid\", equal_node_size = True, equal_background_size = True)\n",
709+
"p = fs.pl.plot_stars(\n",
710+
" fsom,\n",
711+
" background_values=fsom.get_cluster_data().obs.metaclustering,\n",
712+
" view=\"grid\",\n",
713+
" equal_node_size=True,\n",
714+
" equal_background_size=True,\n",
715+
")\n",
710716
"p"
711717
]
712718
},
@@ -736,12 +742,12 @@
736742
],
737743
"source": [
738744
"# Read in that data\n",
739-
"file = open(\"../../tests/data/gating_result.csv\", \"r\")\n",
745+
"file = open(\"../../tests/data/gating_result.csv\")\n",
740746
"data = csv.reader(file)\n",
741747
"data = [i[0] for i in data]\n",
742748
"\n",
743749
"# Plot\n",
744-
"p = fs.pl.plot_pies(fsom, data, background_values = fsom.get_cluster_data().obs.metaclustering)"
750+
"p = fs.pl.plot_pies(fsom, data, background_values=fsom.get_cluster_data().obs.metaclustering)"
745751
]
746752
},
747753
{
@@ -771,7 +777,7 @@
771777
}
772778
],
773779
"source": [
774-
"p = fs.pl.plot_numbers(fsom, level = \"clusters\", text_size = 5)"
780+
"p = fs.pl.plot_numbers(fsom, level=\"clusters\", text_size=5)"
775781
]
776782
},
777783
{
@@ -800,7 +806,7 @@
800806
}
801807
],
802808
"source": [
803-
"p = fs.pl.plot_marker(fsom, marker = np.array([\"CD3\"]))"
809+
"p = fs.pl.plot_marker(fsom, marker=np.array([\"CD3\"]))"
804810
]
805811
},
806812
{
@@ -840,14 +846,14 @@
840846
],
841847
"source": [
842848
"p = fs.pl.plot_2D_scatters(\n",
843-
" fsom,\n",
844-
" channelpairs=[[\"CD3\", \"CD4\"], [\"CD19\", \"TCRb\"]],\n",
845-
" clusters=[[1, 2], [3]],\n",
846-
" metaclusters=[[4], [5, 6]],\n",
847-
" density=True,\n",
848-
" centers=True,\n",
849-
" )\n",
850-
"p"
849+
" fsom,\n",
850+
" channelpairs=[[\"CD3\", \"CD4\"], [\"CD19\", \"TCRb\"]],\n",
851+
" clusters=[[1, 2], [3]],\n",
852+
" metaclusters=[[4], [5, 6]],\n",
853+
" density=True,\n",
854+
" centers=True,\n",
855+
")\n",
856+
"p.show()"
851857
]
852858
},
853859
{
@@ -960,7 +966,12 @@
960966
}
961967
],
962968
"source": [
963-
"features = fs.tl.get_features(fsom, files=[ff_t[1:1000, :], ff_t[1000:2000, :]], level = [\"clusters\", \"metaclusters\"], type = [\"counts\", \"percentages\"])\n",
969+
"features = fs.tl.get_features(\n",
970+
" fsom,\n",
971+
" files=[ff_t[1:1000, :], ff_t[1000:2000, :]],\n",
972+
" level=[\"clusters\", \"metaclusters\"],\n",
973+
" type=[\"counts\", \"percentages\"],\n",
974+
")\n",
964975
"features[\"metacluster_percentages\"]"
965976
]
966977
},
@@ -1075,7 +1086,7 @@
10751086
}
10761087
],
10771088
"source": [
1078-
"fs.tl.get_counts(fsom, level = \"clusters\")"
1089+
"fs.tl.get_counts(fsom, level=\"clusters\")"
10791090
]
10801091
},
10811092
{
@@ -1244,7 +1255,9 @@
12441255
}
12451256
],
12461257
"source": [
1247-
"fs.pp.aggregate_flowframes(filenames = [\"../../tests/data/not_preprocessed.fcs\", \"../../tests/data/not_preprocessed.fcs\"], c_total = 5000)"
1258+
"fs.pp.aggregate_flowframes(\n",
1259+
" filenames=[\"../../tests/data/not_preprocessed.fcs\", \"../../tests/data/not_preprocessed.fcs\"], c_total=5000\n",
1260+
")"
12481261
]
12491262
},
12501263
{
@@ -1301,7 +1314,7 @@
13011314
],
13021315
"source": [
13031316
"fsom_new = fsom.new_data(ff_t[1:200, :])\n",
1304-
"fs.pl.plot_stars(fsom_new, background_values = fsom_new.get_cluster_data().obs.metaclustering)"
1317+
"fs.pl.plot_stars(fsom_new, background_values=fsom_new.get_cluster_data().obs.metaclustering)"
13051318
]
13061319
},
13071320
{
@@ -1350,7 +1363,7 @@
13501363
],
13511364
"source": [
13521365
"fsom_subset = fsom.subset(fsom.get_cell_data().obs[\"metaclustering\"] == 4)\n",
1353-
"fs.pl.plot_stars(fsom_subset, background_values = fsom_subset.get_cluster_data().obs.metaclustering)"
1366+
"fs.pl.plot_stars(fsom_subset, background_values=fsom_subset.get_cluster_data().obs.metaclustering)"
13541367
]
13551368
}
13561369
],

env.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ dependencies:
3232
- sphinxext-opengraph
3333
- ipykernel
3434
- ipython
35-
- sphinx-copybutton
35+
- sphinx-copybutton

0 commit comments

Comments
 (0)