Exemplo n.º 1
0
        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]);
                }
            }
        }
Exemplo n.º 2
0
 private void AddNormalizedPeptideWeight(string peptide, double weight)
 {
     if (string.IsNullOrEmpty(peptide))
     {
         return;
     }
     if (NormalizedPeptideWeights.ContainsKey(peptide))
     {
         return;
     }
     NormalizedPeptideWeights.Add(peptide, weight);
 }
Exemplo n.º 3
0
 private void AddNormalizedPeptideWeight(string peptide, int pos, double weight)
 {
     if (string.IsNullOrEmpty(peptide))
     {
         return;
     }
     if (peptide == WildTypePeptide)
     {
         NormalizedWildtypeWeights.Add(pos, weight);
         return;
     }
     if (!NormalizedPeptideWeights.ContainsKey(peptide))
     {
         NormalizedPeptideWeights.Add(peptide, weight);
     }
 }
Exemplo n.º 4
0
        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]);
                    }
                }
            }
        }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
        private void AddNormalizedPeptideWeight(double weight, int pos, char replaceBy)
        {
            if (string.IsNullOrEmpty(WildTypePeptide))
            {
                return;
            }
            string s = "", e = "";

            if (pos > 0)
            {
                s = WildTypePeptide.Substring(0, pos);
            }
            if (pos < WildTypePeptide.Length - 1)
            {
                e = WildTypePeptide.Substring(pos + 1);
            }
            string peptide = s + replaceBy + e;

            if (/*peptide == WildTypePeptide && */ NormalizedPeptideWeights.ContainsKey(peptide))
            {
                return;
            }
            NormalizedPeptideWeights.Add(peptide, weight);
        }
Exemplo n.º 7
0
        /// <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);
            }
        }