Skip to content

Commit

Permalink
Merge pull request #111 from theislab/dev
Browse files Browse the repository at this point in the history
Dev v0.6.11
  • Loading branch information
davidsebfischer committed Aug 25, 2019
2 parents b2657b3 + 74f17cf commit f8635bb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 25 deletions.
9 changes: 4 additions & 5 deletions diffxpy/models/batch_bfgs/optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from numpy.linalg import pinv
import numpy.random
from multiprocessing import Pool
import xarray as xr

from .objectives import *

Expand All @@ -22,12 +21,12 @@ def __init__(self, Estim_BFGS, nproc):
self._observations = Estim_BFGS.x.shape[0]
self._design_loc = Estim_BFGS.design_loc
self._design_scale = Estim_BFGS.design_scale
self._loss = xr.DataArray(Estim_BFGS.full_loss(nproc))
self._loss = Estim_BFGS.full_loss(nproc)
self._log_probs = -self._loss
self._probs = np.exp(self._log_probs)
self._mles = xr.DataArray(np.transpose(Estim_BFGS.mles()))
self._gradient = xr.DataArray(np.zeros([Estim_BFGS.x.shape[1]]))
self._fisher_inv = xr.DataArray(Estim_BFGS.fisher_inv)
self._mles = np.transpose(Estim_BFGS.mles())
self._gradient = np.zeros([Estim_BFGS.x.shape[1]])
self._fisher_inv = Estim_BFGS.fisher_inv
self._idx_loc = np.arange(0, Estim_BFGS.design_loc.shape[1])
self._idx_scale = np.arange(Estim_BFGS.design_loc.shape[1],
Estim_BFGS.design_loc.shape[1] + Estim_BFGS.design_scale.shape[1])
Expand Down
24 changes: 12 additions & 12 deletions diffxpy/models/hessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def hes_nb_glm_mean_block(
Estimated mean parameters across cells for a given gene.
:param mu: np.ndarray (cells,)
Estimated dispersion parameters across cells for a given gene.
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
Design matrix of location model.
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
Design matrix of shape model.
:param i: int
Index of first dimension in fisher information matrix which is to be computed.
Expand Down Expand Up @@ -78,9 +78,9 @@ def hes_nb_glm_disp_block(
Estimated mean parameters across cells for a given gene.
:param mu: np.ndarray (cells,)
Estimated dispersion parameters across cells for a given gene.
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
Design matrix of location model.
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
Design matrix of shape model.
:param i: int
Index of first dimension in fisher information matrix which is to be computed.
Expand Down Expand Up @@ -129,9 +129,9 @@ def hes_nb_glm_meandisp_block(
Estimated mean parameters across cells for a given gene.
:param mu: np.ndarray (cells,)
Estimated dispersion parameters across cells for a given gene.
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
Design matrix of location model.
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
Design matrix of shape model.
:param i: int
Index of first dimension in fisher information matrix which is to be computed.
Expand Down Expand Up @@ -160,9 +160,9 @@ def hes_nb_glm_bygene(
Estimated mean parameters across cells for a given gene.
:param mu: np.ndarray (cells,)
Estimated dispersion parameters across cells for a given gene.
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
Design matrix of location model.
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
Design matrix of shape model.
:return: np.ndarray (#parameters location model + #parameters shape model, #parameters location model + #parameters shape model)
Expand Down Expand Up @@ -212,9 +212,9 @@ def theta_covar_bygene(
Estimated mean parameters across cells for a given gene.
:param mu: np.ndarray (cells,)
Estimated dispersion parameters across cells for a given gene.
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
Design matrix of location model.
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
:param design_scale: np.ndarray, matrix(cells, #parameters shape model)
Design matrix of shape model.
:return: np.ndarray (#parameters location model + #parameters shape model, #parameters location model + #parameters shape model)
Expand Down Expand Up @@ -243,9 +243,9 @@ def theta_sd_bygene(
Estimated mean parameters across cells for a given gene.
:param disp: np.ndarray (cells,)
Estimated dispersion parameters across cells for a given gene.
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
Design matrix of location model.
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
Design matrix of shape model.
:return: np.ndarray (#parameters location model + #parameters shape model,)
Expand Down
4 changes: 1 addition & 3 deletions diffxpy/testing/det.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,8 @@ def log_fold_change(self, base=np.e, return_type="vector"):
- "dataframe":
return a pandas.DataFrame with columns `gene`, `minuend_<group>`, `subtrahend_<group>` and `logFC`.
- "xarray":
return a xarray.DataArray with dimensions `(minuend, subtrahend, gene)`
:return: either pandas.DataFrame or xarray.DataArray
:return:
"""
factors = set(self.full_design_loc_info.term_names) - set(self.reduced_design_loc_info.term_names)

Expand Down
2 changes: 1 addition & 1 deletion diffxpy/testing/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def wald(
# there is no such column; modify design matrix to create one
design_loc[:, col_indices] = np.where(samples, 1, 0)
elif coef_to_test is not None:
# Directly select coefficients to test from design matrix (xarray):
# Directly select coefficients to test from design matrix:
# Check that coefficients to test are not dependent parameters if constraints are given:
coef_loc_names = glm.data.view_coef_names(design_loc).tolist()
if not np.all([x in coef_loc_names for x in coef_to_test]):
Expand Down
2 changes: 1 addition & 1 deletion diffxpy/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def design_matrix(
formula: Union[None, str] = None,
as_numeric: Union[List[str], Tuple[str], str] = (),
dmat: Union[pd.DataFrame, None] = None,
return_type: str = "xarray"
return_type: str = "patsy"
) -> Union[patsy.design_info.DesignMatrix, pd.DataFrame]:
""" Create a design matrix from some sample description.
Expand Down
2 changes: 1 addition & 1 deletion docs/requires.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ numpy>=1.14.0
scipy
pandas
patsy>=0.5.0
batchglm>=0.6.5
batchglm>=0.6.6
statsmodels
anndata
seaborn
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ numpy>=1.14.0
scipy
pandas
patsy>=0.5.0
batchglm>=0.6.5
batchglm>=0.6.6
statsmodels
anndata
seaborn
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'scipy>=1.2.1',
'pandas',
'patsy>=0.5.0',
'batchglm>=0.6.5',
'batchglm>=0.6.6',
'statsmodels',
],
extras_require={
Expand Down

0 comments on commit f8635bb

Please sign in to comment.