Example #1
0
 def test_detection(self, prepare_table):
     table = prepare_table(self.table)
     preprocessor = DropoutGeneSelection(n_genes=2)
     zero_rate, mean_expr = preprocessor.detection(table.X)
     self.assertEqual(len(zero_rate), len(table.domain.attributes))
     self.assertEqual(len(mean_expr), len(table.domain.attributes))
     npt.assert_allclose(
         zero_rate[:5],
         np.array([0.01092896, 0.02185792, 0.16120219, 0.32240437, 0.61202186]),
         atol=1e-7,
     )
     npt.assert_allclose(
         mean_expr[:5],
         np.array([0.9879741, 0.77491075, 0.78471751, 0.88894012, 0.58119243]),
         atol=1e-7,
     )
Example #2
0
 def __get_selector(self):
     kwargs = {"decay": self.decay, "y_offset": self.y_offset}
     if self.filter_by_nr_of_genes:
         kwargs["n_genes"] = self.n_genes
     else:
         kwargs["x_offset"] = self.x_offset
     return DropoutGeneSelection(**kwargs)
Example #3
0
 def test_warning(self, prepare_table):
     n_genes = 30
     table = prepare_table(self.table)
     with warnings.catch_warnings(record=True) as w:
         filtered_table = DropoutGeneSelection(n_genes)(table)
     self.assertIsInstance(filtered_table, Table)
     self.assertNotEqual(len(filtered_table.domain.attributes), n_genes)
     dropout_warnings = [warning for warning in w if
                         issubclass(warning.category, DropoutWarning)]
     self.assertEqual(len(dropout_warnings), 1)
Example #4
0
 def createinstance(params):
     n_genes = params.get("n_genes", DropoutEditor.DEFAULT_N_GENES)
     return DropoutGeneSelection(n_genes)
Example #5
0
 def test_preserves_density(self, prepare_table):
     table = prepare_table(self.table)
     is_sparse = table.is_sparse()
     filtered_table = DropoutGeneSelection(3)(table)
     self.assertEqual(is_sparse, filtered_table.is_sparse())
Example #6
0
 def test_default(self, prepare_table):
     n_genes = 2
     table = prepare_table(self.table)
     filtered_table = DropoutGeneSelection(n_genes)(table)
     self.assertIsInstance(filtered_table, Table)
     self.assertEqual(len(filtered_table.domain.attributes), n_genes)
Example #7
0
 def commit(self):
     data = None
     if self.selected is not None:
         data = DropoutGeneSelection.filter_columns(self.data,
                                                    self.selected)
     self.Outputs.data.send(data)
Example #8
0
 def _on_curve(self, x: float, y: float):
     if self.__curve is None:
         return False
     return abs(DropoutGeneSelection.y(
         x, self.__decay, self.__x_offset, self.__y_offset) - y) < 0.01