public static void FilterColumns(IMatrixData mdata, Parameters parameters, int[] cols) { bool reduceMatrix = GetReduceMatrix(parameters); if (reduceMatrix){ mdata.ExtractExpressionColumns(cols); } else{ Array.Sort(cols); string[][] row = new string[mdata.ExpressionColumnCount][]; for (int i = 0; i < row.Length; i++){ bool contains = Array.BinarySearch(cols, i) >= 0; row[i] = contains ? new[]{"Keep"} : new[]{"Discard"}; } mdata.AddCategoryRow("Filter", "", row); } }
public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { int[] exColInds = param.GetMultiChoiceParam("Expression columns").Value; int[] numColInds = param.GetMultiChoiceParam("Numerical columns").Value; int[] multiNumColInds = param.GetMultiChoiceParam("Multi-numerical columns").Value; int[] catColInds = param.GetMultiChoiceParam("Categorical columns").Value; int[] textColInds = param.GetMultiChoiceParam("Text columns").Value; data.ExtractExpressionColumns(exColInds); data.NumericColumns = ArrayUtils.SubList(data.NumericColumns, numColInds); data.NumericColumnNames = ArrayUtils.SubList(data.NumericColumnNames, numColInds); data.NumericColumnDescriptions = ArrayUtils.SubList(data.NumericColumnDescriptions, numColInds); data.MultiNumericColumns = ArrayUtils.SubList(data.MultiNumericColumns, multiNumColInds); data.MultiNumericColumnNames = ArrayUtils.SubList(data.MultiNumericColumnNames, multiNumColInds); data.MultiNumericColumnDescriptions = ArrayUtils.SubList(data.MultiNumericColumnDescriptions, multiNumColInds); data.CategoryColumns = PerseusPluginUtils.GetCategoryColumns(data, catColInds); data.CategoryColumnNames = ArrayUtils.SubList(data.CategoryColumnNames, catColInds); data.CategoryColumnDescriptions = ArrayUtils.SubList(data.CategoryColumnDescriptions, catColInds); data.StringColumns = ArrayUtils.SubList(data.StringColumns, textColInds); data.StringColumnNames = ArrayUtils.SubList(data.StringColumnNames, textColInds); data.StringColumnDescriptions = ArrayUtils.SubList(data.StringColumnDescriptions, textColInds); }
public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { int[] exColInds = GetValidExCols(data); int[] numColInds = GetValidNumCols(data); int[] multiNumColInds = GetValidMultiNumCols(data); int[] catColInds = GetValidCatCols(data); int[] textColInds = GetValidTextCols(data); if (exColInds.Length < data.ExpressionColumnCount){ data.ExtractExpressionColumns(exColInds); } if (numColInds.Length < data.NumericColumnCount){ data.NumericColumns = ArrayUtils.SubList(data.NumericColumns, numColInds); data.NumericColumnNames = ArrayUtils.SubList(data.NumericColumnNames, numColInds); data.NumericColumnDescriptions = ArrayUtils.SubList(data.NumericColumnDescriptions, numColInds); } if (multiNumColInds.Length < data.MultiNumericColumnCount){ data.MultiNumericColumns = ArrayUtils.SubList(data.MultiNumericColumns, multiNumColInds); data.MultiNumericColumnNames = ArrayUtils.SubList(data.MultiNumericColumnNames, multiNumColInds); data.MultiNumericColumnDescriptions = ArrayUtils.SubList(data.MultiNumericColumnDescriptions, multiNumColInds); } if (catColInds.Length < data.CategoryColumnCount){ data.CategoryColumns = PerseusPluginUtils.GetCategoryColumns(data, catColInds); data.CategoryColumnNames = ArrayUtils.SubList(data.CategoryColumnNames, catColInds); data.CategoryColumnDescriptions = ArrayUtils.SubList(data.CategoryColumnDescriptions, catColInds); } if (textColInds.Length < data.StringColumnCount){ data.StringColumns = ArrayUtils.SubList(data.StringColumns, textColInds); data.StringColumnNames = ArrayUtils.SubList(data.StringColumnNames, textColInds); data.StringColumnDescriptions = ArrayUtils.SubList(data.StringColumnDescriptions, textColInds); } }
private static void ExpressionToNumeric(IList<int> colInds, IMatrixData mdata) { int[] remainingInds = ArrayUtils.Complement(colInds, mdata.NumericColumnCount); foreach (int colInd in colInds){ double[] d = ArrayUtils.ToDoubles(mdata.GetExpressionColumn(colInd)); mdata.AddNumericColumn(mdata.ExpressionColumnNames[colInd], mdata.ExpressionColumnDescriptions[colInd], d); } mdata.ExtractExpressionColumns(remainingInds); }