From 48765e9f724f659dc918a21f43b18fb124c79d54 Mon Sep 17 00:00:00 2001 From: Lucas Diedrich Date: Mon, 25 Mar 2024 12:14:08 -0400 Subject: [PATCH 1/6] Updated docs configuration --- docs/_static/model.svg | 433 ----------------------------------------- docs/conf.py | 1 + 2 files changed, 1 insertion(+), 433 deletions(-) delete mode 100644 docs/_static/model.svg 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"] From 0198fed7c072ef3e1f9f69b14804bc4fdbe9e7a4 Mon Sep 17 00:00:00 2001 From: Lucas Diedrich Date: Wed, 27 Mar 2024 14:26:52 -0400 Subject: [PATCH 2/6] Covariate-embeddings can have logit normal distribution now --- sccoral/module/_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sccoral/module/_module.py b/sccoral/module/_module.py index 28d2789..0917415 100644 --- a/sccoral/module/_module.py +++ b/sccoral/module/_module.py @@ -200,7 +200,7 @@ 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, distribution=latent_distribution, mean_bias=True, var_bias=True) # Register encoder in class setattr(self, name, model) @@ -215,7 +215,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) From a0e780ec3103dbbe847d68c0377ec3b88c91ee18 Mon Sep 17 00:00:00 2001 From: Lucas Diedrich Date: Wed, 27 Mar 2024 14:31:35 -0400 Subject: [PATCH 3/6] Updated citation --- docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From f7ef6e55732da064f957d23a9f29b858c2d25290 Mon Sep 17 00:00:00 2001 From: Lucas Diedrich Date: Wed, 27 Mar 2024 14:33:27 -0400 Subject: [PATCH 4/6] Changed to --- sccoral/nn/_components.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 2c8aa3eac37283ba9d30e7d5c4da2a78d0baedcd Mon Sep 17 00:00:00 2001 From: Lucas Diedrich Date: Wed, 27 Mar 2024 14:35:58 -0400 Subject: [PATCH 5/6] Renamed to in line with --- sccoral/module/_module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sccoral/module/_module.py b/sccoral/module/_module.py index 0917415..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, distribution=latent_distribution, 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) From 9f6e405f0cdb2311b5678b10f91d20c5a0935b7d Mon Sep 17 00:00:00 2001 From: Lucas Diedrich Date: Wed, 27 Mar 2024 14:56:28 -0400 Subject: [PATCH 6/6] Also test logit normal distribution --- tests/test_model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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