Skip to content

Commit d316d9c

Browse files
authored
Add smooth command to CLI docs, fix double-backslash rendering (#6)
- Add kompot smooth section with usage, options, and examples - Add smooth to overview, quick start workflow, config templates, help - Fix all \\ to single \ in code-block directives (RST renders literally)
1 parent 975ac82 commit d316d9c

1 file changed

Lines changed: 147 additions & 65 deletions

File tree

docs/source/cli.rst

Lines changed: 147 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ Verify installation:
2424
Overview
2525
--------
2626

27-
The CLI provides three main commands:
27+
The CLI provides four main commands:
2828

2929
- ``kompot dm`` - Compute diffusion maps (preprocessing with Palantir)
3030
- ``kompot de`` - Differential expression analysis
3131
- ``kompot da`` - Differential abundance analysis
32+
- ``kompot smooth`` - Smooth gene expression for a single condition
3233

3334
All commands support:
3435

@@ -45,55 +46,61 @@ Complete Workflow
4546
.. code-block:: bash
4647
4748
# 1. Compute diffusion maps (preprocessing)
48-
kompot dm input.h5ad -o input_with_dm.h5ad \\
49-
--pca-key X_pca \\
49+
kompot dm input.h5ad -o input_with_dm.h5ad \
50+
--pca-key X_pca \
5051
--n-components 10
5152
5253
# 2. Run differential expression
53-
kompot de input_with_dm.h5ad -o de_results.h5ad \\
54-
--groupby condition \\
55-
--condition1 control \\
56-
--condition2 treatment \\
54+
kompot de input_with_dm.h5ad -o de_results.h5ad \
55+
--groupby condition \
56+
--condition1 control \
57+
--condition2 treatment \
5758
--obsm-key DM_EigenVectors
5859
5960
# 3. Run differential abundance
60-
kompot da input_with_dm.h5ad -o da_results.h5ad \\
61-
--groupby condition \\
62-
--condition1 control \\
63-
--condition2 treatment \\
61+
kompot da input_with_dm.h5ad -o da_results.h5ad \
62+
--groupby condition \
63+
--condition1 control \
64+
--condition2 treatment \
65+
--obsm-key DM_EigenVectors
66+
67+
# 4. Smooth gene expression for a single condition
68+
kompot smooth input_with_dm.h5ad -o smoothed.h5ad \
69+
--groupby condition \
70+
--condition treatment \
6471
--obsm-key DM_EigenVectors
6572
6673
Diffusion Maps (Preprocessing)
6774
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6875

6976
.. code-block:: bash
7077
71-
kompot dm input.h5ad -o output.h5ad \\
72-
--pca-key X_pca \\
73-
--n-components 10 \\
78+
kompot dm input.h5ad -o output.h5ad \
79+
--pca-key X_pca \
80+
--n-components 10 \
7481
--knn 30
7582
7683
Differential Expression (Basic)
7784
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7885

7986
.. code-block:: bash
8087
81-
kompot de input.h5ad -o output.h5ad \\
82-
--groupby condition \\
83-
--condition1 control \\
84-
--condition2 treatment \\
85-
--obsm-key X_pca \\
88+
kompot de input.h5ad -o output.h5ad \
89+
--groupby condition \
90+
--condition1 control \
91+
--condition2 treatment \
92+
--obsm-key X_pca \
8693
--layer logged_counts
8794
8895
Differential Abundance (Basic)
8996
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9097

9198
.. code-block:: bash
9299
93-
kompot da input.h5ad -o output.h5ad \\
94-
--groupby condition \\
95-
--condition1 control \\
96-
--condition2 treatment \\
100+
kompot da input.h5ad -o output.h5ad \
101+
--groupby condition \
102+
--condition1 control \
103+
--condition2 treatment \
97104
--obsm-key X_pca
98105
99106
Using Config Files
@@ -104,9 +111,9 @@ For complex analyses with many parameters, use config files:
104111
.. code-block:: bash
105112
106113
# Get template (copy from installed package)
107-
python -c "from pathlib import Path; import shutil; \\
108-
import kompot; \\
109-
src = Path(kompot.__file__).parent / 'cli' / 'templates' / 'de_config_minimal.yaml'; \\
114+
python -c "from pathlib import Path; import shutil; \
115+
import kompot; \
116+
src = Path(kompot.__file__).parent / 'cli' / 'templates' / 'de_config_minimal.yaml'; \
110117
shutil.copy(src, 'my_de_config.yaml')"
111118
112119
# Edit config file
@@ -119,8 +126,8 @@ CLI arguments override config file values:
119126

120127
.. code-block:: bash
121128
122-
kompot de input.h5ad -o output.h5ad \\
123-
-c my_config.yaml \\
129+
kompot de input.h5ad -o output.h5ad \
130+
-c my_config.yaml \
124131
--batch-size 50 # Overrides batch_size in config
125132
126133
Diffusion Maps Command
@@ -165,16 +172,16 @@ Example: Complete Preprocessing
165172
.. code-block:: bash
166173
167174
# Starting with raw AnnData (assuming PCA already computed)
168-
kompot dm bone_marrow.h5ad -o bone_marrow_dm.h5ad \\
169-
--pca-key X_pca \\
170-
--n-components 10 \\
175+
kompot dm bone_marrow.h5ad -o bone_marrow_dm.h5ad \
176+
--pca-key X_pca \
177+
--n-components 10 \
171178
--knn 30
172179
173180
# Then run differential analysis
174-
kompot de bone_marrow_dm.h5ad -o results.h5ad \\
175-
--groupby Age \\
176-
--condition1 Young \\
177-
--condition2 Old \\
181+
kompot de bone_marrow_dm.h5ad -o results.h5ad \
182+
--groupby Age \
183+
--condition1 Young \
184+
--condition2 Old \
178185
--obsm-key DM_EigenVectors
179186
180187
Why Diffusion Maps?
@@ -267,17 +274,17 @@ Example: Complete Analysis
267274

268275
.. code-block:: bash
269276
270-
kompot de bone_marrow.h5ad -o results.h5ad \\
271-
--groupby Age \\
272-
--condition1 Young \\
273-
--condition2 Old \\
274-
--obsm-key DM_EigenVectors \\
275-
--layer logged_counts \\
276-
--sample-col Sample \\
277-
--n-landmarks 5000 \\
278-
--batch-size 100 \\
279-
--fdr-threshold 0.05 \\
280-
--null-genes 2000 \\
277+
kompot de bone_marrow.h5ad -o results.h5ad \
278+
--groupby Age \
279+
--condition1 Young \
280+
--condition2 Old \
281+
--obsm-key DM_EigenVectors \
282+
--layer logged_counts \
283+
--sample-col Sample \
284+
--n-landmarks 5000 \
285+
--batch-size 100 \
286+
--fdr-threshold 0.05 \
287+
--null-genes 2000 \
281288
--store-additional-stats
282289
283290
Differential Abundance Command
@@ -348,16 +355,89 @@ Example: Complete Analysis
348355

349356
.. code-block:: bash
350357
351-
kompot da bone_marrow.h5ad -o results.h5ad \\
352-
--groupby Age \\
353-
--condition1 Young \\
354-
--condition2 Old \\
355-
--obsm-key DM_EigenVectors \\
356-
--sample-col Sample \\
357-
--n-landmarks 3000 \\
358-
--log-fold-change-threshold 1.0 \\
358+
kompot da bone_marrow.h5ad -o results.h5ad \
359+
--groupby Age \
360+
--condition1 Young \
361+
--condition2 Old \
362+
--obsm-key DM_EigenVectors \
363+
--sample-col Sample \
364+
--n-landmarks 3000 \
365+
--log-fold-change-threshold 1.0 \
359366
--ptp-threshold 0.05
360367
368+
Smooth Command
369+
--------------
370+
371+
The ``smooth`` command smooths gene expression for a single condition using GP regression. This is useful for denoising expression data or preparing smoothed expression for downstream analysis.
372+
373+
Basic Usage
374+
^^^^^^^^^^^
375+
376+
.. code-block:: bash
377+
378+
kompot smooth INPUT -o OUTPUT [OPTIONS]
379+
kompot smooth INPUT -t TABLE_OUTPUT [OPTIONS]
380+
381+
At least one output must be specified: ``-o/--output`` for full AnnData or ``-t/--table-output`` for CSV/TSV summary table (mean smoothed values and standard deviations per gene).
382+
383+
Common Options
384+
^^^^^^^^^^^^^^
385+
386+
.. code-block:: text
387+
388+
--groupby COLUMN # Column in adata.obs with condition labels
389+
--condition LABEL # Which condition to smooth (requires --groupby)
390+
--obsm-key KEY # Cell state representation (default: DM_EigenVectors)
391+
--layer LAYER # Expression data layer (default: None, use X)
392+
--result-key KEY # Storage key (default: kompot_smooth)
393+
--n-landmarks N # Number of landmarks (default: 5000)
394+
--sample-col COLUMN # Sample ID column for sample variance estimation
395+
--batch-size N # Cells per batch (default: 500)
396+
--genes GENE [GENE ...] # Subset of genes to smooth (default: all)
397+
398+
GP Options
399+
^^^^^^^^^^
400+
401+
.. code-block:: text
402+
403+
--sigma FLOAT # Noise level for the GP (default: 1.0)
404+
--ls-factor FLOAT # Length scale factor (default: 10.0)
405+
--eps FLOAT # Numerical stability constant (default: 1e-8)
406+
--random-state INT # Random seed for landmark selection
407+
408+
Boolean Flags
409+
^^^^^^^^^^^^^
410+
411+
.. code-block:: text
412+
413+
--use-empirical-variance # Estimate per-gene heteroscedastic noise from GP residuals
414+
--overwrite # Overwrite existing results without warning
415+
--no-progress # Disable progress bars
416+
--use-gpu # Use GPU acceleration (requires CUDA-enabled JAX)
417+
418+
Example: Smooth Treatment Condition
419+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
420+
421+
.. code-block:: bash
422+
423+
kompot smooth bone_marrow.h5ad -o smoothed.h5ad \
424+
--groupby Age \
425+
--condition Old \
426+
--obsm-key DM_EigenVectors \
427+
--layer logged_counts \
428+
--n-landmarks 5000
429+
430+
Example: Gene Summary Table
431+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
432+
433+
.. code-block:: bash
434+
435+
kompot smooth bone_marrow.h5ad \
436+
-t gene_summary.csv \
437+
--groupby Age \
438+
--condition Old \
439+
--genes CD34 CD38 THY1
440+
361441
Configuration Files
362442
-------------------
363443

@@ -477,6 +557,7 @@ Kompot provides ready-to-use templates:
477557
- ``kompot/cli/templates/dm_config_template.yaml``
478558
- ``kompot/cli/templates/de_config_template.yaml``
479559
- ``kompot/cli/templates/da_config_template.yaml``
560+
- ``kompot/cli/templates/smooth_config_template.yaml``
480561

481562
Pipeline Integration
482563
--------------------
@@ -526,20 +607,20 @@ Shell Script Example
526607
echo "Processing ${sample}..."
527608
528609
# Step 1: Compute diffusion maps
529-
kompot dm \\
530-
data/${sample}.h5ad \\
531-
-o temp/${sample}_dm.h5ad \\
532-
--pca-key X_pca \\
610+
kompot dm \
611+
data/${sample}.h5ad \
612+
-o temp/${sample}_dm.h5ad \
613+
--pca-key X_pca \
533614
--n-components 10
534615
535616
# Step 2: Differential expression
536-
kompot de \\
537-
temp/${sample}_dm.h5ad \\
538-
-o results/${sample}_de.h5ad \\
539-
--groupby condition \\
540-
--condition1 control \\
541-
--condition2 treatment \\
542-
--obsm-key DM_EigenVectors \\
617+
kompot de \
618+
temp/${sample}_dm.h5ad \
619+
-o results/${sample}_de.h5ad \
620+
--groupby condition \
621+
--condition1 control \
622+
--condition2 treatment \
623+
--obsm-key DM_EigenVectors \
543624
--batch-size 100
544625
545626
if [ $? -eq 0 ]; then
@@ -695,6 +776,7 @@ Getting Help
695776
# Command-specific help
696777
kompot de --help
697778
kompot da --help
779+
kompot smooth --help
698780
kompot dm --help
699781
700782
# Check version

0 commit comments

Comments
 (0)