def commit(self): if self.data is None or self.cont_data is None: self.Outputs.data.send(self.data) self.Outputs.features.send(None) self.Outputs.correlations.send(None) return attrs = [ContinuousVariable("Correlation"), ContinuousVariable("FDR")] metas = [StringVariable("Feature 1"), StringVariable("Feature 2")] domain = Domain(attrs, metas=metas) model = self.vizrank.rank_model x = np.array([[ float(model.data(model.index(row, 0), role)) for role in (Qt.DisplayRole, CorrelationRank.PValRole) ] for row in range(model.rowCount())]) x[:, 1] = FDR(list(x[:, 1])) # pylint: disable=protected-access m = np.array([[ a.name for a in model.data(model.index(row, 0), CorrelationRank._AttrRole) ] for row in range(model.rowCount())], dtype=object) corr_table = Table(domain, x, metas=m) corr_table.name = "Correlations" self.Outputs.data.send(self.data) # data has been imputed; send original attributes self.Outputs.features.send( AttributeList( [self.data.domain[name] for name, _ in self.selection])) self.Outputs.correlations.send(corr_table)
def test_FDR_list(self): p_values = [0.0002, 0.0004, 0.00001, 0.0003, 0.0001] result = FDR(p_values) self.assertIsInstance(result, list) np.testing.assert_almost_equal( np.array([0.00033, 0.0004, 0.00005, 0.00038, 0.00025]), result, decimal=5)
def run(selected_data_transformed: Table, data: Table, result: Result, state: TaskState) -> None: state.set_status("Listing words") result.words = [ i.name for i in selected_data_transformed.domain.attributes ] state.set_status("Computing p-values") result.p_values = hypergeom_p_values(data.X, selected_data_transformed.X, callback=state.set_progress_value) state.set_status("Computing FDR values") result.fdr_values = FDR(result.p_values)
def apply(self): self.clear() self.progressBarInit() self.filter_enabled(False) self.words = [ i.name for i in self.selected_data_transformed.domain.attributes ] self.p_values = hypergeom_p_values(self.data.X, self.selected_data_transformed.X, callback=self.progress) self.fdr_values = FDR(self.p_values) self.filter_and_display() self.filter_enabled(True) self.progressBarFinished()
def test_FDR_no_values(self): self.assertIsNone(FDR(None)) self.assertIsNone(FDR([])) self.assertIsNone(FDR([0.0002, 0.0004], m=0))
def test_FDR_m(self): p_values = np.array([0.0002, 0.0004, 0.00001, 0.0003, 0.0001]) np.testing.assert_almost_equal(np.array( [0.0002, 0.00024, 0.00003, 0.000225, 0.00015]), FDR(p_values, m=3), decimal=5)
def test_FDR_dependent(self): p_values = np.array([0.0002, 0.0004, 0.00001, 0.0003, 0.0001]) np.testing.assert_almost_equal(np.array( [0.00076, 0.00091, 0.00011, 0.00086, 0.00057]), FDR(p_values, dependent=True), decimal=5)
def test_FDR(self): p_values = np.array([0.0002, 0.0004, 0.00001, 0.0003, 0.0001]) np.testing.assert_almost_equal(np.array( [0.00033, 0.0004, 0.00005, 0.00038, 0.00025]), FDR(p_values), decimal=5)