private static void ProcessDataRename(IMatrixData mdata, Parameters param)
 {
     int groupColInd = param.GetSingleChoiceParam("Numerical row").Value;
     string newName = param.GetStringParam("New name").Value;
     string newDescription = param.GetStringParam("New description").Value;
     mdata.NumericRowNames[groupColInd] = newName;
     mdata.NumericRowDescriptions[groupColInd] = newDescription;
 }
Ejemplo n.º 2
0
        public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            bool falseAreIndicated = param.GetSingleChoiceParam("Indicated are").Value == 0;
            int catCol = param.GetSingleChoiceParam("In column").Value;
            string word = param.GetStringParam("Indicator").Value;
            int[] scoreColumns = param.GetMultiChoiceParam("Scores").Value;
            if (scoreColumns.Length == 0){
                processInfo.ErrString = "Please specify at least one column with scores.";
                return;
            }
            bool largeIsGood = param.GetBoolParam("Large values are good").Value;
            int[] showColumns = param.GetMultiChoiceParam("Display quantity").Value;
            if (showColumns.Length == 0){
                processInfo.ErrString = "Please select at least one quantity to display";
                return;
            }
            bool[] indCol = GetIndicatorColumn(falseAreIndicated, catCol, word, data);
            List<string> expColNames = new List<string>();
            List<float[]> expCols = new List<float[]>();
            foreach (int scoreColumn in scoreColumns){
                double[] vals = scoreColumn < data.NumericColumnCount
                    ? data.NumericColumns[scoreColumn]
                    : ArrayUtils.ToDoubles(data.GetExpressionColumn(scoreColumn - data.NumericColumnCount));
                string name = scoreColumn < data.NumericColumnCount
                    ? data.NumericColumnNames[scoreColumn] : data.ExpressionColumnNames[scoreColumn - data.NumericColumnCount];
                int[] order = GetOrder(vals, largeIsGood);
                CalcCurve(ArrayUtils.SubArray(indCol, order), showColumns, name, expCols, expColNames);
            }
            float[,] expData = ToMatrix(expCols);
            data.SetData(data.Name, expColNames, expData, new List<string>(), new List<string[]>(), new List<string>(),
                new List<string[][]>(), new List<string>(), new List<double[]>(), new List<string>(), new List<double[][]>());
        }
 public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
 {
     string[][] col = mdata.CategoryColumns[param.GetSingleChoiceParam("Indicator column").Value];
     string term = param.GetStringParam("Value").Value;
     List<int> inds = new List<int>();
     for (int i = 0; i < col.Length; i++){
         if (Contains(col[i], term)){
             inds.Add(i);
         }
     }
     float[][] profiles = new float[inds.Count][];
     for (int i = 0; i < profiles.Length; i++){
         profiles[i] = mdata.GetExpressionRow(inds[i]);
         float mean = (float) ArrayUtils.Mean(profiles[i]);
         for (int j = 0; j < profiles[i].Length; j++){
             profiles[i][j] -= mean;
         }
     }
     float[] totalProfile = new float[mdata.ExpressionColumnCount];
     for (int i = 0; i < totalProfile.Length; i++){
         List<float> vals = new List<float>();
         foreach (float[] t in profiles){
             float val = t[i];
             if (float.IsNaN(val) || float.IsInfinity(val)){
                 continue;
             }
             vals.Add(val);
         }
         totalProfile[i] = vals.Count > 0 ? ArrayUtils.Median(vals) : float.NaN;
     }
     for (int i = 0; i < mdata.RowCount; i++){
         for (int j = 0; j < mdata.ExpressionColumnCount; j++){
             mdata[i, j] -= totalProfile[j];
         }
     }
 }
 private static void ProcessDataCreate(IMatrixData mdata, Parameters param)
 {
     string name = param.GetStringParam("Row name").Value;
     double[] groupCol = new double[mdata.ExpressionColumnCount];
     for (int i = 0; i < mdata.ExpressionColumnCount; i++){
         string ename = mdata.ExpressionColumnNames[i];
         double value = param.GetDoubleParam(ename).Value;
         groupCol[i] = value;
     }
     mdata.AddNumericRow(name, name, groupCol);
 }
 private static void ProcessDataCreate(IMatrixData mdata, Parameters param)
 {
     string name = param.GetStringParam("Row name").Value;
     string[][] groupCol = new string[mdata.ExpressionColumnCount][];
     for (int i = 0; i < mdata.ExpressionColumnCount; i++){
         string ename = mdata.ExpressionColumnNames[i];
         string value = param.GetStringParam(ename).Value;
         groupCol[i] = value.Length > 0 ? value.Split(';') : new string[0];
     }
     mdata.AddCategoryRow(name, name, groupCol);
 }
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int colInd = param.GetSingleChoiceParam("Column").Value;
            string searchString = param.GetStringParam("Search string").Value;
            if (string.IsNullOrEmpty(searchString)){
                processInfo.ErrString = "Please provide a search string";
                return;
            }
            bool remove = param.GetSingleChoiceParam("Mode").Value == 0;
            bool matchCase = param.GetBoolParam("Match case").Value;
            bool matchWholeWord = param.GetBoolParam("Match whole word").Value;
            string[] vals = mdata.StringColumns[colInd];
            List<int> valids = new List<int>();
            for (int i = 0; i < vals.Length; i++){
                bool matches = Matches(vals[i], searchString, matchCase, matchWholeWord);
                if (matches && !remove){
                    valids.Add(i);
                } else if (!matches && remove){
                    valids.Add(i);
                }
            }
            PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
        }
 public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
 {
     int colInd = param.GetSingleChoiceParam("Column").Value;
     string value = param.GetStringParam("Find").Value;
     bool remove = param.GetSingleChoiceParam("Mode").Value == 0;
     string[][] cats = mdata.CategoryColumns[colInd];
     List<int> valids = new List<int>();
     for (int i = 0; i < cats.Length; i++){
         bool valid = true;
         foreach (string w in cats[i]){
             if (w.Equals(value)){
                 valid = false;
                 break;
             }
         }
         if ((valid && remove) || (!valid && !remove)){
             valids.Add(i);
         }
     }
     mdata.ExtractExpressionRows(valids.ToArray());
 }
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            SingleChoiceWithSubParams p = param.GetSingleChoiceWithSubParams("Row");
            int colInd = p.Value;
            if (colInd < 0) {
                processInfo.ErrString = "No categorical rows available.";
                return;
            }
            MultiChoiceParam mcp = p.GetSubParameters().GetMultiChoiceParam("Values");
            int[] inds = mcp.Value;
            if (inds.Length < 1) {
                processInfo.ErrString = "Please select at least two terms for merging.";
                return;
            }
            string newTerm = param.GetStringParam("New term").Value;
            if (newTerm.Length == 0){
                processInfo.ErrString = "Please specify a new term.";
                return;
            }

            string[] values = new string[inds.Length];
            for (int i = 0; i < values.Length; i++) {
                values[i] = mdata.GetCategoryRowValuesAt(colInd)[inds[i]];
            }
            HashSet<string> value = new HashSet<string>(values);
            string[][] cats = mdata.GetCategoryRowAt(colInd);
            string[][] newCat = new string[cats.Length][];
            for (int i = 0; i < cats.Length; i++){
                string[] w = cats[i];
                bool changed = false;
                for (int j = 0; j < w.Length; j++){
                    if (value.Contains(w[j])){
                        w[j] = newTerm;
                        changed = true;
                    }
                }
                if (changed){
                    Array.Sort(w);
                }
                newCat[i] = w;
            }
            mdata.SetCategoryRowAt(newCat, colInd);
        }
