API Reference
BaseGeneModel
¶
Bases: ABC
, Module
Base class for modeling the expression of gene expression using distributions with gene-specific parameters that are shared across cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_genes |
int
|
The number of genes to model. |
required |
Source code in iicd_workshop_2024/gene_model.py
distribution_name
property
¶
Get the name of the distribution used for modeling the gene expression.
fit(adata, epochs=100, batch_size=128, lr=0.01)
¶
Fit the model to the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata |
AnnData
|
Annotated data matrix. |
required |
epochs |
int
|
Number of epochs to train the model. |
100
|
batch_size |
int
|
Batch size. |
128
|
lr |
float
|
Learning rate. |
0.01
|
Source code in iicd_workshop_2024/gene_model.py
get_distribution(gene_idx=None)
abstractmethod
¶
Get the distribution that models the gene expression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gene_idx |
int or list[int] or None
|
If None, return the distribution over all genes. Otherwise, return the distribution of the specified gene or list of genes (given by their indices). |
None
|
Returns:
Type | Description |
---|---|
Distribution
|
dist.Distribution or list[dist.Distribution]: The distribution(s) of the gene(s). |
Source code in iicd_workshop_2024/gene_model.py
loss(data)
¶
Return the negative log-likelihood of the data given the model.
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: The negative log-likelihood of the data given the model. |
Source code in iicd_workshop_2024/gene_model.py
plot_gene_distribution(model, adata, genes, n_cols=3)
¶
Plot the learned distributions and the empirical distributions of the genes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
BaseGeneModel
|
The gene model. |
required |
adata |
AnnData
|
The annotated data matrix. |
required |
genes |
list[str]
|
The list of genes to plot. |
required |
n_cols |
int
|
The number of columns in the plot. |
3
|
Source code in iicd_workshop_2024/gene_model.py
fit(model, adata, epochs=100, batch_size=128, lr=0.01)
¶
Fit the model to the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Module
|
The model to fit. |
required |
adata |
AnnData
|
The annotated data matrix. |
required |
epochs |
int
|
Number of epochs to train the model. |
100
|
batch_size |
int
|
Batch size. |
128
|
lr |
float
|
Learning rate. |
0.01
|
Source code in iicd_workshop_2024/inference.py
DenseNN
¶
Bases: Module
A simple feedforward neural network with ReLU activation function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_input |
int
|
The number of input features. |
required |
n_output |
int
|
The number of output features. |
required |
n_hidden |
int
|
The number of hidden units in each hidden layer. |
128
|
n_layers |
int
|
The number of hidden layers. |
1
|
Source code in iicd_workshop_2024/neural_network.py
forward(x)
¶
Forward pass of the neural network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
The input tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: The output tensor. |