Skip to content

Commit 71a9991

Browse files
committed
Prefix files with underscore to hide them from sphinx-autodoc.
This avoids unnecessary submodules in the auto-generated documentation; the organization of functions into files is an implementation detail. We also update the links to various scranpy functions.
1 parent cecc18b commit 71a9991

14 files changed

+67
-61
lines changed

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: Build docs
2626
run: |
27-
touch src/singler/lib_singler.py
27+
touch src/singler/_lib_singler.py
2828
pip install tox
2929
tox -e docs
3030

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ MANIFEST
5454
.python-version
5555

5656
_cache
57+
src/singler/_lib_singler.py

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,14 @@
302302
intersphinx_mapping = {
303303
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
304304
"python": ("https://docs.python.org/" + python_version, None),
305-
"matplotlib": ("https://matplotlib.org", None),
306305
"numpy": ("https://numpy.org/doc/stable", None),
307-
"sklearn": ("https://scikit-learn.org/stable", None),
308-
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
309306
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
310307
"setuptools": ("https://setuptools.pypa.io/en/stable/", None),
311308
"pyscaffold": ("https://pyscaffold.org/en/stable", None),
312309
"biocframe": ("https://biocpy.github.io/BiocFrame", None),
313310
"summarizedexperiment": ("https://biocpy.github.io/SummarizedExperiment", None),
314311
"singlecellexperiment": ("https://biocpy.github.io/SingleCellExperiment", None),
312+
"scranpy": ("https://libscran.github.io/scranpy", None),
315313
}
316314

317315
print(f"loading configurations for {project} {version} ...", file=sys.stderr)

lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ set_property(TARGET singler PROPERTY CXX_STANDARD 17)
2727
target_link_libraries(singler PRIVATE pybind11::pybind11)
2828

2929
set_target_properties(singler PROPERTIES
30-
OUTPUT_NAME lib_singler
30+
OUTPUT_NAME _lib_singler
3131
PREFIX ""
3232
)

lib/src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void init_classify_single(pybind11::module&);
77
void init_train_integrated(pybind11::module&);
88
void init_classify_integrated(pybind11::module&);
99