Ejemplo n.º 9
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int colIndex = param.GetSingleChoiceParam("Column with second last AA").Value;
            string aas = param.GetStringParam("Amino acids").Value;
            string[][] col = mdata.GetCategoryColumnAt(colIndex);
            List<int> validRows = new List<int>();
            for (int i = 0; i < mdata.RowCount; i++){
                string[] x = col[i];
                for (int j = 0; j < x.Length; j++){
                    if (x[j].Length != 1){
                        processInfo.ErrString = "Some of the entries in column " + mdata.CategoryColumnNames[colIndex] +
                            " do not contain amino acids";
                        return;
                    }
                }
                bool keep = JudgeIfKept(aas, x);
                if (keep){
                    validRows.Add(i);
                }
            }
            mdata.ExtractExpressionRows(validRows.ToArray());
        }
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            string regexStr = param.GetStringParam("Regular expression").Value;
            Regex regex = new Regex(regexStr);
            for (int i = 0; i < mdata.ExpressionColumnCount; i++){
                string newName = regex.Match(mdata.ExpressionColumnNames[i]).Groups[1].ToString();
                if (string.IsNullOrEmpty(newName)){
                    processInfo.ErrString = "Applying parse rule to '" + mdata.ExpressionColumnNames[i] +
                        "' results in an empty string.";
                    return;
                }
                mdata.ExpressionColumnNames[i] = newName;
            }
        }
