Skip to content

Commit f8635bb

Browse files
Merge pull request #111 from theislab/dev
Dev v0.6.11
2 parents b2657b3 + 74f17cf commit f8635bb

File tree

8 files changed

+22
-25
lines changed

8 files changed

+22
-25
lines changed

diffxpy/models/batch_bfgs/optim.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from numpy.linalg import pinv
77
import numpy.random
88
from multiprocessing import Pool
9-
import xarray as xr
109

1110
from .objectives import *
1211

@@ -22,12 +21,12 @@ def __init__(self, Estim_BFGS, nproc):
2221
self._observations = Estim_BFGS.x.shape[0]
2322
self._design_loc = Estim_BFGS.design_loc
2423
self._design_scale = Estim_BFGS.design_scale
25-
self._loss = xr.DataArray(Estim_BFGS.full_loss(nproc))
24+
self._loss = Estim_BFGS.full_loss(nproc)
2625
self._log_probs = -self._loss
2726
self._probs = np.exp(self._log_probs)
28-
self._mles = xr.DataArray(np.transpose(Estim_BFGS.mles()))
29-
self._gradient = xr.DataArray(np.zeros([Estim_BFGS.x.shape[1]]))
30-
self._fisher_inv = xr.DataArray(Estim_BFGS.fisher_inv)
27+
self._mles = np.transpose(Estim_BFGS.mles())
28+
self._gradient = np.zeros([Estim_BFGS.x.shape[1]])
29+
self._fisher_inv = Estim_BFGS.fisher_inv
3130
self._idx_loc = np.arange(0, Estim_BFGS.design_loc.shape[1])
3231
self._idx_scale = np.arange(Estim_BFGS.design_loc.shape[1],
3332
Estim_BFGS.design_loc.shape[1] + Estim_BFGS.design_scale.shape[1])

diffxpy/models/hessian.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def hes_nb_glm_mean_block(
2727
Estimated mean parameters across cells for a given gene.
2828
:param mu: np.ndarray (cells,)
2929
Estimated dispersion parameters across cells for a given gene.
30-
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
30+
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
3131
Design matrix of location model.
32-
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
32+
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
3333
Design matrix of shape model.
3434
:param i: int
3535
Index of first dimension in fisher information matrix which is to be computed.
@@ -78,9 +78,9 @@ def hes_nb_glm_disp_block(
7878
Estimated mean parameters across cells for a given gene.
7979
:param mu: np.ndarray (cells,)
8080
Estimated dispersion parameters across cells for a given gene.
81-
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
81+
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
8282
Design matrix of location model.
83-
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
83+
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
8484
Design matrix of shape model.
8585
:param i: int
8686
Index of first dimension in fisher information matrix which is to be computed.
@@ -129,9 +129,9 @@ def hes_nb_glm_meandisp_block(
129129
Estimated mean parameters across cells for a given gene.
130130
:param mu: np.ndarray (cells,)
131131
Estimated dispersion parameters across cells for a given gene.
132-
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
132+
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
133133
Design matrix of location model.
134-
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
134+
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
135135
Design matrix of shape model.
136136
:param i: int
137137
Index of first dimension in fisher information matrix which is to be computed.
@@ -160,9 +160,9 @@ def hes_nb_glm_bygene(
160160
Estimated mean parameters across cells for a given gene.
161161
:param mu: np.ndarray (cells,)
162162
Estimated dispersion parameters across cells for a given gene.
163-
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
163+
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
164164
Design matrix of location model.
165-
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
165+
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
166166
Design matrix of shape model.
167167
168168
:return: np.ndarray (#parameters location model + #parameters shape model, #parameters location model + #parameters shape model)
@@ -212,9 +212,9 @@ def theta_covar_bygene(
212212
Estimated mean parameters across cells for a given gene.
213213
:param mu: np.ndarray (cells,)
214214
Estimated dispersion parameters across cells for a given gene.
215-
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
215+
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
216216
Design matrix of location model.
217-
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
217+
:param design_scale: np.ndarray, matrix(cells, #parameters shape model)
218218
Design matrix of shape model.
219219
220220
:return: np.ndarray (#parameters location model + #parameters shape model, #parameters location model + #parameters shape model)
@@ -243,9 +243,9 @@ def theta_sd_bygene(
243243
Estimated mean parameters across cells for a given gene.
244244
:param disp: np.ndarray (cells,)
245245
Estimated dispersion parameters across cells for a given gene.
246-
:param design_loc: np.ndarray, matrix, xarray (cells, #parameters location model)
246+
:param design_loc: np.ndarray, matrix (cells, #parameters location model)
247247
Design matrix of location model.
248-
:param design_scale: np.ndarray, matrix, xarray (cells, #parameters shape model)
248+
:param design_scale: np.ndarray, matrix (cells, #parameters shape model)
249249
Design matrix of shape model.
250250
251251
:return: np.ndarray (#parameters location model + #parameters shape model,)

diffxpy/testing/det.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,8 @@ def log_fold_change(self, base=np.e, return_type="vector"):
581581
582582
- "dataframe":
583583
return a pandas.DataFrame with columns `gene`, `minuend_<group>`, `subtrahend_<group>` and `logFC`.
584-
- "xarray":
585-
return a xarray.DataArray with dimensions `(minuend, subtrahend, gene)`
586584
587-
:return: either pandas.DataFrame or xarray.DataArray
585+
:return:
588586
"""
589587
factors = set(self.full_design_loc_info.term_names) - set(self.reduced_design_loc_info.term_names)
590588

diffxpy/testing/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def wald(
594594
# there is no such column; modify design matrix to create one
595595
design_loc[:, col_indices] = np.where(samples, 1, 0)
596596
elif coef_to_test is not None:
597-
# Directly select coefficients to test from design matrix (xarray):
597+
# Directly select coefficients to test from design matrix:
598598
# Check that coefficients to test are not dependent parameters if constraints are given:
599599
coef_loc_names = glm.data.view_coef_names(design_loc).tolist()
600600
if not np.all([x in coef_loc_names for x in coef_to_test]):

diffxpy/testing/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def design_matrix(
123123
formula: Union[None, str] = None,
124124
as_numeric: Union[List[str], Tuple[str], str] = (),
125125
dmat: Union[pd.DataFrame, None] = None,
126-
return_type: str = "xarray"
126+
return_type: str = "patsy"
127127
) -> Union[patsy.design_info.DesignMatrix, pd.DataFrame]:
128128
""" Create a design matrix from some sample description.
129129

docs/requires.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ numpy>=1.14.0
22
scipy
33
pandas
44
patsy>=0.5.0
5-
batchglm>=0.6.5
5+
batchglm>=0.6.6
66
statsmodels
77
anndata
88
seaborn

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ numpy>=1.14.0
22
scipy
33
pandas
44
patsy>=0.5.0
5-
batchglm>=0.6.5
5+
batchglm>=0.6.6
66
statsmodels
77
anndata
88
seaborn

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
'scipy>=1.2.1',
2222
'pandas',
2323
'patsy>=0.5.0',
24-
'batchglm>=0.6.5',
24+
'batchglm>=0.6.6',
2525
'statsmodels',
2626
],
2727
extras_require={

0 commit comments

Comments
 (0)