Skip to content

Commit

Permalink
Update example code
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrohbeck authored Sep 13, 2023
1 parent 6c9ec6d commit 5844535
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@ Cellij (pronounced as "zillīj", derived from [Zellij](https://en.wikipedia.org/
<img src="https://github.com/bioFAM/cellij/blob/main/docs/_static/figure1_black.png" alt="schematic" width="750"/>
</p>

Cellij is designed for rapid prototyping of custom factor analysis models, allowing users to efficiently define new models in an iterative fashion.
Cellij is designed for rapid prototyping of custom factor analysis models, allowing users to efficiently define new models in an iterative fashion. The following code snippet shows an example how to setup and train a model with a predefined sparsity prior.
```python
# First we create an instance of a MOFA class
model = cellij.core.models.MOFA(n_factors=30, sparsity_prior="Horseshoe")
mdata = cellij.Importer().load_CLL()

# Afterwards, we need to add the data to the model
model.add_data(data=mdata)
# 1. We create a new Factor Analysis model
model = cellij.FactorModel(n_factors=10)

# We call `.fit` to train the model
model.fit(
likelihoods={
"mrna": "Normal",
"mutations": "Bernoulli",
# 2. We add an MuData object to the model
model.add_data(mdata)

# 3. We can add some options if we wish
model.set_model_options(
weight_priors={
"drugs": "Horseshoe",
"methylation": "Horseshoe",
"mrna": "Horseshoe",
},
epochs=1000,
learning_rate=0.001,
)

# 4. We train the model
model.fit(epochs=10000)
```
For a basic tutorial on real-world data, have a look at [this notebook](https://github.com/bioFAM/cellij/blob/main/notebooks/basic_example_mofa.ipynb).
For basic tutorials on real-world data, please have a look at [our notebook repository]([https://github.com/bioFAM/cellij/blob/main/notebooks/basic_example_mofa.ipynb](https://github.com/bioFAM/cellij-notebooks/tree/main)).


## Getting started
Expand Down

0 comments on commit 5844535

Please sign in to comment.