Ejemplo n.º 11
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            string regexStr = param.GetStringParam("Regular expression").Value;
            Regex regex = new Regex(regexStr);
            int[] inds = param.GetMultiChoiceParam("Columns").Value;
            foreach (int ind in inds){
                ProcessCol(mdata.StringColumns[ind], regex);
            }
        }
Ejemplo n.º 12
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int minCount = param.GetIntParam("Min. count").Value;
            int selCol = param.GetSingleChoiceParam("Selection").Value;
            string value = param.GetStringParam("Value").Value;
            int[] catIndices = param.GetMultiChoiceParam("Categories").Value;
            bool[] selection = null;
            if (selCol < mdata.CategoryColumnCount){
                selection = new bool[mdata.RowCount];
                string[][] x = mdata.GetCategoryColumnAt(selCol);
                for (int i = 0; i < selection.Length; i++){
                    if (x[i] != null){
                        for (int j = 0; j < x[i].Length; j++){
                            if (x[i][j].Equals(value)){
                                selection[i] = true;
                                break;
                            }
                        }
                    }
                }
            }
            CountingResult result = CountCategories(mdata, selection, selCol, catIndices);
            CreateMatrixData(result, mdata, minCount, selection);
        }
Ejemplo n.º 13
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            List<string> expressionColumnNames = new List<string>();
            HashSet<string> taken = new HashSet<string>();
            for (int i = 0; i < mdata.ExpressionColumnCount; i++){
                string newName = param.GetStringParam(mdata.ExpressionColumnNames[i]).Value;
                if (taken.Contains(newName)){
                    processInfo.ErrString = "Name " + newName + " is contained multiple times";
                    return;
                }
                taken.Add(newName);
                expressionColumnNames.Add(newName);
            }
            mdata.ExpressionColumnNames = expressionColumnNames;
            taken = new HashSet<string>();
            List<string> numericColumnNames = new List<string>();
            for (int i = 0; i < mdata.NumericColumnCount; i++){
                string newName = param.GetStringParam(mdata.NumericColumnNames[i]).Value;
                if (taken.Contains(newName)){
                    processInfo.ErrString = "Name " + newName + " is contained multiple times";
                    return;
                }
                taken.Add(newName);
                numericColumnNames.Add(newName);
            }
            mdata.NumericColumnNames = numericColumnNames;
            taken = new HashSet<string>();
            List<string> categoryColumnNames = new List<string>();
            for (int i = 0; i < mdata.CategoryColumnCount; i++){
                string newName = param.GetStringParam(mdata.CategoryColumnNames[i]).Value;
                if (taken.Contains(newName)){
                    processInfo.ErrString = "Name " + newName + " is contained multiple times";
                    return;
                }
                taken.Add(newName);
                categoryColumnNames.Add(newName);
            }
            mdata.CategoryColumnNames = categoryColumnNames;
            taken = new HashSet<string>();
            List<string> stringColumnNames = new List<string>();
            for (int i = 0; i < mdata.StringColumnCount; i++){
                string newName = param.GetStringParam(mdata.StringColumnNames[i]).Value;
                if (taken.Contains(newName)){
                    processInfo.ErrString = "Name " + newName + " is contained multiple times";
                    return;
                }
                taken.Add(newName);
                stringColumnNames.Add(newName);
            }
            mdata.StringColumnNames = stringColumnNames;
            taken = new HashSet<string>();
            List<string> multiNumericColumnNames = new List<string>();
            for (int i = 0; i < mdata.MultiNumericColumnCount; i++){
                string newName = param.GetStringParam(mdata.MultiNumericColumnNames[i]).Value;
                if (taken.Contains(newName)){
                    processInfo.ErrString = "Name " + newName + " is contained multiple times";
                    return;
                }
                taken.Add(newName);
                multiNumericColumnNames.Add(newName);
            }
            mdata.MultiNumericColumnNames = multiNumericColumnNames;
        }
