biolord.BiolordModule#
- class biolord.BiolordModule(n_genes, n_samples, x_loc, ordered_attributes_map=None, categorical_attributes_map=None, n_latent=32, n_latent_attribute_categorical=4, n_latent_attribute_ordered=16, gene_likelihood='normal', reconstruction_penalty=100.0, unknown_attribute_penalty=10.0, use_batch_norm=True, use_layer_norm=False, unknown_attribute_noise_param=0.1, unknown_attributes=True, attribute_dropout_rate=None, decoder_width=512, decoder_depth=4, decoder_activation=True, attribute_nn_width=None, attribute_nn_depth=None, attribute_nn_activation=True, eval_r2_ordered=False, decoder_dropout_rate=0.1, seed=0)[source]#
The
biolord
module.- Parameters:
n_genes (
int
) – Number of input genes.n_samples (
int
) – Number of layers.x_loc (
str
) – The expression data location.ordered_attributes_map (
Optional
[dict
[str
,int
]]) – Dictionary of ordered classes and their dimensions.categorical_attributes_map (
Optional
[dict
[str
,dict
]]) – Dictionary for categorical classes, containing categorical values with keys as each category name and values as the categorical integer assignment.n_latent (
int
) – Latent dimension.n_latent_attribute_ordered (
int
) – Latent dimension of ordered attributes.n_latent_attribute_categorical (
int
) – Latent dimension of categorical attributes.gene_likelihood (
Literal
['normal'
,'nb'
,'poisson'
]) – The gene_likelihood model.reconstruction_penalty (
float
) – MSE error to reconstruction loss.use_batch_norm (
bool
) – Use batch norm in layers.use_layer_norm (
bool
) – Use layer norm in layers.unknown_attribute_noise_param (
float
) – Noise strength added to encoding of unknown attributes.unknown_attributes (
bool
) – Whether to include learning for unknown attributesattribute_dropout_rate (
Optional
[dict
[str
,float
]]) – Dropout rate.attribute_nn_width (
Optional
[dict
[str
,int
]]) – Ordered attributes autoencoder layers’ width.attribute_nn_depth (
Optional
[dict
[str
,int
]]) – Ordered attributes autoencoder number of layers.attribute_nn_activation (
bool
) – Use activation in ordered attributes.decoder_width (
int
) – Decoder layers’ width.decoder_depth (
int
) – Decoder number of layers.decoder_activation (
bool
) – Use activation in decoder.eval_r2_ordered (
bool
) – Evaluate the R2 w.r.t. the ordered attribute. Set toTrue
only if ordered attributes are binned.decoder_dropout_rate (
float
) – Decoder dropout rate.seed (
int
) – Random seed.
Attributes table#
Methods table#
|
Runs the generative step. |
|
Computes gene expression means and standard deviation. |
|
Convert tensors to valid inference input. |
|
Apply module inference. |
|
Computes the module's loss. |
|
Evaluate the \(R^2\) metric over gene expression. |
Computes the content penalty term in the loss. |
Attributes#
Methods#
generative#
get_expression#
get_inference_input#
inference#
- BiolordModule.inference(genes, sample_indices, categorical_attribute_dict, ordered_attribute_dict, nullify_attribute=None)[source]#
Apply module inference.
- Parameters:
genes (
Tensor
) – Input expression.sample_indices (
Tensor
) – Indices in theAnnData
object of the input samples.categorical_attribute_dict (
dict
[Any
,Any
]) – Dictionary with categorical attributes as keys and the attribute sample labels as values.ordered_attribute_dict (
dict
[Any
,Any
]) – Dictionary with ordered attributes as keys and the attribute sample values as values.nullify_attribute (
Optional
[list
]) – Attributes to exclude from inferred latent space.
- Return type:
- Returns:
Dictionary with the module’s expected input tensors (
genes
,sample_indices
,categorical_attribute_dict
, andordered_attribute_dict
).