本文整理汇总了C#中IMatrixData.AddCategoryColumn方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.AddCategoryColumn方法的具体用法?C# IMatrixData.AddCategoryColumn怎么用?C# IMatrixData.AddCategoryColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.AddCategoryColumn方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterRows
public static void FilterRows(IMatrixData mdata, Parameters parameters, int[] rows)
{
bool reduceMatrix = GetReduceMatrix(parameters);
if (reduceMatrix){
mdata.ExtractExpressionRows(rows);
} else{
Array.Sort(rows);
string[][] col = new string[mdata.RowCount][];
for (int i = 0; i < col.Length; i++){
bool contains = Array.BinarySearch(rows, i) >= 0;
col[i] = contains ? new[]{"Keep"} : new[]{"Discard"};
}
mdata.AddCategoryColumn("Filter", "", col);
}
}
示例2: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string word = param.GetParam<string>("Find what").Value;
int colInd = param.GetParam<int>("Look in").Value;
bool matchCase = param.GetParam<bool>("Match case").Value;
bool matchWholeWord = param.GetParam<bool>("Match whole word").Value;
string scolName = mdata.StringColumnNames[colInd];
string[] scol = mdata.StringColumns[colInd];
string[][] catCol = new string[mdata.RowCount][];
for (int i = 0; i < catCol.Length; i++){
bool found = Find(scol[i], word, matchCase, matchWholeWord);
catCol[i] = found ? new[]{"+"} : new string[0];
}
mdata.AddCategoryColumn("Search: " + scolName, "Search: " + scolName, catCol);
}
示例3: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string colName = param.GetParam<string>("Name of new column").Value;
int[] columns = param.GetParam<int[]>("Categories").Value;
bool inverse = param.GetParam<bool>("Inverse").Value;
int[] catCols;
int[] stringCols;
Split(columns, out catCols, out stringCols, mdata.CategoryColumnCount);
string[] word1 = param.GetParam<string[]>("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){
for (int i = 0; i < mdata.RowCount; i++){
foreach (string s in mdata.GetCategoryColumnEntryAt(col, 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);
}
示例4: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int[] cols = param.GetMultiChoiceParam("Columns").Value;
int truncIndex = param.GetSingleChoiceParam("Use for truncation").Value;
TestTruncation truncation = truncIndex == 0
? TestTruncation.Pvalue : (truncIndex == 1 ? TestTruncation.BenjaminiHochberg : TestTruncation.PermutationBased);
double threshold = param.GetDoubleParam("Threshold value").Value;
int sideInd = param.GetSingleChoiceParam("Side").Value;
TestSide side;
switch (sideInd){
case 0:
side = TestSide.Both;
break;
case 1:
side = TestSide.Left;
break;
case 2:
side = TestSide.Right;
break;
default:
throw new Exception("Never get here.");
}
foreach (int col in cols){
float[] r = mdata.GetExpressionColumn(col);
double[] pvals = CalcSignificanceA(r, side);
string[][] fdr;
switch (truncation){
case TestTruncation.Pvalue:
fdr = PerseusPluginUtils.CalcPvalueSignificance(pvals, threshold);
break;
case TestTruncation.BenjaminiHochberg:
fdr = PerseusPluginUtils.CalcBenjaminiHochbergFdr(pvals, threshold);
break;
default:
throw new Exception("Never get here.");
}
mdata.AddNumericColumn(mdata.ExpressionColumnNames[col] + " Significance A", "", pvals);
mdata.AddCategoryColumn(mdata.ExpressionColumnNames[col] + " A significant", "", fdr);
}
}
示例5: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
{
int numQuantiles = param.GetIntParam("Number of quantiles").Value;
int[] colInds = param.GetMultiChoiceParam("Columns").Value;
foreach (int colInd in colInds){
float[] vals = mdata.GetExpressionColumn(colInd);
List<int> v = new List<int>();
for (int i = 0; i < vals.Length; i++){
if (!float.IsNaN(vals[i])){
v.Add(i);
}
}
int[] o = v.ToArray();
vals = ArrayUtils.SubArray(vals, o);
int[] q = ArrayUtils.Order(vals);
o = ArrayUtils.SubArray(o, q);
string[][] catCol = new string[mdata.RowCount][];
for (int i = 0; i < catCol.Length; i++){
catCol[i] = new[]{"missing"};
}
for (int i = 0; i < o.Length; i++){
int catVal = (i*numQuantiles)/o.Length + 1;
catCol[o[i]] = new[]{"Q" + catVal};
}
string name = mdata.ExpressionColumnNames[colInd] + "_q";
string desc = "The column " + mdata.ExpressionColumnNames[colInd] + " has been divided into " + numQuantiles +
" quantiles.";
mdata.AddCategoryColumn(name, desc, catCol);
}
}
示例6: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string[] seqWins;
string[] accs;
string[] function;
string[] process;
string[] protInteract;
string[] otherInteract;
string[] notes;
string[] species;
PhosphoSitePlusParser.ParseRegulatorySites(out seqWins, out accs, out function, out process, out protInteract,
out otherInteract, out notes, out species);
if (seqWins == null){
processInfo.ErrString = "File does not exist.";
return;
}
string[] up = mdata.StringColumns[param.GetParam<int>("Uniprot column").Value];
string[][] uprot = new string[up.Length][];
for (int i = 0; i < up.Length; i++){
uprot[i] = up[i].Length > 0 ? up[i].Split(';') : new string[0];
}
string[] win = mdata.StringColumns[param.GetParam<int>("Sequence window").Value];
Dictionary<string, List<int>> map = new Dictionary<string, List<int>>();
for (int i = 0; i < seqWins.Length; i++){
string acc = accs[i];
if (!map.ContainsKey(acc)){
map.Add(acc, new List<int>());
}
map[acc].Add(i);
}
string[][] newCatCol = new string[uprot.Length][];
string[][] function2 = new string[uprot.Length][];
string[][] process2 = new string[uprot.Length][];
string[][] protInteract2 = new string[uprot.Length][];
string[][] otherInteract2 = new string[uprot.Length][];
string[][] notes2 = new string[uprot.Length][];
for (int i = 0; i < uprot.Length; i++){
string[] win1 = TransformIl(win[i]).Split(';');
HashSet<string> wins = new HashSet<string>();
HashSet<string> function1 = new HashSet<string>();
HashSet<string> process1 = new HashSet<string>();
HashSet<string> protInteract1 = new HashSet<string>();
HashSet<string> otherInteract1 = new HashSet<string>();
HashSet<string> notes1 = new HashSet<string>();
foreach (string ux in uprot[i]){
if (map.ContainsKey(ux)){
List<int> n = map[ux];
foreach (int ind in n){
string s = seqWins[ind];
if (Contains(win1, TransformIl(s.ToUpper().Substring(1, s.Length - 2)))){
wins.Add(s);
if (function[ind].Length > 0){
function1.Add(function[ind]);
}
if (process[ind].Length > 0){
process1.Add(process[ind]);
}
if (protInteract[ind].Length > 0){
protInteract1.Add(protInteract[ind]);
}
if (otherInteract[ind].Length > 0){
otherInteract1.Add(otherInteract[ind]);
}
if (notes[ind].Length > 0){
notes1.Add(notes[ind]);
}
}
}
}
}
if (wins.Count > 0){
newCatCol[i] = new[]{"+"};
function2[i] = ArrayUtils.ToArray(function1);
process2[i] = ArrayUtils.ToArray(process1);
protInteract2[i] = ArrayUtils.ToArray(protInteract1);
otherInteract2[i] = ArrayUtils.ToArray(otherInteract1);
notes2[i] = ArrayUtils.ToArray(notes1);
} else{
newCatCol[i] = new string[0];
function2[i] = new string[0];
process2[i] = new string[0];
protInteract2[i] = new string[0];
otherInteract2[i] = new string[0];
notes2[i] = new string[0];
}
}
mdata.AddCategoryColumn("Regulatory site", "", newCatCol);
mdata.AddCategoryColumn("Regulatory site function", "", function2);
mdata.AddCategoryColumn("Regulatory site process", "", process2);
mdata.AddCategoryColumn("Regulatory site protInteract", "", protInteract2);
mdata.AddCategoryColumn("Regulatory site otherInteract", "", otherInteract2);
mdata.AddCategoryColumn("Regulatory site notes", "", notes2);
}
示例7: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int[] outputColumns = param.GetMultiChoiceParam("Output").Value;
int proteinIdColumnInd = param.GetSingleChoiceParam("Protein IDs").Value;
string[] proteinIds = mdata.StringColumns[proteinIdColumnInd];
int[] intensityCols = param.GetMultiChoiceParam("Intensities").Value;
if (intensityCols.Length == 0){
processInfo.ErrString = "Please select at least one column containing protein intensities.";
return;
}
// variable to hold all intensity values
List<double[]> columns = new List<double[]>();
string[] sampleNames = new string[intensityCols.Length];
for (int col = 0; col < intensityCols.Length; col++){
double[] values;
if (intensityCols[col] < mdata.ExpressionColumnCount){
values = ArrayUtils.ToDoubles(mdata.GetExpressionColumn(intensityCols[col]));
sampleNames[col] = mdata.ExpressionColumnNames[intensityCols[col]];
} else{
values = mdata.NumericColumns[intensityCols[col] - mdata.ExpressionColumnCount];
sampleNames[col] = mdata.NumericColumnNames[intensityCols[col] - mdata.ExpressionColumnCount];
}
sampleNames[col] = new Regex(@"^(?:(?:LFQ )?[Ii]ntensity )?(.*)$").Match(sampleNames[col]).Groups[1].Value;
columns.Add(values);
}
// average over columns if this option is selected
if (param.GetSingleChoiceWithSubParams("Averaging mode").Value == 3){
double[] column = new double[mdata.RowCount];
for (int row = 0; row < mdata.RowCount; row++){
double[] values = new double[intensityCols.Length];
for (int col = 0; col < intensityCols.Length; col++){
values[col] = columns[col][row];
}
column[row] = ArrayUtils.Median(ExtractValidValues(values, false));
}
// delete the original list of columns
columns = new List<double[]>{column};
sampleNames = new[]{""};
}
// revert logarithm if necessary
if (param.GetBoolWithSubParams("Logarithmized").Value){
double[] logBases = new[]{2, Math.E, 10};
double logBase =
logBases[param.GetBoolWithSubParams("Logarithmized").GetSubParameters().GetSingleChoiceParam("log base").Value];
foreach (double[] t in columns){
for (int row = 0; row < mdata.RowCount; row++){
if (t[row] == 0){
processInfo.ErrString = "Are the columns really logarithmized?\nThey contain zeroes!";
}
t[row] = Math.Pow(logBase, t[row]);
}
}
}
double[] mw = mdata.NumericColumns[param.GetSingleChoiceParam("Molecular masses").Value];
// detect whether the molecular masses are given in Da or kDa
if (ArrayUtils.Median(mw) < 250) // likely kDa
{
for (int i = 0; i < mw.Length; i++){
mw[i] *= 1000;
}
}
double[] detectabilityNormFactor = mw;
if (param.GetBoolWithSubParams("Detectability correction").Value){
detectabilityNormFactor =
mdata.NumericColumns[
param.GetBoolWithSubParams("Detectability correction")
.GetSubParameters()
.GetSingleChoiceParam("Correction factor")
.Value];
}
// the normalization factor needs to be nonzero for all proteins
// check and replace with 1 for all relevant cases
for (int row = 0; row < mdata.RowCount; row++){
if (detectabilityNormFactor[row] == 0 || detectabilityNormFactor[row] == double.NaN){
detectabilityNormFactor[row] = 1;
}
}
// detect the organism
Organism organism = DetectOrganism(proteinIds);
// c value the amount of DNA per cell, see: http://en.wikipedia.org/wiki/C-value
double cValue = (organism.genomeSize*basePairWeight)/avogadro;
// find the histones
int[] histoneRows = FindHistones(proteinIds, organism);
// write a categorical column indicating the histones
string[][] histoneCol = new string[mdata.RowCount][];
for (int row = 0; row < mdata.RowCount; row++){
histoneCol[row] = (ArrayUtils.Contains(histoneRows, row)) ? new[]{"+"} : new[]{""};
}
mdata.AddCategoryColumn("Histones", "", histoneCol);
// initialize the variables for the annotation rows
double[] totalProteinRow = new double[mdata.ExpressionColumnCount];
double[] totalMoleculesRow = new double[mdata.ExpressionColumnCount];
string[][] organismRow = new string[mdata.ExpressionColumnCount][];
double[] histoneMassRow = new double[mdata.ExpressionColumnCount];
double[] ploidyRow = new double[mdata.ExpressionColumnCount];
double[] cellVolumeRow = new double[mdata.ExpressionColumnCount];
double[] normalizationFactors = new double[columns.Count];
// calculate normalization factors for each column
for (int col = 0; col < columns.Count; col++){
//.........这里部分代码省略.........
示例8: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
if (mdata.CategoryColumnCount < 2){
processInfo.ErrString = "There are less than two categorical columns available.";
return;
}
int colInd1 = param.GetSingleChoiceParam("First column").Value;
int colInd2 = param.GetSingleChoiceParam("Second column").Value;
string[][] col1 = mdata.GetCategoryColumnAt(colInd1);
string[][] col2 = mdata.GetCategoryColumnAt(colInd2);
string[][] result = new string[col1.Length][];
for (int i = 0; i < result.Length; i++){
result[i] = CombineTerms(col1[i], col2[i]);
}
string colName = mdata.CategoryColumnNames[colInd1] + "_" + mdata.CategoryColumnNames[colInd2];
mdata.AddCategoryColumn(colName, "", result);
}
示例9: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int[] rcols = param.GetMultiChoiceParam("Ratio columns").Value;
int[] icols = param.GetMultiChoiceParam("Intensity columns").Value;
if (rcols.Length == 0){
processInfo.ErrString = "Please specify some ratio columns.";
return;
}
if (rcols.Length != icols.Length){
processInfo.ErrString = "The number of ratio and intensity columns have to be equal.";
return;
}
int truncIndex = param.GetSingleChoiceParam("Use for truncation").Value;
TestTruncation truncation = truncIndex == 0
? TestTruncation.Pvalue : (truncIndex == 1 ? TestTruncation.BenjaminiHochberg : TestTruncation.PermutationBased);
double threshold = param.GetDoubleParam("Threshold value").Value;
int sideInd = param.GetSingleChoiceParam("Side").Value;
TestSide side;
switch (sideInd){
case 0:
side = TestSide.Both;
break;
case 1:
side = TestSide.Left;
break;
case 2:
side = TestSide.Right;
break;
default:
throw new Exception("Never get here.");
}
for (int i = 0; i < rcols.Length; i++){
float[] r = mdata.GetExpressionColumn(rcols[i]);
float[] intens = icols[i] < mdata.ExpressionColumnCount
? mdata.GetExpressionColumn(icols[i])
: ArrayUtils.ToFloats(mdata.NumericColumns[icols[i] - mdata.ExpressionColumnCount]);
double[] pvals = CalcSignificanceB(r, intens, side);
string[][] fdr;
switch (truncation){
case TestTruncation.Pvalue:
fdr = PerseusPluginUtils.CalcPvalueSignificance(pvals, threshold);
break;
case TestTruncation.BenjaminiHochberg:
fdr = PerseusPluginUtils.CalcBenjaminiHochbergFdr(pvals, threshold);
break;
default:
throw new Exception("Never get here.");
}
mdata.AddNumericColumn(mdata.ExpressionColumnNames[rcols[i]] + " Significance B", "", pvals);
mdata.AddCategoryColumn(mdata.ExpressionColumnNames[rcols[i]] + " B significant", "", fdr);
}
}
示例10: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string mod = param.GetParam<int>("Modification").StringValue;
string[] seqWins;
string[] accs;
string[] pubmedLtp;
string[] pubmedMs2;
string[] cstMs2;
string[] species;
PhosphoSitePlusParser.ParseKnownMod(mod, out seqWins, out accs, out pubmedLtp, out pubmedMs2, out cstMs2, out species);
if (seqWins == null){
processInfo.ErrString = "File does not exist.";
return;
}
string[] up = mdata.StringColumns[param.GetParam<int>("Uniprot column").Value];
string[][] uprot = new string[up.Length][];
for (int i = 0; i < up.Length; i++){
uprot[i] = up[i].Length > 0 ? up[i].Split(';') : new string[0];
}
string[] win = mdata.StringColumns[param.GetParam<int>("Sequence window").Value];
Dictionary<string, List<int>> map = new Dictionary<string, List<int>>();
for (int i = 0; i < seqWins.Length; i++){
string acc = accs[i];
if (!map.ContainsKey(acc)){
map.Add(acc, new List<int>());
}
map[acc].Add(i);
}
string[] newCol = new string[uprot.Length];
string[][] newCatCol = new string[uprot.Length][];
string[][] originCol = new string[uprot.Length][];
for (int i = 0; i < newCol.Length; i++){
string[] win1 = TransformIl(win[i]).Split(';');
HashSet<string> wins = new HashSet<string>();
HashSet<string> origins = new HashSet<string>();
foreach (string ux in uprot[i]){
if (map.ContainsKey(ux)){
List<int> n = map[ux];
foreach (int ind in n){
string s = seqWins[ind];
if (Contains(win1, TransformIl(s.ToUpper().Substring(1, s.Length - 2)))){
wins.Add(s);
if (pubmedLtp[ind].Length > 0){
origins.Add("LTP");
}
if (pubmedMs2[ind].Length > 0){
origins.Add("HTP");
}
if (cstMs2[ind].Length > 0){
origins.Add("CST");
}
}
}
}
}
if (wins.Count > 0){
newCol[i] = StringUtils.Concat(";", ArrayUtils.ToArray(wins));
newCatCol[i] = new[]{"+"};
string[] x = ArrayUtils.ToArray(origins);
Array.Sort(x);
originCol[i] = x;
} else{
newCol[i] = "";
newCatCol[i] = new string[0];
originCol[i] = new string[0];
}
}
mdata.AddStringColumn("PhosphoSitePlus window", "", newCol);
mdata.AddCategoryColumn("Known site", "", newCatCol);
mdata.AddCategoryColumn("Origin", "", originCol);
}
示例11: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string[] mods = param.GetParam<int[]>("Modifications").StringValue.Split(new[]{';'},
StringSplitOptions.RemoveEmptyEntries);
string[] up = mdata.StringColumns[param.GetParam<int>("Uniprot column").Value];
string[][] uprot = new string[up.Length][];
for (int i = 0; i < up.Length; i++){
uprot[i] = up[i].Length > 0 ? up[i].Split(';') : new string[0];
}
double[][] c = new double[mods.Length][];
for (int index = 0; index < mods.Length; index++){
string mod = mods[index];
string filename = PhosphoSitePlusParser.GetFilenameForMod(mod);
if (filename == null){
processInfo.ErrString = "File does not exist.";
return;
}
string[] seqWins;
string[] accs;
string[] pubmedLtp;
string[] pubmedMs2;
string[] cstMs2;
string[] species;
PhosphoSitePlusParser.ParseKnownMods(filename, out seqWins, out accs, out pubmedLtp, out pubmedMs2, out cstMs2, out species);
for (int i = 0; i < seqWins.Length; i++){
seqWins[i] = seqWins[i].ToUpper();
}
Dictionary<string, HashSet<string>> counts = new Dictionary<string, HashSet<string>>();
for (int i = 0; i < accs.Length; i++){
string acc = accs[i];
if (!counts.ContainsKey(acc)){
counts.Add(acc, new HashSet<string>());
}
counts[acc].Add(seqWins[i]);
}
c[index] = new double[up.Length];
for (int i = 0; i < up.Length; i++){
c[index][i] = CountSites(uprot[i], counts);
}
}
string[][] catCol = new string[up.Length][];
for (int i = 0; i < catCol.Length; i++){
List<string> x = new List<string>();
for (int j = 0; j < mods.Length; j++){
if (c[j][i] > 0){
x.Add(mods[j]);
}
}
x.Sort();
catCol[i] = x.ToArray();
}
mdata.AddCategoryColumn("Known modifications", "Known modifications", catCol);
for (int i = 0; i < mods.Length; i++){
mdata.AddNumericColumn(mods[i] + " count", mods[i] + " count", c[i]);
}
}