10-
PYBIND11_MODULE(lib_singler, m) {
10+
PYBIND11_MODULE(_lib_singler, m) {
1111
init_find_classic_markers(m);
1212
init_train_single(m);
1313
init_classify_single(m);

src/singler/__init__.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@
88

99
try:
1010
# Change here if project is renamed and does not equal the package name
11-
dist_name = __name__
12-
__version__ = version(dist_name)
11+
_dist_name = __name__
12+
__version__ = version(_dist_name)
1313
except PackageNotFoundError: # pragma: no cover
1414
__version__ = "unknown"
1515
finally:
1616
del version, PackageNotFoundError
1717

1818

19-
from .get_classic_markers import get_classic_markers, number_of_classic_markers
20-
from .train_single import train_single, TrainedSingleReference
21-
from .classify_single import classify_single
22-
from .annotate_single import annotate_single
23-
from .train_integrated import train_integrated, TrainedIntegratedReferences
24-
from .classify_integrated import classify_integrated
25-
from .annotate_integrated import annotate_integrated
26-
from .aggregate_reference import aggregate_reference
19+
from ._get_classic_markers import get_classic_markers, number_of_classic_markers
20+
from ._train_single import train_single, TrainedSingleReference
21+
from ._classify_single import classify_single
22+
from ._annotate_single import annotate_single
23+
from ._train_integrated import train_integrated, TrainedIntegratedReferences
24+
from ._classify_integrated import classify_integrated
25+
from ._annotate_integrated import annotate_integrated
26+
from ._aggregate_reference import aggregate_reference
27+
28+
29+
__all__ = []
30+
for _name in dir():
31+
if _name.startswith("_") or _name == "sys":
32+
continue
33+
__all__.append(_name)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def aggregate_reference(
2222
num_threads: int = 1
2323
) -> summarizedexperiment.SummarizedExperiment:
2424
"""Aggregate reference samples for a given label by using vector quantization to average their count profiles.
25-
The idea is to reduce the size of single-cell reference datasets so as to reduce the computation time of :py:func:`~singler.train_single.train_single`.
25+
The idea is to reduce the size of single-cell reference datasets so as to reduce the computation time of :py:func:`~singler.train_single`.
2626
We perform k-means clustering for all cells in each label and aggregate all cells within each k-means cluster.
2727
(More specifically, the clustering is done on the principal components generated from the highly variable genes to better capture the structure within each label.)
2828
This yields one or more profiles per label, reducing the number of separate observations while preserving some level of intra-label heterogeneity.
@@ -39,7 +39,7 @@ def aggregate_reference(
3939
Sequence of identifiers for each feature, i.e., row in ``ref_data``.
4040
4141
num_centers:
42-
Maximum number of aggregated profiles to produce for each label with :py:func:`~scranpy.cluster_kmeans.cluster_kmeans`.
42+
Maximum number of aggregated profiles to produce for each label with :py:func:`~scranpy.cluster_kmeans`.
4343
If ``None``, a suitable number of profiles is automatically chosen.
4444
4545
power:
@@ -48,10 +48,10 @@ def aggregate_reference(
4848
Ignored if ``num_centers`` is not ``None``.
4949
5050
num_top:
51-
Number of highly variable genes to use for PCA prior to clustering, see :py:func:`~scranpy.choose_highly_variable_genes.choose_highly_variable_genes`.
51+
Number of highly variable genes to use for PCA prior to clustering, see :py:func:`~scranpy.choose_highly_variable_genes`.
5252
5353
rank:
54-
Number of principal components to use during clustering, see :py:func:`~scranpy.run_pca.run_pca`.
54+
Number of principal components to use during clustering, see :py:func:`~scranpy.run_pca`.
5555
5656
assay_type:
5757
Integer or string specifying the assay of ``ref_data`` containing the relevant expression matrix,
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import warnings
55

66
from ._utils import _clean_matrix, _restrict_features
7-
from .train_single import train_single
8-
from .train_integrated import train_integrated
9-
from .classify_single import classify_single
10-
from .classify_integrated import classify_integrated
7+
from ._train_single import train_single
8+
from ._train_integrated import train_integrated
9+
from ._classify_single import classify_single
10+
from ._classify_integrated import classify_integrated
1111

1212

1313
def annotate_integrated(
@@ -46,7 +46,7 @@ def annotate_integrated(
4646
- A matrix-like object representing the reference dataset, where rows
4747
are features and columns are samples. Entries should be expression values,
4848
usually log-transformed (see comments for the ``ref_data`` argument in
49-
:py:func:`~singler.train_single.train_single`).
49+
:py:func:`~singler.train_single`).
5050
- A ``SummarizedExperiment`` object containing such a matrix in its assays.
5151
5252
ref_labels:
@@ -86,30 +86,30 @@ def annotate_integrated(
8686
8787
train_single_args:
8888
Further arguments to pass to
89-
:py:func:`~singler.train_single.train_single`.
89+
:py:func:`~singler.train_single`.
9090
9191
classify_single_args:
9292
Further arguments to pass to
93-
:py:func:`~singler.classify_single.classify_single`.
93+
:py:func:`~singler.classify_single`.
9494
9595
train_integrated_args:
9696
Further arguments to pass to
97-
:py:func:`~singler.train_integrated.train_integrated`.
97+
:py:func:`~singler.train_integrated`.
9898
9999
classify_integrated_args:
100100
Further arguments to pass to
101-
:py:func:`~singler.classify_integrated.classify_integrated`.
101+
:py:func:`~singler.classify_integrated`.
102102
103103
num_threads:
104104
Number of threads to use for the various steps.
105105
106106
Returns:
107107
Tuple where the first element contains per-reference results (i.e. a
108108
list of BiocFrame outputs, roughly equivalent to running
109-
:py:func:`~singler.annotate_single.annotate_single` on each reference)
109+
:py:func:`~singler.annotate_single` on each reference)
110110
and the second element contains integrated results across references
111111
(i.e., a BiocFrame from
112-
:py:func:`~singler.classify_integrated.classify_integrated`).
112+
:py:func:`~singler.classify_integrated`).
113113
"""
114114
nrefs = len(ref_data)
115115
if nrefs != len(ref_labels):
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import biocframe
55
import summarizedexperiment
66

7-
from .train_single import train_single
8-
from .classify_single import classify_single
7+
from ._train_single import train_single
8+
from ._classify_single import classify_single
99
from ._utils import _clean_matrix, _restrict_features
1010

1111

@@ -41,7 +41,7 @@ def annotate_single(
4141
A matrix-like object representing the reference dataset, where rows
4242
are features and columns are samples. Entries should be expression values,
4343
usually log-transformed (see comments for the ``ref`` argument in
44-
:py:func:`~singler.train_single.train_single`).
44+
:py:func:`~singler.train_single`).
4545
4646
Alternatively, a
4747
:py:class:`~summarizedexperiment.SummarizedExperiment.SummarizedExperiment`
@@ -78,18 +78,18 @@ def annotate_single(
7878
7979
train_args:
8080
Further arguments to pass to
81-
:py:func:`~singler.train_single.train_single`.
81+
:py:func:`~singler.train_single`.
8282
8383
classify_args:
8484
Further arguments to pass to
85-
:py:func:`~singler.classify_single.classify_single`.
85+
:py:func:`~singler.classify_single`.
8686
8787
num_threads:
8888
Number of threads to use for the various steps.
8989
9090
Returns:
9191
A :py:class:`~biocframe.BiocFrame.BiocFrame` of labelling results, see
92-
:py:func:`~singler.classify_single.classify_single` for details.
92+
:py:func:`~singler.classify_single` for details.
9393
"""
9494
if isinstance(ref_labels, str):
9595
warnings.warn(
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import summarizedexperiment
77
import numpy
88

9-
from . import lib_singler as lib
10-
from .train_integrated import TrainedIntegratedReferences
9+
from . import _lib_singler as lib
10+
from ._train_integrated import TrainedIntegratedReferences
1111

1212

1313
def classify_integrated(
@@ -35,13 +35,13 @@ def classify_integrated(
3535
3636
results:
3737
List of classification results generated by running
38-
:py:func:`~singler.classify_single.classify_single` on
38+
:py:func:`~singler.classify_single` on
3939
``test_data`` with each reference. References should be in the
4040
same order as that used to construct ``integrated_prebuilt``.
4141
4242
integrated_prebuilt:
4343
Integrated reference object, constructed with
44-
:py:func:`~singler.train_integrated.train_integrated`.
44+
:py:func:`~singler.train_integrated`.
4545
4646
assay_type:
4747
Assay containing the expression matrix, if ``test_data`` is a

0 commit comments

Comments
 (0)