Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use custom datamodules for training #102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ packages = [
{include = "scgen"},
]
readme = "README.md"
version = "2.1.1"
version = "2.1.2"

[tool.poetry.dependencies]
adjustText = "*"
Expand Down
28 changes: 20 additions & 8 deletions scgen/_scgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class SCGEN(VAEMixin, UnsupervisedTrainingMixin, BaseModelClass):
>>> adata.obsm["X_scgen"] = vae.get_latent_representation()
"""

_module_cls = SCGENVAE

def __init__(
self,
adata: AnnData,
Expand All @@ -57,14 +59,24 @@ def __init__(
):
super().__init__(adata)

self.module = SCGENVAE(
n_input=self.summary_stats.n_vars,
n_hidden=n_hidden,
n_latent=n_latent,
n_layers=n_layers,
dropout_rate=dropout_rate,
**model_kwargs,
)
self._module_kwargs = {
"n_hidden": n_hidden,
"n_latent": n_latent,
"n_layers": n_layers,
"dropout_rate": dropout_rate,
**model_kwargs
}
if self._module_init_on_train:
self.module = None
else:
self.module = SCGENVAE(
n_input=self.summary_stats.n_vars,
n_hidden=n_hidden,
n_latent=n_latent,
n_layers=n_layers,
dropout_rate=dropout_rate,
**model_kwargs,
)
self._model_summary_string = (
"SCGEN Model with the following params: \nn_hidden: {}, n_latent: {}, n_layers: {}, dropout_rate: "
"{}"
Expand Down
1 change: 1 addition & 0 deletions scgen/_scgenvae.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(
use_batch_norm: Literal["encoder", "decoder", "none", "both"] = "both",
use_layer_norm: Literal["encoder", "decoder", "none", "both"] = "none",
kl_weight: float = 0.00005,
**kwargs # needed when initilaized with a datamodule
):
super().__init__()
self.n_layers = n_layers
Expand Down
Loading