Skip to content

Commit 4a5640f

Browse files
improved model annotation
1 parent 0412cef commit 4a5640f

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

diffxpy/fit/fit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ def model(
164164
165165
Should be "float32" for single precision or "float64" for double precision.
166166
:param kwargs: [Debugging] Additional arguments will be passed to the _fit method.
167+
:return:
168+
An estimator instance that contains all estimation relevant attributes and the model in estim.model.
169+
The attributes of the model depend on the noise model and the covariates used.
170+
We provide documentation for the model class in the model section of the documentation.
167171
"""
168172
if len(kwargs) != 0:
169173
logging.getLogger("diffxpy").debug("additional kwargs: %s", str(kwargs))

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ Welcome to diffxpy's documentation!
1111
:caption: Contents:
1212

1313
installation
14-
tutorials
1514
api/index
15+
tutorials
1616
parallelization
1717
training
18+
models
1819
references
1920

2021

docs/models.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Models
2+
======
3+
4+
Occurrence of estimator objects in diffxpy
5+
------------------------------------------
6+
7+
GLMs and similar models are a main model class for differential expression analysis with Wald and likelihood ratio tests (LRT).
8+
Diffxpy allows the user to choose between different GLMs based on the noise model argument.
9+
The user can select the covariates that are to be modelled based on formulas or by supplying design matrices directly.
10+
Both Wald test (`de.test.wald`) and LRT (`de.test.lrt`) require the fit of GLMs to the given data.
11+
These fits can be extracted from the differential expression test objects that are returned by the `de.test.*` functions:
12+
These objects are called `model_estim` in the case of the Wald test or `full_estim` and `reduced_estim` for the LRT (for full and reduced model).
13+
Similarly, one can use `de.fit.model` to directely produce such an estimator object.
14+
15+
Structure of estimator objects
16+
------------------------------
17+
18+
These estimator objects are the interface between diffxpy and batchglm and can be directly produced with batchglm.
19+
An estimator object contains various attributes that relate to the estimation procedure and a `.model` attribute that contains an executable
20+
(numpy) version of the estimated model.
21+
The instance of the estimator object contains the raw parameter estimates and functions that compute downstream model characteristics,
22+
such as location and scale parameter estiamtes in a generalized linear model, the equivalent of $\hat{y}$ in a simple feed forward neural network.
23+
The names of these model attributes depend on the noise model and are listed below
24+
25+
Generalized linear models (GLMs)
26+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27+
28+
The estiamted parameters of the location and scale model are in `estim.model.a_var` (location) and `estim.model.b_var` (scale).
29+
The corresponding parameter names are in `estim.model.loc_names` and `estim.model.scale_names`.
30+
The observation and feature wise location and scale prediction after application of design matrix and inverse linker function are in `estim.model.location` and `estim.model.scale`.
31+
32+
For a negative binomial distribution model, the location model correpsponds to the mean model and the scale model corresponds to the dispersion model.
33+
For a normal distribution model, the location model correpsponds to the mean model and the scale model corresponds to the standard deviation model.

docs/requires.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ scipy
33
pandas
44
patsy>=0.5.0
55
batchglm>=0.6.3
6-
xarray
76
statsmodels
87
anndata
98
seaborn

0 commit comments

Comments
 (0)