本文整理汇总了C#中IMatrixData.GetExpressionColumn方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.GetExpressionColumn方法的具体用法?C# IMatrixData.GetExpressionColumn怎么用?C# IMatrixData.GetExpressionColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.GetExpressionColumn方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValidExCols
private static int[] GetValidExCols(IMatrixData data)
{
List<int> valids = new List<int>();
for (int i = 0; i < data.ExpressionColumnCount; i++){
if (!IsInvalidExColumn(data.GetExpressionColumn(i))){
valids.Add(i);
}
}
return valids.ToArray();
}
示例2: 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);
}
}
示例3: ProcessData
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[][]>());
}
示例4: GetColumn
private static float[] GetColumn(IMatrixData matrixData, int ind)
{
if (ind < matrixData.ExpressionColumnCount){
return matrixData.GetExpressionColumn(ind);
}
double[] x = matrixData.NumericColumns[ind - matrixData.ExpressionColumnCount];
float[] f = new float[x.Length];
for (int i = 0; i < x.Length; i++){
f[i] = (float) x[i];
}
return f;
}
示例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, ProcessInfo processInfo)
{
int colInd = param.GetSingleChoiceParam("Column").Value;
double value = param.GetDoubleParam("Value").Value;
int ruleInd = param.GetSingleChoiceParam("Remove if").Value;
bool keepNan = param.GetBoolParam("Keep NaN").Value;
double[] vals = colInd < mdata.NumericColumnCount
? mdata.NumericColumns[colInd] : ArrayUtils.ToDoubles(mdata.GetExpressionColumn(colInd - mdata.NumericColumnCount));
List<int> valids = new List<int>();
for (int i = 0; i < vals.Length; i++){
bool valid;
double val = vals[i];
if (double.IsNaN(val)){
valid = keepNan;
} else{
switch (ruleInd){
case 0:
valid = val > value;
break;
case 1:
valid = val >= value;
break;
case 2:
valid = val != value;
break;
case 3:
valid = val == value;
break;
case 4:
valid = val <= value;
break;
case 5:
valid = val < value;
break;
default:
throw new Exception("Never get here.");
}
}
if (valid){
valids.Add(i);
}
}
PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
}
示例7: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
bool keepEmpty = param.GetBoolParam("Keep rows without ID").Value;
AverageType atype = GetAverageType(param.GetSingleChoiceParam("Average type for expression columns").Value);
string[] ids2 = mdata.StringColumns[param.GetSingleChoiceParam("ID column").Value];
string[][] ids = SplitIds(ids2);
int[] present;
int[] absent;
GetPresentAbsentIndices(ids, out present, out absent);
ids = ArrayUtils.SubArray(ids, present);
int[][] rowInds = new int[present.Length][];
for (int i = 0; i < rowInds.Length; i++){
rowInds[i] = new[]{present[i]};
}
ClusterRows(ref rowInds, ref ids);
if (keepEmpty){
rowInds = ProlongRowInds(rowInds, absent);
}
int nrows = rowInds.Length;
int ncols = mdata.ExpressionColumnCount;
float[,] expVals = new float[nrows,ncols];
for (int j = 0; j < ncols; j++){
float[] c = mdata.GetExpressionColumn(j);
for (int i = 0; i < nrows; i++){
float[] d = ArrayUtils.SubArray(c, rowInds[i]);
expVals[i, j] = Average(d, atype);
}
}
mdata.ExpressionValues = expVals;
for (int i = 0; i < mdata.NumericColumnCount; i++){
string name = mdata.NumericColumnNames[i];
AverageType atype1 = GetAverageType(param.GetSingleChoiceParam("Average type for " + name).Value);
double[] c = mdata.NumericColumns[i];
double[] newCol = new double[nrows];
for (int k = 0; k < nrows; k++){
double[] d = ArrayUtils.SubArray(c, rowInds[k]);
newCol[k] = Average(d, atype1);
}
mdata.NumericColumns[i] = newCol;
}
for (int i = 0; i < mdata.CategoryColumnCount; i++){
string[][] c = mdata.GetCategoryColumnAt(i);
string[][] newCol = new string[nrows][];
for (int k = 0; k < nrows; k++){
string[][] d = ArrayUtils.SubArray(c, rowInds[k]);
newCol[k] = Average(d);
}
mdata.SetCategoryColumnAt(newCol,i);
}
for (int i = 0; i < mdata.StringColumnCount; i++){
string[] c = mdata.StringColumns[i];
string[] newCol = new string[nrows];
for (int k = 0; k < nrows; k++){
string[] d = ArrayUtils.SubArray(c, rowInds[k]);
newCol[k] = Average(d);
}
mdata.StringColumns[i] = newCol;
}
for (int i = 0; i < mdata.MultiNumericColumnCount; i++){
double[][] c = mdata.MultiNumericColumns[i];
double[][] newCol = new double[nrows][];
for (int k = 0; k < nrows; k++){
double[][] d = ArrayUtils.SubArray(c, rowInds[k]);
newCol[k] = Average(d);
}
mdata.MultiNumericColumns[i] = newCol;
}
}
示例8: 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++){
//.........这里部分代码省略.........
示例9: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
float[,] vals = mdata.ExpressionValues;
double[] dm = new double[mdata.ExpressionColumnCount];
double[] dp = new double[mdata.ExpressionColumnCount];
for (int i = 0; i < mdata.ExpressionColumnCount; i++){
List<float> v = new List<float>();
foreach (float f in mdata.GetExpressionColumn(i)){
if (!float.IsNaN(f) && !float.IsInfinity(f)){
v.Add(f);
}
}
float[] d = v.ToArray();
float[] q = ArrayUtils.Quantiles(d, new[]{0.25, 0.5, 0.75});
for (int j = 0; j < mdata.RowCount; j++){
vals[j, i] -= q[1];
}
dm[i] = q[1] - q[0];
dp[i] = q[2] - q[1];
}
double adm = ArrayUtils.Median(dm);
double adp = ArrayUtils.Median(dp);
for (int i = 0; i < mdata.ExpressionColumnCount; i++){
for (int j = 0; j < mdata.RowCount; j++){
if (vals[j, i] < 0){
vals[j, i] = (float) (vals[j, i]*adm/dm[i]);
} else{
vals[j, i] = (float) (vals[j, i]*adp/dp[i]);
}
}
}
}
示例10: 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);
}
}
示例11: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int ind = param.GetSingleChoiceParam("Column").Value;
bool descending = param.GetBoolParam("Descending").Value;
if (ind < mdata.ExpressionColumnCount){
float[] v = mdata.GetExpressionColumn(ind);
int[] o = ArrayUtils.Order(v);
if (descending){
ArrayUtils.Revert(o);
}
mdata.ExtractExpressionRows(o);
} else{
double[] v = mdata.NumericColumns[ind - mdata.ExpressionColumnCount];
int[] o = ArrayUtils.Order(v);
if (descending){
ArrayUtils.Revert(o);
}
mdata.ExtractExpressionRows(o);
}
}
示例12: ExpressionToNumeric
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);
}