Skip to content

Commit

Permalink
PR corrections - inplace instead of copy on flowsom function
Browse files Browse the repository at this point in the history
  • Loading branch information
burtonrj committed Oct 30, 2023
1 parent ee56fa4 commit 166fed0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
language_version: python3
args:
- --max-line-length=88
- --ignore=E203
- --ignore=E203,TYP001
exclude: |
(?x)(
__init__.py
Expand Down
10 changes: 3 additions & 7 deletions docs/tutorials/flowsom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
"cell_type": "code",
"execution_count": null,
"id": "fa01f5013e68d3d2",
"metadata": {
"jupyter": {
"outputs_hidden": false
}
},
"metadata": {},
"outputs": [],
"source": [
"import scanpy as sc\n",
Expand Down Expand Up @@ -163,7 +159,7 @@
"metadata": {},
"source": [
"We can now cluster our data with the `flowsom_clustering` function from the `tl` (tools) module of `pytometry`. The FlowSOM algorithm works in the following stages:\n",
"1. A self-organsing map is trained that learns a low dimensional embedding of the single cell feature space\n",
"1. A self-organising map is trained that learns a low dimensional embedding of the single cell feature space\n",
"2. Consensus clustering (https://github.com/burtonrj/consensusclustering) of the SOM nodes identifies the optimal number of clusters to retain\n",
"3. Each observation is assigned to a cluster according to its nearest meta-cluster in the SOM\n",
"\n",
Expand Down Expand Up @@ -202,7 +198,7 @@
" max_clusters=20,\n",
" return_clustering_objs=True,\n",
" verbose=True,\n",
" copy=True,\n",
" inplace=True,\n",
" agglomerative_clustering_kwargs={\"metric\": \"euclidean\", \"linkage\": \"ward\"},\n",
")"
]
Expand Down
6 changes: 3 additions & 3 deletions pytometry/tools/clustering/_flowsom.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def flowsom_clustering(
max_clusters: int = 10,
n_resamples: int = 100,
resample_frac: float = 0.9,
copy: bool = False,
inplace: bool = True,
verbose: bool = False,
agglomerative_clustering_kwargs: dict | None = None,
return_clustering_objs: bool = False,
Expand Down Expand Up @@ -169,7 +169,7 @@ def flowsom_clustering(
max_clusters (int, default=10): maximum number of clusters to consider
n_resamples (int, default=100): number of resamples for consensus clustering
resample_frac (float, default=0.5): fraction of samples to resample for
copy (bool, default=False): whether to copy the AnnData object or modify it
inplace (bool, default=False): whether to copy the AnnData object or modify it
verbose (bool, default=False)
agglomerative_clustering_kwargs (dict, default=None): keyword arguments for
sklearn.cluster.AgglomerativeClustering. If None, defaults to
Expand All @@ -183,7 +183,7 @@ def flowsom_clustering(
containing the annotated data matrix and the clustering objects is returned.
"""
adata = adata.copy() if copy else adata
adata = adata if inplace else adata.copy()
logger.info("Running FlowSOM clustering")
logger.info("Training SOM")
som = som_clustering(
Expand Down

0 comments on commit 166fed0

Please sign in to comment.