本文整理汇总了C#中BasicLib.Param.Parameters.GetSingleChoiceWithSubParams方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.GetSingleChoiceWithSubParams方法的具体用法?C# Parameters.GetSingleChoiceWithSubParams怎么用?C# Parameters.GetSingleChoiceWithSubParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicLib.Param.Parameters
的用法示例。
在下文中一共展示了Parameters.GetSingleChoiceWithSubParams方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
SingleChoiceWithSubParams access = param.GetSingleChoiceWithSubParams("Matrix access");
bool rows = access.Value == 0;
int groupInd;
if (rows){
groupInd = access.GetSubParameters().GetSingleChoiceParam("Grouping").Value - 1;
} else{
groupInd = -1;
}
int what = param.GetSingleChoiceParam("Subtract what").Value;
if (groupInd < 0){
SubtractValues(rows, GetFunc(what), mdata, processInfo.NumThreads);
} else{
string[][] catRow = mdata.GetCategoryRowAt(groupInd);
foreach (string[] t in catRow){
if (t.Length > 1){
processInfo.ErrString = "The groups are overlapping.";
return;
}
}
SubtractGroups(mdata, catRow, GetFunc(what));
}
}
示例2: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
SingleChoiceWithSubParams scwsp = param.GetSingleChoiceWithSubParams("Action");
Parameters spar = scwsp.GetSubParameters();
switch (scwsp.Value){
case 0:
ProcessDataCreate(mdata, spar);
break;
case 1:
ProcessDataEdit(mdata, spar);
break;
case 2:
ProcessDataRename(mdata, spar);
break;
case 3:
ProcessDataDelete(mdata, spar);
break;
}
}
示例3: ProcessDataEdit
private static void ProcessDataEdit(IMatrixData mdata, Parameters param)
{
SingleChoiceWithSubParams s = param.GetSingleChoiceWithSubParams("Numerical row");
int groupColInd = s.Value;
Parameters sp = s.GetSubParameters();
for (int i = 0; i < mdata.ExpressionColumnCount; i++){
string t = mdata.ExpressionColumnNames[i];
double x = sp.GetDoubleParam(t).Value;
mdata.NumericRows[groupColInd][i] = x;
}
}
示例4: 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++){
//.........这里部分代码省略.........
示例5: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
SingleChoiceWithSubParams xp = param.GetSingleChoiceWithSubParams("Expression column selection");
bool groups = xp.Value == 2;
string[] groupNames = null;
int[][] colIndsGroups = null;
if (groups){
int groupRowInd = xp.GetSubParameters().GetSingleChoiceParam("Group").Value;
string[][] groupCol = mdata.GetCategoryRowAt(groupRowInd);
groupNames = ArrayUtils.UniqueValuesPreserveOrder(groupCol);
colIndsGroups = PerseusPluginUtils.GetExpressionColIndices(groupCol, groupNames);
}
int[] useCols = xp.Value == 1
? xp.GetSubParameters().GetMultiChoiceParam("Columns").Value
: ArrayUtils.ConsecutiveInts(mdata.ExpressionColumnCount);
HashSet<int> w = ArrayUtils.ToHashSet(param.GetMultiChoiceParam("Calculate").Value);
bool[] include = new bool[procs.Length];
double[][] columns = new double[procs.Length][];
double[][][] columnsG = null;
if (groups){
columnsG = new double[procs.Length][][];
for (int i = 0; i < columnsG.Length; i++){
columnsG[i] = new double[groupNames.Length][];
}
}
for (int i = 0; i < include.Length; i++){
include[i] = w.Contains(i);
if (include[i]){
columns[i] = new double[mdata.RowCount];
if (groups){
for (int j = 0; j < groupNames.Length; j++){
columnsG[i][j] = new double[mdata.RowCount];
}
}
}
}
for (int i = 0; i < mdata.RowCount; i++){
List<double> v = new List<double>();
foreach (int j in useCols){
double x = mdata[i, j];
if (!double.IsNaN(x) && !double.IsInfinity(x)){
v.Add(x);
}
}
for (int j = 0; j < include.Length; j++){
if (include[j]){
columns[j][i] = procs[j].Item2(v);
}
}
if (groups){
List<double>[] vg = new List<double>[groupNames.Length];
for (int j = 0; j < colIndsGroups.Length; j++){
vg[j] = new List<double>();
for (int k = 0; k < colIndsGroups[j].Length; k++){
double x = mdata[i, colIndsGroups[j][k]];
if (!double.IsNaN(x) && !double.IsInfinity(x)){
vg[j].Add(x);
}
}
}
for (int j = 0; j < include.Length; j++){
if (include[j]){
for (int k = 0; k < groupNames.Length; k++){
columnsG[j][k][i] = procs[j].Item2(vg[k]);
}
}
}
}
}
for (int i = 0; i < include.Length; i++){
if (include[i]){
mdata.AddNumericColumn(procs[i].Item1, procs[i].Item3, columns[i]);
if (groups){
for (int k = 0; k < groupNames.Length; k++){
mdata.AddNumericColumn(procs[i].Item1 + " " + groupNames[k], procs[i].Item3, columnsG[i][k]);
}
}
}
}
}
示例6: ProcessDataCreateFromGoupNames
private static void ProcessDataCreateFromGoupNames(IMatrixData mdata, Parameters param, ProcessInfo processInfo)
{
SingleChoiceWithSubParams scwsp = param.GetSingleChoiceWithSubParams("Pattern");
Parameters spar = scwsp.GetSubParameters();
string regexString = "";
string replacement = "";
switch (scwsp.Value) {
case 0:
case 1:
case 2:
regexString = GetSelectableRegexes()[scwsp.Value][1];
break;
case 3:
regexString = spar.GetStringParam("Regex").Value;
break;
case 4:
regexString = spar.GetStringParam("Regex").Value;
replacement = spar.GetStringParam("Replace with").Value;
break;
default:
break;
}
Regex regex;
try{
regex = new Regex(regexString);
}
catch (ArgumentException){
processInfo.ErrString = "The regular expression you provided has invalid syntax.";
return;
}
List<string[]> groupNames = new List<string[]>();
foreach (string sampleName in mdata.ExpressionColumnNames) {
string groupName = scwsp.Value < 4 ? regex.Match(sampleName).Groups[1].Value : regex.Replace(sampleName, replacement);
if (string.IsNullOrEmpty(groupName))
groupName = sampleName;
groupNames.Add(new[] { groupName });
}
mdata.AddCategoryRow("Grouping", "", groupNames.ToArray());
}
示例7: ProcessDataEdit
private static void ProcessDataEdit(IMatrixData mdata, Parameters param)
{
SingleChoiceWithSubParams s = param.GetSingleChoiceWithSubParams("Category row");
int groupColInd = s.Value;
Parameters sp = s.GetSubParameters();
string[][] newRow = new string[mdata.ExpressionColumnCount][];
for (int i = 0; i < mdata.ExpressionColumnCount; i++){
string t = mdata.ExpressionColumnNames[i];
string x = sp.GetStringParam(t).Value;
newRow[i] = x.Length > 0 ? x.Split(';') : new string[0];
}
mdata.SetCategoryRowAt(newRow, groupColInd);
}
示例8: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
const bool rows = false;
int minValids = param.GetIntParam("Min. number of values").Value;
SingleChoiceWithSubParams modeParam = param.GetSingleChoiceWithSubParams("Mode");
int modeInd = modeParam.Value;
if (modeInd != 0 && mdata.CategoryRowNames.Count == 0){
processInfo.ErrString = "No grouping is defined.";
return;
}
if (modeInd != 0){
processInfo.ErrString = "Group-wise filtering can only be appled to rows.";
return;
}
SingleChoiceWithSubParams x = param.GetSingleChoiceWithSubParams("Values should be");
Parameters subParams = x.GetSubParameters();
int shouldBeIndex = x.Value;
FilteringMode filterMode;
double threshold = double.NaN;
double threshold2 = double.NaN;
switch (shouldBeIndex){
case 0:
filterMode = FilteringMode.Valid;
break;
case 1:
filterMode = FilteringMode.GreaterThan;
threshold = subParams.GetDoubleParam("Minimum").Value;
break;
case 2:
filterMode = FilteringMode.GreaterEqualThan;
threshold = subParams.GetDoubleParam("Minimum").Value;
break;
case 3:
filterMode = FilteringMode.LessThan;
threshold = subParams.GetDoubleParam("Maximum").Value;
break;
case 4:
filterMode = FilteringMode.LessEqualThan;
threshold = subParams.GetDoubleParam("Maximum").Value;
break;
case 5:
filterMode = FilteringMode.Between;
threshold = subParams.GetDoubleParam("Minimum").Value;
threshold2 = subParams.GetDoubleParam("Maximum").Value;
break;
case 6:
filterMode = FilteringMode.Outside;
threshold = subParams.GetDoubleParam("Minimum").Value;
threshold2 = subParams.GetDoubleParam("Maximum").Value;
break;
default:
throw new Exception("Should not happen.");
}
if (modeInd != 0){
int gind = modeParam.GetSubParameters().GetSingleChoiceParam("Grouping").Value;
string[][] groupCol = mdata.GetCategoryRowAt(gind);
NonzeroFilterGroup(minValids, mdata, param, modeInd == 2, threshold, threshold2, filterMode, groupCol);
} else{
NonzeroFilter1(rows, minValids, mdata, param, threshold, threshold2, filterMode);
}
}
示例9: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
SingleChoiceWithSubParams scwsp = param.GetSingleChoiceWithSubParams("Action");
Parameters spar = scwsp.GetSubParameters();
switch (scwsp.Value){
case 0:
ProcessDataCreate(mdata, spar);
break;
case 1:
ProcessDataCreateFromGoupNames(mdata, spar, processInfo);
break;
case 2:
ProcessDataEdit(mdata, spar);
break;
case 3:
ProcessDataRename(mdata, spar);
break;
case 4:
ProcessDataDelete(mdata, spar);
break;
case 5:
ProcessDataWriteTemplateFile(mdata, spar);
break;
case 6:
string err = ProcessDataReadFromFile(mdata, spar);
if (err != null){
processInfo.ErrString = err;
}
break;
}
}
示例10: ProcessData
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);
}
示例11: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
{
bool rows = param.GetSingleChoiceParam("Matrix access").Value == 0;
bool atLeast = param.GetSingleChoiceParam("Side").Value == 0;
int numValids = param.GetIntParam("Number of valid values").Value;
SingleChoiceWithSubParams modeParam = param.GetSingleChoiceWithSubParams("Mode");
int modeInd = modeParam.Value;
if (modeInd != 0 && mdata.CategoryRowNames.Count == 0){
processInfo.ErrString = "No grouping is defined.";
return;
}
if (modeInd != 0 && !rows){
processInfo.ErrString = "Group-wise filtering can only be appled to rows.";
return;
}
if (modeInd != 0){
int gind = modeParam.GetSubParameters().GetSingleChoiceParam("Grouping").Value;
string[][] groupCol = mdata.CategoryRows[gind];
ValidValueFilterGroup(numValids, mdata, param, modeInd == 2, groupCol, atLeast);
} else{
ValidValueFilter1(rows, numValids, mdata, param, atLeast);
}
}
示例12: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
{
SingleChoiceWithSubParams sp = param.GetSingleChoiceWithSubParams("Source type");
Parameters subParams = sp.GetSubParameters();
int[] colInds = subParams.GetMultiChoiceParam("Columns").Value;
int which = subParams.GetSingleChoiceParam("Target type").Value;
switch (sp.Value){
case 0:
ExpressionToNumeric(colInds, mdata);
break;
case 1:
if (which == 0){
NumericToCategorical(colInds, mdata);
} else{
NumericToExpression(colInds, mdata);
}
break;
case 2:
if (which == 0){
CategoricalToNumeric(colInds, mdata);
} else{
CategoricalToString(colInds, mdata);
}
break;
case 3:
StringToCategorical(colInds, mdata);
break;
default:
throw new Exception("Never get here");
}
}
示例13: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ProcessInfo processInfo)
{
SingleChoiceWithSubParams access = param.GetSingleChoiceWithSubParams("Matrix access");
bool rows = access.Value == 0;
int groupInd;
if (rows){
groupInd = access.GetSubParameters().GetSingleChoiceParam("Grouping").Value - 1;
} else{
groupInd = -1;
}
if (groupInd < 0){
Zscore(rows, mdata);
} else{
string[][] catRow = mdata.CategoryRows[groupInd];
foreach (string[] t in catRow){
if (t.Length > 1){
processInfo.ErrString = "The groups are overlapping.";
return;
}
}
ZscoreGroups(mdata, catRow);
}
}
示例14: ProcessData
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 == 0){
processInfo.ErrString = "Please select at least one term for filtering.";
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);
bool remove = param.GetSingleChoiceParam("Mode").Value == 0;
string[][] cats = mdata.GetCategoryRowAt(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 (value.Contains(w)){
valid = false;
break;
}
}
if ((valid && remove) || (!valid && !remove)){
valids.Add(i);
}
}
PerseusPluginUtils.FilterColumns(mdata, param, valids.ToArray());
}