// Update is called once per frame void Update () { if (!networkManager) { networkManager = GameObject.Find ("NetworkManager").GetComponent<CustomNetworkManager> (); return; } if (isLocalPlayer) { if (!rup) { rup = GameObject.FindGameObjectWithTag("ReadyUpPanel"); return; } else if (!selection) { selection = rup.GetComponent<ClassSelection>(); } if (currentClass != selection.selectedClass) { currentClass = selection.selectedClass; CmdSendClass(currentClass); } } }
private void ClsidInput_SelectionChanged(object sender, SelectionChangedEventArgs e) { ViewModel.SelectedItem = e.AddedItems.Count > 0 && e.AddedItems[0] is SearchItem registryClass ? registryClass : default; var selectedClass = ViewModel.SelectedClass; Selection?.Invoke(this, selectedClass); if (selectedClass != default) { ClassSelection?.Invoke(this, selectedClass); } else { InvalidAddress?.Invoke(this, ViewModel.SearchText); } e.Handled = true; }
private async void Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "PatternLab Project (*.plp)|*.plp"; ofd.FileName = ""; if (ofd.ShowDialog() != true) { return; } Dictionary <int, string> allClassDescriptions = new Dictionary <int, string>(); try { WaitWindowWPF.Visibility = Visibility.Visible; await Task.Run(() => { plp = new PatternLabProject(ofd.FileName); allClassDescriptions = plp.MySparseMatrix.ClassDescriptionDictionary; plp.MySparseMatrix.theMatrixInRows.Sort((a, b) => a.Lable.CompareTo(b.Lable)); //Verify if the sparse matrix classes are appropriate List <int> theLabels = plp.MySparseMatrix.ExtractLabels(); List <int> newLabels = new List <int>(); for (int i = 0; i < theLabels.Count; i++) { newLabels.Add(i + 1); } if (theLabels.Count != 2) { ClassSelection cs = new ClassSelection(theLabels, newLabels, plp.MySparseMatrix, true, 3); cs.ShowDialog(); } }); WaitWindowWPF.Visibility = Visibility.Collapsed; ComboBoxFonts.Text = "Times New Roman"; ButtonPlot.IsEnabled = true; ButtonSavePlot.IsEnabled = true; } catch { MessageBox.Show("Problems loading sparse matrix / index files"); return; } //Verify if the classes follow the pattern 1,2,3, else we should correct and warn the uses List <int> lables = plp.MySparseMatrix.ExtractLabels(); Dictionary <int, int> labelConversion = new Dictionary <int, int>(); Dictionary <int, string> newClassDescriptions = new Dictionary <int, string>(); for (int i = 0; i < lables.Count; i++) { labelConversion.Add(lables[i], i + 1); if (lables[i] != i + 1) { MessageBox.Show("Matrix lable " + lables[i] + " will be represented as group " + (i + 1)); } } foreach (sparseMatrixRow r in plp.MySparseMatrix.theMatrixInRows) { r.Lable = labelConversion[r.Lable]; } //---------------------------------- //Update the descriptions, in case they have the word group if (TextBoxC1Name.Text.Equals("Group") && lables.Count >= 1 && plp.MySparseMatrix.ClassDescriptionDictionary.ContainsKey(lables[0]) || allClassDescriptions.ContainsValue(TextBoxC1Name.Text)) { TextBoxC1Name.Text = plp.MySparseMatrix.ClassDescriptionDictionary[lables[0]]; } if (TextBoxC2Name.Text.Equals("Group") && lables.Count >= 2 && plp.MySparseMatrix.ClassDescriptionDictionary.ContainsKey(lables[1]) || allClassDescriptions.ContainsValue(TextBoxC2Name.Text)) { TextBoxC2Name.Text = plp.MySparseMatrix.ClassDescriptionDictionary[lables[1]]; } if (TextBoxC3Name.Text.Equals("Group") && lables.Count >= 3 && plp.MySparseMatrix.ClassDescriptionDictionary.ContainsKey(lables[2]) || allClassDescriptions.ContainsValue(TextBoxC3Name.Text)) { TextBoxC3Name.Text = plp.MySparseMatrix.ClassDescriptionDictionary[lables[2]]; } if (lables.Count != 2) { RadioButtonFilteringProbability.IsEnabled = false; } }
private void buttonParse_Click(object sender, EventArgs e) { openFileDialog1.Filter = "PatternLab Project (*.plp)|*.plp"; openFileDialog1.FileName = ""; if (openFileDialog1.ShowDialog() == DialogResult.Cancel) { return; } plp = new PatternLabProject(openFileDialog1.FileName); //To make sure we dont duplicate info in the table buttonParse.Text = "Wait!"; this.Update(); dataGridView1.Rows.Clear(); folds.Clear(); //try //{ //Calculate the pscores and folds ClassSelection cs; //Verify if the sparse matrix classes are appropriate List <int> theLabels = plp.MySparseMatrix.ExtractLabels(); buttonOptimizeFStringency.Enabled = true; if (theLabels.Count > 2 || (theLabels.Count == 2 && ((!theLabels.Contains(1) || !theLabels.Contains(-1))))) { if (radioButtonAC.Checked) { cs = new ClassSelection(theLabels, new List <int> { -1, 1 }, plp.MySparseMatrix, false, 2); } else if (radioButtonTTest.Checked) { cs = new ClassSelection(theLabels, new List <int> { -1, 1 }, plp.MySparseMatrix, true, 2); } else { cs = new ClassSelection(theLabels, new List <int> { -1, 1 }, plp.MySparseMatrix, true, 2); } cs.ShowDialog(); } if (theLabels.Count == 1 && !theLabels.Contains(-1) && radioButtonTTest.Checked) { cs = new ClassSelection(theLabels, new List <int> { -1 }, plp.MySparseMatrix, true, 1); cs.ShowDialog(); } //Refresh the labels theLabels = plp.MySparseMatrix.ExtractLabels(); //Compress the matrix if (radioButtonAC.Checked) { plp.MySparseMatrix.shatterMatrix(); } else if (radioButtonTTest.Checked) { //Eliminate dims that do not satisfy the minimum readings if (radioButtonAllClasses.Checked) { List <int> allDims = plp.MySparseMatrix.allDims(); List <int> dimsToEliminate = new List <int>(); foreach (int dim in allDims) { List <double> valuesT = plp.MySparseMatrix.ExtractDimValues(dim, 0, true); if (valuesT.Count < (double)numericUpDownMinReplicates.Value) { dimsToEliminate.Add(dim); } } foreach (int dim in dimsToEliminate) { plp.MySparseMatrix.eliminateDim(dim, 0, true); } } else if (radioButtonPerClass.Checked) { List <int> allDims = plp.MySparseMatrix.allDims(); List <int> allClasses = plp.MySparseMatrix.ExtractLabels(); List <int> dimsToEliminate = new List <int>(); foreach (int dim in allDims) { foreach (int label in allClasses) { List <double> valuesT = plp.MySparseMatrix.ExtractDimValues(dim, label, false); if (valuesT.Count < (double)numericUpDownMinReplicates.Value) { dimsToEliminate.Add(dim); } } } dimsToEliminate = dimsToEliminate.Distinct().ToList(); foreach (int dim in dimsToEliminate) { plp.MySparseMatrix.eliminateDim(dim, 0, true); } } } //matrix.saveMatrix(@"C:\Users\Paulo C Carvalho\Desktop\PatternLabExampleData\ExampleData\mstep2DimElimination.txt"); //Add pseudo spectral counts if (!radioButtonUsingLabeledData.Checked) { plp.MySparseMatrix.addPseudoCounts(1); } //Determine what normalization the user specified int normalization = 0; if (radioButtonNRowSigma.Checked) { normalization = 1; } else if (radioButtonNTS.Checked) { normalization = 2; } else if (radioButtonUsingLabeledData.Checked) { normalization = 3; } if (theLabels.Count <= 2) { XFoldCalculations fs = new XFoldCalculations(plp.MySparseMatrix); theData = fs.Xfold(normalization, radioButtonAC.Checked, (double)numericUpDownPValueLowerClip.Minimum); //Calculate all the folds folds.Clear(); foreach (var dataPoint in theData) { double correctedFoldChange; correctedFoldChange = dataPoint.CorrectedFold(); //keep track of fold Changes double foldChangeToAdd = correctedFoldChange; if (foldChangeToAdd > 3) { foldChangeToAdd = 3; } else if (foldChangeToAdd < -3) { foldChangeToAdd = -3; } folds.Add(correctedFoldChange); } //Populate Result Table //Fill the Data Table foreach (XFoldStruct ac in theData) { //Just in case if (ac.GPI == 0) { continue; } try { dataGridView1.Rows.Add( ac.GPI, plp.MyIndex.GetName(ac.GPI), Math.Round(ac.FoldChange, 2), Math.Round(ac.pValue, 4), ac.QuantitationPositiveClass, ac.QuantitationNegativeClass, plp.MyIndex.GetDescription(ac.GPI) ); } catch (Exception e2) { MessageBox.Show(e2.Message); } } } //Were done groupBoxSelectionParameters.Enabled = true; groupBoxFunctions.Enabled = true; //Make sure the canvas is clean //acPlotWPF1.dispose(); //Clear the labels labelBlueDots.Text = "0"; labelGreenDots.Text = "0"; labelRedDots.Text = "0"; labelTotalNumber.Text = "0"; //} //catch (Exception z) //{ // ErrorWindow ew = new ErrorWindow(z.GetBaseException().ToString()); // ew.ShowDialog(); //} buttonParse.Text = "Parse"; }
private void buttonLoad_Click(object sender, EventArgs e) { openFileDialog1.Filter = "PatternLab Project (*.plp)|*.plp"; openFileDialog1.FileName = ""; if (openFileDialog1.ShowDialog() == DialogResult.Cancel) { return; } Dictionary <int, string> allClassDescriptions = new Dictionary <int, string>(); try { plp = new PatternLabProject(openFileDialog1.FileName); allClassDescriptions = plp.MySparseMatrix.ClassDescriptionDictionary; plp.MySparseMatrix.theMatrixInRows.Sort((a, b) => a.Lable.CompareTo(b.Lable)); //Verify if the sparse matrix classes are appropriate List <int> theLabels = plp.MySparseMatrix.ExtractLabels(); List <int> newLabels = new List <int>(); for (int i = 0; i < theLabels.Count; i++) { newLabels.Add(i + 1); } if (theLabels.Count != 2 || (theLabels.Count == 2 && (!theLabels.Contains(1) || !theLabels.Contains(-1)))) { ClassSelection cs = new ClassSelection(theLabels, newLabels, plp.MySparseMatrix, true, 3); cs.ShowDialog(); } groupBoxPlotOptions.Enabled = true; } catch { MessageBox.Show("Problems loading sparse matrix / index files"); return; } //Verify if the classes follow the pattern 1,2,3, else we should correct and warn the uses List <int> lables = plp.MySparseMatrix.ExtractLabels(); Dictionary <int, int> labelConversion = new Dictionary <int, int>(); Dictionary <int, string> newClassDescriptions = new Dictionary <int, string>(); for (int i = 0; i < lables.Count; i++) { labelConversion.Add(lables[i], i + 1); if (lables[i] != i + 1) { MessageBox.Show("Matrix lable " + lables[i] + " will be represented as group " + (i + 1)); } } foreach (sparseMatrixRow r in plp.MySparseMatrix.theMatrixInRows) { r.Lable = labelConversion[r.Lable]; } //---------------------------------- //Update the descriptions, in case they have the word group if (textBoxC1Name.Text.Equals("Group") && lables.Count >= 1 && plp.MySparseMatrix.ClassDescriptionDictionary.ContainsKey(lables[0]) || allClassDescriptions.ContainsValue(textBoxC1Name.Text)) { textBoxC1Name.Text = plp.MySparseMatrix.ClassDescriptionDictionary[lables[0]]; //textBoxC1Name.Text = sMatrix.ClassDescriptionDictionary[1]; } if (textBoxC2Name.Text.Equals("Group") && lables.Count >= 2 && plp.MySparseMatrix.ClassDescriptionDictionary.ContainsKey(lables[1]) || allClassDescriptions.ContainsValue(textBoxC2Name.Text)) { textBoxC2Name.Text = plp.MySparseMatrix.ClassDescriptionDictionary[lables[1]]; //textBoxC2Name.Text = sMatrix.ClassDescriptionDictionary[2]; } if (textBoxC3Name.Text.Equals("Group") && lables.Count >= 3 && plp.MySparseMatrix.ClassDescriptionDictionary.ContainsKey(lables[2]) || allClassDescriptions.ContainsValue(textBoxC3Name.Text)) { textBoxC3Name.Text = plp.MySparseMatrix.ClassDescriptionDictionary[lables[2]];; //textBoxC3Name.Text = sMatrix.ClassDescriptionDictionary[3]; } if (lables.Count != 2) { radioButtonFilteringProbability.Enabled = false; } }