mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-05 04:18:11 +08:00
Adding minor tests to scanpy calculation code
This commit is contained in:
@@ -124,6 +124,7 @@ class ScanpyEngine(CXGDriver):
|
|||||||
expression_1 = self.data.X[cells_idx_1, :]
|
expression_1 = self.data.X[cells_idx_1, :]
|
||||||
expression_2 = self.data.X[cells_idx_2, :]
|
expression_2 = self.data.X[cells_idx_2, :]
|
||||||
diff_exp = stats.ttest_ind(expression_1, expression_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)
|
set1 = np.logical_and(diff_exp.pvalue < pval, diff_exp.statistic > 0)
|
||||||
set2 = 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]
|
stat1 = diff_exp.statistic[set1]
|
||||||
|
|||||||
@@ -43,6 +43,25 @@ class UtilTest(unittest.TestCase):
|
|||||||
for val in n_genes_vals:
|
for val in n_genes_vals:
|
||||||
assert 300 <= val <= 400
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user