当前位置: 首页>>代码示例>>C#>>正文


C# IMatrixData.AddNumericRow方法代码示例

本文整理汇总了C#中IMatrixData.AddNumericRow方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.AddNumericRow方法的具体用法?C# IMatrixData.AddNumericRow怎么用?C# IMatrixData.AddNumericRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMatrixData的用法示例。


在下文中一共展示了IMatrixData.AddNumericRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadMatrixData


//.........这里部分代码省略.........
                            q = q.Substring(1, q.Length - 2);
                        }
                        if (q.Length >= 2 && q[0] == '\'' && q[q.Length - 1] == '\''){
                            q = q.Substring(1, q.Length - 2);
                        }
                        string[] ww = q.Length == 0 ? new string[0] : q.Split(';');
                        List<int> valids = new List<int>();
                        for (int j = 0; j < ww.Length; j++){
                            ww[j] = ww[j].Trim();
                            if (ww[j].Length > 0){
                                valids.Add(j);
                            }
                        }
                        ww = ArrayUtils.SubArray(ww, valids);
                        Array.Sort(ww);
                        if (categoryAnnotation[i].Length > count){
                            categoryAnnotation[i][count] = ww;
                        }
                    }
                }
                for (int i = 0; i < textColIndices.Count; i++){
                    if (textColIndices[i] >= w.Length){
                        stringAnnotation[i][count] = "";
                    } else{
                        string q = w[textColIndices[i]].Trim();
                        if (stringAnnotation[i].Length > count){
                            stringAnnotation[i][count] = RemoveSplitWhitespace(RemoveQuotes(q));
                        }
                    }
                }
                count++;
            }
            reader.Close();
            string[] columnNames = ArrayUtils.SubArray(colNames, mainColIndices);
            if (shortenExpressionNames){
                columnNames = StringUtils.RemoveCommonSubstrings(columnNames, true);
            }
            string[] catColnames = ArrayUtils.SubArray(colNames, catColIndices);
            string[] numColnames = ArrayUtils.SubArray(colNames, numColIndices);
            string[] multiNumColnames = ArrayUtils.SubArray(colNames, multiNumColIndices);
            string[] textColnames = ArrayUtils.SubArray(colNames, textColIndices);
            matrixData.Name = origin;
            matrixData.ColumnNames = RemoveQuotes(columnNames);
            matrixData.Values.Set(mainValues);
            if (hasAddtlMatrices){
                matrixData.Quality.Set(qualityValues);
                matrixData.IsImputed.Set(isImputedValues);
            } else{
                matrixData.Quality.Set(new float[mainValues.GetLength(0), mainValues.GetLength(1)]);
                matrixData.IsImputed.Set(new bool[mainValues.GetLength(0), mainValues.GetLength(1)]);
            }
            matrixData.SetAnnotationColumns(RemoveQuotes(textColnames), stringAnnotation, RemoveQuotes(catColnames),
                categoryAnnotation, RemoveQuotes(numColnames), numericAnnotation, RemoveQuotes(multiNumColnames),
                multiNumericAnnotation);
            if (colDescriptions != null){
                string[] columnDesc = ArrayUtils.SubArray(colDescriptions, mainColIndices);
                string[] catColDesc = ArrayUtils.SubArray(colDescriptions, catColIndices);
                string[] numColDesc = ArrayUtils.SubArray(colDescriptions, numColIndices);
                string[] multiNumColDesc = ArrayUtils.SubArray(colDescriptions, multiNumColIndices);
                string[] textColDesc = ArrayUtils.SubArray(colDescriptions, textColIndices);
                matrixData.ColumnDescriptions = new List<string>(columnDesc);
                matrixData.NumericColumnDescriptions = new List<string>(numColDesc);
                matrixData.CategoryColumnDescriptions = new List<string>(catColDesc);
                matrixData.StringColumnDescriptions = new List<string>(textColDesc);
                matrixData.MultiNumericColumnDescriptions = new List<string>(multiNumColDesc);
            }
            foreach (string key in catAnnotatRows.Keys){
                string name = key;
                string[] svals = ArrayUtils.SubArray(catAnnotatRows[key], mainColIndices);
                string[][] cat = new string[svals.Length][];
                for (int i = 0; i < cat.Length; i++){
                    string s = svals[i].Trim();
                    cat[i] = s.Length > 0 ? s.Split(';') : new string[0];
                    List<int> valids = new List<int>();
                    for (int j = 0; j < cat[i].Length; j++){
                        cat[i][j] = cat[i][j].Trim();
                        if (cat[i][j].Length > 0){
                            valids.Add(j);
                        }
                    }
                    cat[i] = ArrayUtils.SubArray(cat[i], valids);
                    Array.Sort(cat[i]);
                }
                matrixData.AddCategoryRow(name, name, cat);
            }
            foreach (string key in numAnnotatRows.Keys){
                string name = key;
                string[] svals = ArrayUtils.SubArray(numAnnotatRows[key], mainColIndices);
                double[] num = new double[svals.Length];
                for (int i = 0; i < num.Length; i++){
                    string s = svals[i].Trim();
                    num[i] = double.NaN;
                    double.TryParse(s, out num[i]);
                }
                matrixData.AddNumericRow(name, name, num);
            }
            matrixData.Origin = origin;
            progress(0);
            status("");
        }
