private void mnuItemFilterpq_Click(object sender, EventArgs e) { string filtTableName = null; if (!mhtDatasets.ContainsKey("p-Values")) { MessageBox.Show("'p-Values' table not found; cannot filter using ANOVA results", "Error"); return; } var anovaParams = new frmFilterAnova { PopulateDataComboBox = AvailableDataSources() }; var pvaluesTable = mhtDatasets["p-Values"]; anovaParams.PopulateListBox = clsDataTable.DataTableColumns(pvaluesTable.mDTable, true); if (anovaParams.ShowDialog() == DialogResult.OK) { var column = anovaParams.SelectedColumn + 1; var datasetNameInR = (mhtDatasets[anovaParams.Dataset]).mstrRdatasetName; var thres = anovaParams.Thres.ToString(CultureInfo.InvariantCulture); string ltgt; if (anovaParams.LessThan) { ltgt = @"smode=""LT"""; } else { ltgt = @"smode=""GT"""; } var rcmd = "filterResult <- filterAnova(pvalues," + datasetNameInR + "," + thres + "," + column + "," + ltgt + ")"; bool executionError; bool dataNotFound; try { mintFilterTblNum++; filtTableName = "filteredData" + mintFilterTblNum.ToString(); mRConnector.EvaluateNoReturn(rcmd); mRConnector.EvaluateNoReturn("err<-filterResult$error"); mRConnector.EvaluateNoReturn("nodata<-filterResult$NoData"); mRConnector.EvaluateNoReturn(filtTableName + "<-filterResult$Filtered"); executionError = mRConnector.GetSymbolAsBool("err"); dataNotFound = mRConnector.GetSymbolAsBool("nodata"); } catch (Exception ex) { Console.WriteLine(ex.Message); executionError = true; dataNotFound = true; } if (executionError || dataNotFound) { MessageBox.Show("No matches found. Check if you selected the correct dataset or" + Environment.NewLine + "if your cutoff is too conservative.", "Problem...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (mRConnector.GetTableFromRmatrix(filtTableName)) { var filteredDataFromR = mRConnector.DataTable.Copy(); filteredDataFromR.TableName = filtTableName; filteredDataFromR.Columns[0].ColumnName = "ID"; AddDataset2HashTable(filteredDataFromR); if (mhtDatasets.ContainsKey("Filtered Data" + mintFilterTblNum)) { AddDataNode(mhtDatasets["Filtered Data" + mintFilterTblNum]); } } } }
private void mnuItemFilterpq_Click(object sender, EventArgs e) { string filtTableName = null; if (!mhtDatasets.ContainsKey("p-Values")) { MessageBox.Show("'p-Values' table not found; cannot filter using ANOVA results", "Error"); return; } var mfrmFilterANOVA = new frmFilterAnova { PopulateDataComboBox = AvailableDataSources() }; var mclsAnova = mhtDatasets["p-Values"]; mfrmFilterANOVA.PopulateListBox = clsDataTable.DataTableColumns(mclsAnova.mDTable, true); if (mfrmFilterANOVA.ShowDialog() == DialogResult.OK) { var column = mfrmFilterANOVA.SelectedColumn + 1; var datasetNameInR = (mhtDatasets[mfrmFilterANOVA.Dataset]).mstrRdatasetName; var thres = mfrmFilterANOVA.Thres.ToString(CultureInfo.InvariantCulture); string ltgt; if (mfrmFilterANOVA.LessThan) ltgt = @"smode=""LT"""; else ltgt = @"smode=""GT"""; var rcmd = "filterResult <- filterAnova(pvalues," + datasetNameInR + "," + thres + "," + column.ToString() + "," + ltgt + ")"; var mblErr = true; var mblNoData = true; try { mintFilterTblNum++; filtTableName = "filteredData" + mintFilterTblNum.ToString(); mRConnector.EvaluateNoReturn(rcmd); mRConnector.EvaluateNoReturn("err<-filterResult$error"); mRConnector.EvaluateNoReturn("nodata<-filterResult$NoData"); mRConnector.EvaluateNoReturn(filtTableName + "<-filterResult$Filtered"); mblErr = mRConnector.GetSymbolAsBool("err"); mblNoData = mRConnector.GetSymbolAsBool("nodata"); } catch (Exception ex) { Console.WriteLine(ex.Message); mblErr = true; mblNoData = true; } if (mblErr || mblNoData) MessageBox.Show("No matches found. Check if you selected the correct dataset or" + Environment.NewLine + "if your cutoff is too conservative.", "Problem...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else if (mRConnector.GetTableFromRmatrix(filtTableName)) { var mDTfiltered = mRConnector.DataTable.Copy(); mDTfiltered.TableName = filtTableName; mDTfiltered.Columns[0].ColumnName = "ID"; AddDataset2HashTable(mDTfiltered); if (mhtDatasets.ContainsKey("Filtered Data" + mintFilterTblNum)) AddDataNode(mhtDatasets["Filtered Data" + mintFilterTblNum]); } } }