Adding minor tests to scanpy calculation code

This commit is contained in:
Charlotte Weaver
2018-07-13 15:22:05 -07:00
parent 05b9a6833d
commit a5423a6911
2 changed files with 20 additions and 0 deletions

View File

@@ -124,6 +124,7 @@ class ScanpyEngine(CXGDriver):
expression_1 = self.data.X[cells_idx_1, :]
expression_2 = self.data.X[cells_idx_2, :]
diff_exp = stats.ttest_ind(expression_1, expression_2)
# TODO break this up into functions
set1 = np.logical_and(diff_exp.pvalue < pval, diff_exp.statistic > 0)
set2 = np.logical_and(diff_exp.pvalue < pval, diff_exp.statistic < 0)
stat1 = diff_exp.statistic[set1]

View File

@@ -43,6 +43,25 @@ class UtilTest(unittest.TestCase):
for val in n_genes_vals:
assert 300 <= val <= 400
def test_metadata(self):
metadata = self.data.metadata(df=self.data.data)
assert len(metadata) == 2638
assert 'louvain' in metadata[0]
def test_create_graph(self):
graph = self.data.create_graph(df=self.data.data)
assert graph[0][1] == 0.5545382653143183
assert graph[0][2] == 0.6021833809031731
def test_diffexp(self):
diffexp = self.data.diffexp(["AAACATACAACCAC-1", "AACCGATGGTCATG-1"], ["CCGATAGACCTAAG-1", "GGTGGAGAAGTAGA-1"], 0.5, 7)
assert diffexp["celllist1"]["topgenes"] == ['EBNA1BP2', 'DIAPH1', 'SLC25A11', 'SNRNP27', 'COMMD8', 'COTL1', 'GTF3A']
def test_expression(self):
expression = self.data.expression(cells=["AAACATACAACCAC-1"])
data_exp = self.data.data[["AAACATACAACCAC-1"], :].X
for idx in range(len(expression["cells"][0]["e"])):
assert expression["cells"][0]["e"][idx] == data_exp[idx]
if __name__ == '__main__':