开发者ID:JurgenCox,项目名称:perseus-plugins,代码行数:101,代码来源:PerseusUtils.cs

示例2: ProcessData


//.........这里部分代码省略.........
                Dictionary<int, List<double>> factors = new Dictionary<int, List<double>>();
                for (int i = 0; i < columns.Count; i++){
                    if (factors.ContainsKey(grouping[i])){
                        factors[grouping[i]].Add(normalizationFactors[i]);
                    } else{
                        factors.Add(grouping[i], new List<double>{normalizationFactors[i]});
                    }
                }
                double[] averagedNormalizationFactors = new double[columns.Count];
                for (int i = 0; i < columns.Count; i++){
                    List<double> factor;
                    factors.TryGetValue(grouping[i], out factor);
                    averagedNormalizationFactors[i] = ArrayUtils.Mean(factor);
                }
                normalizationFactors = averagedNormalizationFactors;
            }
            // loop over all selected columns and calculate copy numbers
            for (int col = 0; col < columns.Count; col++){
                string sampleName = sampleNames[col];
                double[] column = columns[col];
                double factor = normalizationFactors[col];
                double[] copyNumbers = new double[mdata.RowCount];
                double[] concentrations = new double[mdata.RowCount]; // femtoliters
                double[] massFraction = new double[mdata.RowCount];
                double[] moleFraction = new double[mdata.RowCount];
                double totalProtein = 0; // picograms
                double histoneMass = 0; // picograms
                double totalMolecules = 0;
                for (int row = 0; row < mdata.RowCount; row++){
                    if (!double.IsNaN(column[row]) && !double.IsNaN(mw[row])){
                        copyNumbers[row] = (column[row]/detectabilityNormFactor[row])*factor;
                        totalMolecules += copyNumbers[row];
                        totalProtein += (copyNumbers[row]*mw[row]*1e12)/avogadro; // picograms
                        if (ArrayUtils.Contains(histoneRows, row)){
                            histoneMass += (copyNumbers[row]*mw[row]*1e12)/avogadro; // picograms
                        }
                    }
                }
                double totalVolume = (totalProtein/(param.GetDoubleParam("Total cellular protein concentration [g/l]").Value))*1000;
                // femtoliters
                for (int row = 0; row < mdata.RowCount; row++){
                    if (!double.IsNaN(column[row]) && !double.IsNaN(mw[row])){
                        concentrations[row] = ((copyNumbers[row]/(totalVolume*1e-15))/avogadro)*1e9; // nanomolar
                        massFraction[row] = (((copyNumbers[row]*mw[row]*1e12)/avogadro)/totalProtein)*1e6; // ppm
                        moleFraction[row] = (copyNumbers[row]/totalMolecules)*1e6; // ppm
                    }
                }
                string suffix = (sampleName == "") ? "" : " " + sampleName;
                if (ArrayUtils.Contains(outputColumns, 0)){
                    mdata.AddNumericColumn("Copy number" + suffix, "", copyNumbers);
                }
                if (ArrayUtils.Contains(outputColumns, 1)){
                    mdata.AddNumericColumn("Concentration [nM]" + suffix, "", concentrations);
                }
                if (ArrayUtils.Contains(outputColumns, 2)){
                    mdata.AddNumericColumn("Abundance (mass/total mass) [*10^-6]" + suffix, "", massFraction);
                }
                if (ArrayUtils.Contains(outputColumns, 3)){
                    mdata.AddNumericColumn("Abundance (molecules/total molecules) [*10^-6]" + suffix, "", moleFraction);
                }
                double[] rank = ArrayUtils.Rank(copyNumbers);
                double[] relativeRank = new double[mdata.RowCount];
                double validRanks = mdata.RowCount;
                for (int row = 0; row < mdata.RowCount; row++){
                    // remove rank for protein with no copy number information
                    if (double.IsNaN((copyNumbers[row])) || copyNumbers[row] == 0){
                        rank[row] = double.NaN;
                        validRanks--; // do not consider as valid
                    }
                    // invert ranking, so that rank 0 is the most abundant protein
                    rank[row] = mdata.RowCount - rank[row];
                }
                for (int row = 0; row < mdata.RowCount; row++){
                    relativeRank[row] = rank[row]/validRanks;
                }
                if (ArrayUtils.Contains(outputColumns, 4)){
                    mdata.AddNumericColumn("Copy number rank" + suffix, "", rank);
                }
                if (ArrayUtils.Contains(outputColumns, 5)){
                    mdata.AddNumericColumn("Relative copy number rank" + suffix, "", relativeRank);
                }
                if (intensityCols[col] < mdata.ExpressionColumnCount &&
                    param.GetSingleChoiceWithSubParams("Averaging mode").Value != 3){
                    totalProteinRow[intensityCols[col]] = Math.Round(totalProtein, 2);
                    totalMoleculesRow[intensityCols[col]] = Math.Round(totalMolecules, 0);
                    organismRow[intensityCols[col]] = new string[]{organism.name};
                    histoneMassRow[intensityCols[col]] = Math.Round(histoneMass, 4);
                    ploidyRow[intensityCols[col]] = Math.Round((histoneMass*1e-12)/cValue, 2);
                    cellVolumeRow[intensityCols[col]] = Math.Round(totalVolume, 2); // femtoliters
                }
            }
            if (param.GetSingleChoiceWithSubParams("Averaging mode").Value != 3 && ArrayUtils.Contains(outputColumns, 6)){
                mdata.AddNumericRow("Total protein [pg/cell]", "", totalProteinRow);
                mdata.AddNumericRow("Total molecules per cell", "", totalMoleculesRow);
                mdata.AddCategoryRow("Organism", "", organismRow);
                mdata.AddNumericRow("Histone mass [pg/cell]", "", histoneMassRow);
                mdata.AddNumericRow("Ploidy", "", ploidyRow);
                mdata.AddNumericRow("Cell volume [fl]", "", cellVolumeRow);
            }
        }