Ejemplo n.º 14
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            string colName = param.GetStringParam("Name of new column").Value;
            int[] columns = param.GetMultiChoiceParam("Categories").Value;
            bool inverse = param.GetBoolParam("Inverse").Value;
            int[] catCols;
            int[] stringCols;
            Split(columns, out catCols, out stringCols, mdata.CategoryColumnCount);
            string[] word1 = param.GetMultiStringParam("Search terms").Value;
            if (word1.Length == 0){
                processInfo.ErrString = "Please specify one or more search terms.";
                return;
            }
            if (string.IsNullOrEmpty(colName)){
                colName = word1[0];
            }
            string[] word = new string[word1.Length];
            for (int i = 0; i < word.Length; i++){
                word[i] = word1[i].ToLower().Trim();
            }
            bool[] indicator = new bool[mdata.RowCount];
            foreach (int col in catCols){
                string[][] cat = mdata.GetCategoryColumnAt(col);
                for (int i = 0; i < cat.Length; i++){
                    foreach (string s in cat[i]){
                        foreach (string s1 in word){
                            if (s.ToLower().Contains(s1)){
                                indicator[i] = true;
                                break;
                            }
                        }
                    }
                }
            }
            foreach (string[] txt in stringCols.Select(col => mdata.StringColumns[col])){
                for (int i = 0; i < txt.Length; i++){
                    string s = txt[i];
                    foreach (string s1 in word){
                        if (s.ToLower().Contains(s1)){
                            indicator[i] = true;
                            break;
                        }
                    }
                }
            }
            string[][] newCol = new string[indicator.Length][];
            for (int i = 0; i < newCol.Length; i++){
                bool yes = inverse ? !indicator[i] : indicator[i];
                newCol[i] = yes ? new[]{"+"} : new string[0];
            }
            mdata.AddCategoryColumn(colName, "", newCol);
        }
Ejemplo n.º 15
0
 public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
 {
     List<string> expressionColumnNames = new List<string>();
     for (int i = 0; i < mdata.ExpressionColumnCount; i++){
         expressionColumnNames.Add(param.GetStringParam(mdata.ExpressionColumnNames[i]).Value);
     }
     mdata.ExpressionColumnNames = expressionColumnNames;
     List<string> numericColumnNames = new List<string>();
     for (int i = 0; i < mdata.NumericColumnCount; i++){
         numericColumnNames.Add(param.GetStringParam(mdata.NumericColumnNames[i]).Value);
     }
     mdata.NumericColumnNames = numericColumnNames;
     List<string> categoryColumnNames = new List<string>();
     for (int i = 0; i < mdata.CategoryColumnCount; i++){
         categoryColumnNames.Add(param.GetStringParam(mdata.CategoryColumnNames[i]).Value);
     }
     mdata.CategoryColumnNames = categoryColumnNames;
     List<string> stringColumnNames = new List<string>();
     for (int i = 0; i < mdata.StringColumnCount; i++){
         stringColumnNames.Add(param.GetStringParam(mdata.StringColumnNames[i]).Value);
     }
     mdata.StringColumnNames = stringColumnNames;
 }