private void GenerateNormalizedPeptideWeights() { NormalizedPeptideWeights.Clear(); NormalizedWildtypeWeights.Clear(); NormalizedMatrixMin = double.MaxValue; NormalizedMatrixMax = double.MinValue; for (int iRow = 0; iRow < RowCount; iRow++) { for (int iCol = 0; iCol < ColCount; iCol++) { int pos = PermutationXAxis ? iRow : iCol; double normby = NormMode == NormalizationMode.Mean ? NormalizationValue : NormBy == null ? 1 : NormBy[pos]; if (normby != 0) { NormalizedMatrix[iRow, iCol] = QuantificationMatrix[iRow, iCol] / normby; } if (NormalizedMatrix[iRow, iCol] < NormalizedMatrixMin) { NormalizedMatrixMin = NormalizedMatrix[iRow, iCol]; } if (NormalizedMatrix[iRow, iCol] > NormalizedMatrixMax) { NormalizedMatrixMax = NormalizedMatrix[iRow, iCol]; } AddNormalizedPeptideWeight(PeptideMatrix[iRow, iCol], pos, NormalizedMatrix[iRow, iCol]); } } }
private void GenerateNormalizedPeptideWeights() { NormalizedPeptideWeights.Clear(); NormalizedMatrixMin = double.MaxValue; NormalizedMatrixMax = double.MinValue; for (int iRow = 0; iRow < RowCount; iRow++) { for (int iCol = 0; iCol < ColCount; iCol++) { int pos = PermutationXAxis ? iRow : iCol; double normby = NormMode == NormalizationMode.Max ? NormalizationValue : NormBy == null ? 1 : NormBy[pos]; if (normby != 0) { NormalizedMatrix[iRow, iCol] = QuantificationMatrix[iRow, iCol] / normby; } if (NormalizedMatrix[iRow, iCol] < NormalizedMatrixMin) { NormalizedMatrixMin = NormalizedMatrix[iRow, iCol]; } if (NormalizedMatrix[iRow, iCol] > NormalizedMatrixMax) { NormalizedMatrixMax = NormalizedMatrix[iRow, iCol]; } double weight = NormalizedMatrix[iRow, iCol]; if (PermutationXAxis) { if (this.PositionYAxisTopToBottom) { AddNormalizedPeptideWeight(weight, iRow, Permutation[iCol]); } else //if Position Matrix is read from bottom to top, rowind should be reversed { AddNormalizedPeptideWeight(weight, RowCount - iRow - 1, Permutation[iCol]); } } else { AddNormalizedPeptideWeight(weight, iCol, Permutation[iRow]); } } } }
public void Normalize(double normBy) { NormalizedPeptideWeights.Clear(); if (normBy == 0) { return; } NormalizationValue = normBy; for (int i = 0; i < RowCount; i++) { for (int j = 0; j < ColCount; j++) { NormalizedMatrix[i, j] = QuantificationMatrix[i, j] / normBy; AddNormalizedPeptideWeight(PeptideMatrix[i, j], NormalizedMatrix[i, j]); } } GenerateModifiedPeptideList(); }
/// <summary> /// Dictionary of weight for each char at every position /// </summary> /// <param name="PA"></param> /// <returns></returns> public Dictionary <int, Dictionary <char, double> > GenerateWeights() { try { int motifsize = PermutationXAxis ? RowCount : ColCount; WildTypePeptide = new string('X', motifsize); NormalizedPeptideWeights.Clear(); Dictionary <int, Dictionary <char, double> > weights; Dictionary <int, double> totalWeightsPerPos; weights = new Dictionary <int, Dictionary <char, double> >(); totalWeightsPerPos = new Dictionary <int, double>(); for (int i = 0; i < motifsize; i++) { totalWeightsPerPos.Add(i, 0); weights.Add(i, new Dictionary <char, double>()); } for (int rowind = 0; rowind < RowCount; rowind++) { for (int colind = 0; colind < ColCount; colind++) { double weight = NormalizedMatrix[rowind, colind]; if (PermutationXAxis) { if (this.PositionYAxisTopToBottom) { if (weight > PositiveThreshold) { weights[rowind].Add(Permutation[colind], weight); totalWeightsPerPos[rowind] += weight; } AddNormalizedPeptideWeight(weight, rowind, Permutation[colind]); } else //if Position Matrix is read from bottom to top, rowind should be reversed { if (weight > PositiveThreshold) { weights[RowCount - rowind - 1].Add(Permutation[colind], weight); totalWeightsPerPos[RowCount - rowind - 1] += weight; } AddNormalizedPeptideWeight(weight, RowCount - rowind - 1, Permutation[colind]); } } else { if (weight > PositiveThreshold) { weights[colind].Add(Permutation[rowind], weight); totalWeightsPerPos[colind] += weight; } AddNormalizedPeptideWeight(weight, colind, Permutation[rowind]); } } } for (int i = 0; i < motifsize; i++) { List <char> charlist = weights[i].Keys.ToList(); foreach (char c in charlist) { weights[i][c] /= totalWeightsPerPos[i]; } } return(weights); } catch { return(null); } }