本文整理汇总了C#中IMatrixData.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.Copy方法的具体用法?C# IMatrixData.Copy怎么用?C# IMatrixData.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.Copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CombineData
public IMatrixData CombineData(IMatrixData matrixData1, IMatrixData matrixData2, Parameters parameters,
ProcessInfo processInfo)
{
bool indicator = parameters.GetBoolParam("Indicator").Value;
int otherCol = parameters.GetSingleChoiceParam("Matching column 2").Value;
Average avExpression = GetAveraging(parameters.GetSingleChoiceParam("Combine expression values").Value);
Average avNumerical = GetAveraging(parameters.GetSingleChoiceParam("Combine numerical values").Value);
string[] q = matrixData2.StringColumns[otherCol];
string[][] w = new string[q.Length][];
for (int i = 0; i < q.Length; i++){
string r = q[i].Trim();
w[i] = r.Length == 0 ? new string[0] : r.Split(';');
w[i] = ArrayUtils.UniqueValues(w[i]);
}
Dictionary<string, List<int>> id2Cols = new Dictionary<string, List<int>>();
for (int i = 0; i < w.Length; i++){
foreach (string s in w[i]){
if (!id2Cols.ContainsKey(s)){
id2Cols.Add(s, new List<int>());
}
id2Cols[s].Add(i);
}
}
int pgCol = parameters.GetSingleChoiceParam("Matching column 1").Value;
string[] d = matrixData1.StringColumns[pgCol];
string[][] x = new string[d.Length][];
for (int i = 0; i < d.Length; i++){
string r = d[i].Trim();
x[i] = r.Length == 0 ? new string[0] : r.Split(';');
x[i] = ArrayUtils.UniqueValues(x[i]);
}
int[][] indexMap = new int[x.Length][];
string[][] indicatorCol = new string[x.Length][];
for (int i = 0; i < indexMap.Length; i++){
List<int> qwer = new List<int>();
foreach (string s in x[i]){
if (id2Cols.ContainsKey(s)){
List<int> en = id2Cols[s];
qwer.AddRange(en);
}
}
indexMap[i] = qwer.ToArray();
indexMap[i] = ArrayUtils.UniqueValues(indexMap[i]);
indicatorCol[i] = indexMap[i].Length > 0 ? new[]{"+"} : new string[0];
}
IMatrixData result = matrixData1.Copy();
SetAnnotationRows(result, matrixData1, matrixData2);
if (indicator){
result.AddCategoryColumn(matrixData2.Name, "", indicatorCol);
}
{
int[] exCols = parameters.GetMultiChoiceParam("Expression columns").Value;
float[,] newExColumns = new float[matrixData1.RowCount, exCols.Length];
float[,] newQuality = new float[matrixData1.RowCount, exCols.Length];
bool[,] newIsImputed = new bool[matrixData1.RowCount, exCols.Length];
string[] newExColNames = new string[exCols.Length];
float[,] oldEx = matrixData2.ExpressionValues;
float[,] oldQual = matrixData2.QualityValues;
bool[,] oldImp = matrixData2.IsImputed;
for (int i = 0; i < exCols.Length; i++) {
newExColNames[i] = matrixData2.ExpressionColumnNames[exCols[i]];
for (int j = 0; j < matrixData1.RowCount; j++){
int[] inds = indexMap[j];
List<double> values = new List<double>();
List<double> qual = new List<double>();
List<bool> imp = new List<bool>();
foreach (int ind in inds) {
double v = oldEx[ind, exCols[i]];
if (!double.IsNaN(v) && !double.IsInfinity(v)){
values.Add(v);
double qx = oldQual[ind, exCols[i]];
if (!double.IsNaN(qx) && !double.IsInfinity(qx)){
qual.Add(qx);
}
bool isi = oldImp[ind, exCols[i]];
imp.Add(isi);
}
}
newExColumns[j, i] = values.Count == 0 ? float.NaN : (float)avExpression(values.ToArray());
newQuality[j, i] = qual.Count == 0 ? float.NaN : (float)avExpression(qual.ToArray());
newIsImputed[j, i] = imp.Count != 0 && AvImp(imp.ToArray());
}
}
MakeNewNames(newExColNames, result.ExpressionColumnNames);
AddExpressionColumns(result, newExColNames, newExColumns, newQuality, newIsImputed);
}
{
int[] numCols = parameters.GetMultiChoiceParam("Numerical columns").Value;
double[][] newNumericalColumns = new double[numCols.Length][];
string[] newNumColNames = new string[numCols.Length];
for (int i = 0; i < numCols.Length; i++){
double[] oldCol = matrixData2.NumericColumns[numCols[i]];
newNumColNames[i] = matrixData2.NumericColumnNames[numCols[i]];
newNumericalColumns[i] = new double[matrixData1.RowCount];
for (int j = 0; j < matrixData1.RowCount; j++){
int[] inds = indexMap[j];
List<double> values = new List<double>();
foreach (int ind in inds){
double v = oldCol[ind];
if (!double.IsNaN(v)){
//.........这里部分代码省略.........