开发者ID:neuhauser,项目名称:perseus-plugins,代码行数:101,代码来源:CopyNumbers.cs

示例3: ProcessDataCreate

 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);
 }
开发者ID:neuhauser,项目名称:perseus-plugins,代码行数:11,代码来源:CreateNumericalAnnotRow.cs

示例4: LoadData


//.........这里部分代码省略.........
                for (int i = 0; i < multiNumColIndices.Count; i++){
                    if (multiNumColIndices[i] >= w.Length){
                        multiNumericAnnotation[i][count] = new double[0];
                    } else{
                        string q = w[multiNumColIndices[i]].Trim();
                        if (q.Length >= 2 && q[0] == '\"' && q[q.Length - 1] == '\"'){
                            q = q.Substring(1, q.Length - 2);
                        }
                        if (q.Length >= 2 && q[0] == '\'' && q[q.Length - 1] == '\''){
                            q = q.Substring(1, q.Length - 2);
                        }
                        string[] ww = q.Length == 0 ? new string[0] : q.Split(';');
                        multiNumericAnnotation[i][count] = new double[ww.Length];
                        for (int j = 0; j < ww.Length; j++){
                            double q1;
                            bool success = double.TryParse(ww[j], out q1);
                            multiNumericAnnotation[i][count][j] = success ? q1 : double.NaN;
                        }
                    }
                }
                for (int i = 0; i < catColIndices.Count; i++){
                    if (catColIndices[i] >= w.Length){
                        categoryAnnotation[i][count] = new string[0];
                    } else{
                        string q = w[catColIndices[i]].Trim();
                        if (q.Length >= 2 && q[0] == '\"' && q[q.Length - 1] == '\"'){
                            q = q.Substring(1, q.Length - 2);
                        }
                        if (q.Length >= 2 && q[0] == '\'' && q[q.Length - 1] == '\''){
                            q = q.Substring(1, q.Length - 2);
                        }
                        string[] ww = q.Length == 0 ? new string[0] : q.Split(';');
                        Array.Sort(ww);
                        categoryAnnotation[i][count] = ww;
                    }
                }
                for (int i = 0; i < numColIndices.Count; i++){
                    if (numColIndices[i] >= w.Length){
                        numericAnnotation[i][count] = double.NaN;
                    } else{
                        double q;
                        bool success = double.TryParse(w[numColIndices[i]].Trim(), out q);
                        numericAnnotation[i][count] = success ? q : double.NaN;
                    }
                }
                for (int i = 0; i < textColIndices.Count; i++){
                    if (textColIndices[i] >= w.Length){
                        stringAnnotation[i][count] = "";
                    } else{
                        string q = w[textColIndices[i]].Trim();
                        stringAnnotation[i][count] = RemoveSplitWhitespace(RemoveQuotes(q));
                    }
                }
                count++;
            }
            reader.Close();
            string[] columnNames = ArrayUtils.SubArray(colNames, expressionColIndices);
            string[] catColnames = ArrayUtils.SubArray(colNames, catColIndices);
            string[] numColnames = ArrayUtils.SubArray(colNames, numColIndices);
            string[] multiNumColnames = ArrayUtils.SubArray(colNames, multiNumColIndices);
            string[] textColnames = ArrayUtils.SubArray(colNames, textColIndices);
            matrixData.SetData(filename, RemoveQuotes(columnNames), expressionValues, RemoveQuotes(textColnames),
                stringAnnotation, RemoveQuotes(catColnames), categoryAnnotation, RemoveQuotes(numColnames), numericAnnotation,
                RemoveQuotes(multiNumColnames), multiNumericAnnotation);
            if (colDescriptions != null){
                string[] columnDesc = ArrayUtils.SubArray(colDescriptions, expressionColIndices);
                string[] catColDesc = ArrayUtils.SubArray(colDescriptions, catColIndices);
                string[] numColDesc = ArrayUtils.SubArray(colDescriptions, numColIndices);
                string[] multiNumColDesc = ArrayUtils.SubArray(colDescriptions, multiNumColIndices);
                string[] textColDesc = ArrayUtils.SubArray(colDescriptions, textColIndices);
                matrixData.ExpressionColumnDescriptions = new List<string>(columnDesc);
                matrixData.NumericColumnDescriptions = new List<string>(numColDesc);
                matrixData.CategoryColumnDescriptions = new List<string>(catColDesc);
                matrixData.StringColumnDescriptions = new List<string>(textColDesc);
                matrixData.MultiNumericColumnDescriptions = new List<string>(multiNumColDesc);
            }
            foreach (string key in ArrayUtils.GetKeys(catAnnotatRows)){
                string name = key;
                string[] svals = ArrayUtils.SubArray(catAnnotatRows[key], expressionColIndices);
                string[][] cat = new string[svals.Length][];
                for (int i = 0; i < cat.Length; i++){
                    string s = svals[i].Trim();
                    cat[i] = s.Length > 0 ? s.Split(';') : new string[0];
                }
                matrixData.AddCategoryRow(name, name, cat);
            }
            foreach (string key in ArrayUtils.GetKeys(numAnnotatRows)){
                string name = key;
                string[] svals = ArrayUtils.SubArray(numAnnotatRows[key], expressionColIndices);
                double[] num = new double[svals.Length];
                for (int i = 0; i < num.Length; i++){
                    string s = svals[i].Trim();
                    num[i] = double.NaN;
                    double.TryParse(s, out num[i]);
                }
                matrixData.AddNumericRow(name, name, num);
            }
            matrixData.Origin = filename;
            status("");
        }
开发者ID:BAngermann,项目名称:perseus-plugins,代码行数:101,代码来源:GenericDataUpload.cs


注:本文中的IMatrixData.AddNumericRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。