Skip to content

Commit

Permalink
fixed some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsebfischer committed Mar 28, 2019
1 parent 3fd95a4 commit ca27acd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion diffxpy/unit_test/test_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_null_distribution_wald(self, n_cells: int = 2000, n_genes: int = 100):
:param n_cells: Number of cells to simulate (number of observations per test).
:param n_genes: Number of genes to simulate (number of tests).
"""
logging.getLogger("tensorflow").setLevel(logging.INFO)
logging.getLogger("tensorflow").setLevel(logging.ERROR)
logging.getLogger("batchglm").setLevel(logging.WARNING)
logging.getLogger("diffxpy").setLevel(logging.WARNING)

Expand Down
2 changes: 0 additions & 2 deletions diffxpy/unit_test/test_numeric.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import unittest

import numpy as np
import pandas as pd
import scipy.stats as stats
import logging

from batchglm.api.models.glm_nb import Simulator
Expand Down
23 changes: 13 additions & 10 deletions diffxpy/unit_test/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
import scipy.stats as stats

from batchglm.api.models.glm_nb import Simulator, Estimator, InputData
from batchglm.api.models.glm_nb import Simulator
import diffxpy.api as de


Expand Down Expand Up @@ -247,18 +247,21 @@ def test_ztest_de(self, n_cells: int = 2000, n_genes: int = 500):
)
summary = test.summary()

frac_nonde_sig = np.mean(
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), :num_non_de] < 0.05) /
(2 * num_non_de)
)
frac_de_sig = np.mean(
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), num_non_de:] < 0.05) /
(2 * (n_genes - num_non_de))
)
logging.getLogger("diffxpy").info('fraction of non-DE genes with q-value < 0.05: %.1f%%' %
float(100 * np.mean(
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), :num_non_de] < 0.05) /
(2 * num_non_de)
)))
str(np.round(100. * frac_nonde_sig, 3)))
logging.getLogger("diffxpy").info('fraction of DE genes with q-value < 0.05: %.1f%%' %
float(100 * np.mean(
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), num_non_de:] < 0.05) /
(2 * (n_genes - num_non_de))
)))
str(np.round(100. * frac_de_sig, 3)))

# TODO asserts
assert frac_de_sig > 0.5, "too many DE"
assert frac_nonde_sig < 0.5, "too many non-DE"
return True


Expand Down
16 changes: 0 additions & 16 deletions diffxpy/unit_test/test_single_training_strategies.py

This file was deleted.

0 comments on commit ca27acd

Please sign in to comment.