diff --git a/docs/_static/model.svg b/docs/_static/model.svg deleted file mode 100644 index 6b3ee28..0000000 --- a/docs/_static/model.svg +++ /dev/null @@ -1,433 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Metadata - Linear Decoder - Encoder - Latent space - Genes - Gene loadings - N latent - Cell - Reconstructed counts - Counts - - - - - - - - - - - - - - - - - diff --git a/docs/conf.py b/docs/conf.py index 1261082..2575b93 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -108,6 +108,7 @@ # a list of builtin themes. # html_theme = "sphinx_book_theme" +html_logo = "_static/img/logo.png" html_static_path = ["_static"] html_css_files = ["css/custom.css"] diff --git a/docs/contributing.md b/docs/contributing.md index ac9bcdb..0861dbb 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -103,7 +103,7 @@ Please write documentation for new or changed features and use-cases. This proje - [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension). - Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks)) - [Sphinx autodoc typehints][], to automatically reference annotated input and output types -- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/) +- Citations (like {cite:p}`virshup2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/) See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information on how to write documentation. diff --git a/sccoral/module/_module.py b/sccoral/module/_module.py index 28d2789..cbc0fa1 100644 --- a/sccoral/module/_module.py +++ b/sccoral/module/_module.py @@ -200,7 +200,9 @@ def __init__( n_levels = 1 name = f"encoder_{cat_name}" - model = LinearEncoder(n_levels, 1, mean_bias=True, var_bias=True) + model = LinearEncoder( + n_levels, 1, latent_distribution=latent_distribution, mean_bias=True, var_bias=True + ) # Register encoder in class setattr(self, name, model) @@ -215,7 +217,7 @@ def __init__( if continuous_names is not None: for con_name, dim in zip(continuous_names, range(n_latent + n_cat, n_latent + n_cat + n_con)): name = f"encoder_{con_name}" - model = LinearEncoder(1, 1) + model = LinearEncoder(1, 1, latent_distribution=latent_distribution) # Register encoder in class setattr(self, name, model) diff --git a/sccoral/nn/_components.py b/sccoral/nn/_components.py index 874a8d7..938b2f0 100644 --- a/sccoral/nn/_components.py +++ b/sccoral/nn/_components.py @@ -16,7 +16,7 @@ class LinearEncoder(nn.Module): Number of input dimensions n_output Number of output dimensions - distributions + latent_distribution Normal distribution `normal` or lognormal `ln` (:cite:Svensson2020) return_dist Whether to return the distribution or samples @@ -30,7 +30,7 @@ def __init__( self, n_input: int, n_output: int, - distribution: Literal["ln", "normal"] = "normal", + latent_distribution: Literal["ln", "normal"] = "ln", return_dist: bool = False, mean_bias: bool = True, var_bias: bool = True, @@ -43,7 +43,7 @@ def __init__( self.var_eps = var_eps - if distribution == "ln": + if latent_distribution == "ln": self.z_transformation = nn.Softmax(dim=-1) else: # Identity function diff --git a/tests/test_model.py b/tests/test_model.py index 74d20df..fb181c9 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -78,12 +78,12 @@ def test_pretraining_early_stopping(adata, pretraining_early_stopping, requires_ assert model.module.z_encoder.encoder.fc_layers[0][0].weight.requires_grad == requires_grad -@pytest.fixture(scope="module") -def basic_train(adata): +@pytest.fixture(scope="module", params=["normal", "ln"]) +def basic_train(adata, request): SCCORAL.setup_anndata( adata, categorical_covariates="categorical_covariate", continuous_covariates="continuous_covariate" ) - model = SCCORAL(adata, n_latent=5) + model = SCCORAL(adata, n_latent=5, latent_distribution=request.param) model.train(max_epochs=20, accelerator="cpu") return model