Source code for MSQuant: frmPCPplot.vb, MSQuant/msquant/src/GUI/forms/frmPCPplot.vb.

Table of contents page.

Home page for MSQuant.

'****************************************************************************
'* Copyright (C) 2008 Peter Mortensen and Matthias Mann                     *
'* This file is part of MSQuant.                                            *
'*                                                                          *
'* MSQuant is distributed under the terms of                                *
'* the GNU General Public License. See src/COPYING.TXT or                   *
'* <http://www.gnu.org/licenses/gpl.txt> for details.                       *
'*                                                                          *
'* MSQuant is free software; you can redistribute it                        *
'* and/or modify it under the terms of the GNU                              *
'* General Public License as published by the Free                          *
'* Software Foundation; either version 2 of the                             *
'* License, or (at your option) any later version.                          *
'*                                                                          *
'* MSQuant is distributed in the hope that it will be                       *
'* useful, but WITHOUT ANY WARRANTY; without even the                       *
'* implied warranty of MERCHANTABILITY or FITNESS FOR                       *
'* A PARTICULAR PURPOSE.  See the GNU General Public                        *
'* License for more details.                                                *
'*                                                                          *
'* You should have received a copy of the GNU General                       *
'* Public License along with MSQuant; if not, write to                      *
'* the Free Software Foundation, Inc., 59 Temple                            *
'* Place, Suite 330, Boston, MA  02111-1307  USA                            *
'*                                                                          *
'* Purpose: plotting of PCP related values.                                 *
'*                                                                          *
'****************************************************************************

'****************************************************************************
'*                               CEBI                                       *
'*                    Software Development Group                            *
'*                         Peter Mortensen                                  *
'*                E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk          *
'*                 WWW: http://www.cebi.sdu.dk/                             *
'*                                                                          *
'*  Program for post-processing of result from search in mass               *
'*    spectrometric data.                                                   *
'*                                                                          *
'*    FILENAME:   frmPCPplot.vb                                             *
'*    TYPE:  VISUAL_BASIC                                                   *
'*                                                                          *
'* CREATED: PM 2008-09-29   Vrs 1.0.                                        *
'* UPDATED: PM 2008-xx-xx                                                   *
'*                                                                          *
'****************************************************************************

Option Strict On
Option Explicit On

'Imports System.Text  'For StringBuilder
'Imports System
'Imports System.Reflection 'For MemberInfo.

Imports System.Collections.Generic 'For Dictionary and List.
Imports System.Text 'For StringBuilder

Imports ZedGraph


Imports MolecularSharedStructures 'For ProteinHitStructure.
Imports massSpectrometryBase 'For taggingStruct
Imports SDUPutility 'For statsStructure.


'****************************************************************************
'*    <placeholder for header>                                              *
'****************************************************************************
Public Class frmPCPplot

    Private mStartingUp As Boolean

    Private mPlotList As List(Of MolecularSharedStructures.proteinPCPstructure)
    Private mProteinList As List(Of ProteinHitStructure)
    Private mPrimaryDimensionName As String

    'Changed PM_PCP_PLOT_OPENPROTEIN 2008-10-14
    Private mParent As frmProteinList

    Private mStartDimensionIndex As Integer

    'Changed PM_PCP_CONSENSUS_PROFILE 2008-11-05
    Private mConsensusProfile As List(Of frmProteinList.consensusDishInfoStruct) 'Outer:
    '  dish, inner values across a dimension.


    Private mMaxZeroPoints As Integer 

    'Changed PM_PCP_PLOT_SILACFILTER_GUI 2008-10-24
    Private mSILACviewOptions As List(Of CheckBox)
    Private mOneTimeInitCompleted As Boolean


    'Changed PM_PCP_PLOT_TAGGING 2008-11-04
    Private mTag2colourIndex As Dictionary(Of String, Integer) 'Key is
    '  primary protein tag. Value is some data structure index (for
    '  specifying a colour for a curve in the plot). 
    Private mSBscratch As StringBuilder


    'Changed PM_TWOLEVEL_WINDOWNUMBERING_PREFIX 2008-12-03
    Private mParseIDnumber As Integer


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub New( _
      ByRef anInPlotList As List(Of MolecularSharedStructures.proteinPCPstructure), _
      ByRef anInProteinList As List(Of ProteinHitStructure), _
      ByRef anInPrimaryDimensionName As String, _
      ByRef aParent As frmProteinList, _
      ByRef aStartIndex As Integer, _
      ByRef aConsensusProfile2 As List(Of frmProteinList.consensusDishInfoStruct), _
      ByVal aParseIDnumber As Integer _
      )

        'aStartIndex: e.g. 41 if start number for primary dimension is 42.

        mStartingUp = True 'Note: must be before InitializeComponent()!!!!

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        'No second level init, wait until form load time.

        mPlotList = anInPlotList
        mProteinList = anInProteinList
        mPrimaryDimensionName = anInPrimaryDimensionName

        'Changed PM_PCP_PLOT_OPENPROTEIN 2008-10-14
        mParent = aParent

        mStartDimensionIndex = aStartIndex

        'Changed PM_PCP_CONSENSUS_PROFILE 2008-11-05
        mConsensusProfile = aConsensusProfile2


        'Changed PM_TWOLEVEL_WINDOWNUMBERING_PREFIX 2008-12-03
        mParseIDnumber = aParseIDnumber 'Need to save for use in displayData().



        mMaxZeroPoints = 1 'Corresponding to the checked
        '  one in the designer.

        'Changed PM_PCP_PLOT_SILACFILTER_GUI 2008-10-24
        mSILACviewOptions = New List(Of CheckBox)(3)
        mOneTimeInitCompleted = False

        'Changed PM_PCP_PLOT_TAGGING 2008-11-04
        mTag2colourIndex = New Dictionary(Of String, Integer)
        mSBscratch = New StringBuilder(30)
    End Sub 'Constructor.


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub frmPCPplot_Load( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles MyBase.Load

        mStartingUp = True 'Just in case.

        If True Then 'Block.

            'This is not in updateDisplay() as we only need to do
            'it once. It does not change when e.g. the user choses
            'another max zero point option.
            Dim maxDishes As Integer = 5

            Dim refPoint As Point = rbMaxZero0.Location
            Dim x As Integer = refPoint.X + 500
            Dim y As Integer = refPoint.Y

            'Dim lastIndex As Integer = maxDishes - 1
            Dim dish As Integer
            For dish = 1 To maxDishes

                Dim newCB As CheckBox = New CheckBox
                newCB.Enabled = True 'Needed?
                newCB.Name = "cb" & dish.ToString 'Needed?
                newCB.UseVisualStyleBackColor = True 'Needed?

                newCB.Text = "Ratio " & dish & "/1"
                newCB.AutoSize = True

                'Dialog starup defaults:
                newCB.Checked = True
                If dish = 1 Then
                    newCB.Checked = False
                End If

                newCB.Visible = False 'Until we need it.

                Dim loc As Point
                loc.X = x
                loc.Y = y
                newCB.Location = loc

                mSILACviewOptions.Add(newCB)

                Me.Controls.Add(newCB)

                x += 80
            Next dish
        End If 'Block.

        Me.updateDisplay()

        mStartingUp = False
    End Sub 'frmPCPplot_Load


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub updateDisplay()
        displayData( _
          mPlotList, mProteinList, mPrimaryDimensionName, mMaxZeroPoints, _
          mConsensusProfile)
    End Sub 'updateDisplay


    'Changed PM_REFACTOR 2008-11-05
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function derivePlotType(ByVal aDishZbased As Integer) _
      As SymbolType

        'For now. Later: data structure.
        Dim plotType As SymbolType
        Select Case aDishZbased
            Case 0
                'Changed PM_PCP_PLOT_NOTSTAR 2008-11-27
                'plotType = SymbolType.Triangle
                plotType = SymbolType.TriangleDown

            Case 1
                plotType = SymbolType.Diamond

            Case 2
                'Changed PM_PCP_PLOT_NOTSTAR 2008-11-27
                'plotType = SymbolType.Star
                'plotType = SymbolType.Square
                plotType = SymbolType.Circle

            Case Else
                Trace.Assert(False, _
                  "PIL ASSERT. Select Case never fall-through")
        End Select

        Return plotType
    End Function 'derivePlotType


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub displayData( _
      ByRef anInPlotList As List(Of proteinPCPstructure), _
      ByRef anInProteinList As List(Of ProteinHitStructure), _
      ByRef anInPrimaryDimensionName As String, _
      ByVal aMaxZeroPoints As Integer, _
      ByRef aConsensusProfile2 As List(Of frmProteinList.consensusDishInfoStruct) _
      )
        Me.SetSize() 'Right place?

        Dim myPane As GraphPane = Nothing 'Keep compiler happy.
        commonGraph(PCPplot_ZedGraph, "PCP plot", myPane)

        'Changed PM_PCP_PLOT_YLOG 2008-10-03
        myPane.YAxis.Type = AxisType.Log


        '       Dim penColours() As Color = _
        '         {
        '          Color.DarkBlue, _
        '          Color.DarkRed, _
        '          Color.DarkGreen, _
        '          Color.DarkOrange, _
        '_
        '          Color.Violet, _
        '          Color.Brown, _
        '          Color.DarkSlateBlue, _
        '          Color.DarkSalmon _
        '         }
        Dim penColours() As Color = _
          {Color.Red, _
           Color.Green, _
           Color.Orange, _
           Color.Cyan, _
           Color.Gold, _
           Color.DarkSlateBlue, _
           Color.DarkSalmon, _
           Color.DarkBlue, _
           Color.DarkRed, _
           Color.DarkGreen, _
           Color.DarkOrange, _
           Color.Violet, _
           Color.Brown, _
           Color.DarkSlateBlue, _
           Color.DarkSalmon _
          }
        'Removed:
        '  Color.Yellow, _

        Dim numColors As Integer = penColours.Length

        'Refactor all of this. Separate GUI from data structures
        '  in order to use it from Protein List window.
        '
        '  Separate function to find the number of dishes.
        '
        '  The options for which ratios to display should be a data
        '  strucuture that reflects the setting in the GUI (check boxes)

        Dim inputProteins As Integer = anInPlotList.Count
        Dim effectiveProteins As Integer = 0 'May not end up the
        '  same as input proteins if we filter some out...

        Dim startDimensionBaseOne As Integer = mStartDimensionIndex + 1

        'Changed PM_MEMORY_EFFICIENCY 2008-10-14
        Dim sbScr As StringBuilder = New StringBuilder(30)

        'Changed PM_PROTEIN_TAGS 2008-10-29
        'Dim dishes As Integer = -1 'We auto detect it from the
        ''  data structures.
        Dim dishes As Integer = _
          ProteinHitStructure.getDishesFromQuantResult(anInPlotList)

        'Explain anInPlotList...

        If True Then 'Create checkboxes. This was inside the loop...

            'Create checkboxes, one for each dish, e.g. for 2/1 ratio value.
            If Not mOneTimeInitCompleted Then 'Only do it
                '  once for the entire lifetime of this dialog.
                '  This makes the assumption that the number of dishes
                '  does not change.
                mOneTimeInitCompleted = True

                Dim lastIndex2 As Integer = dishes - 1
                Dim j As Integer
                For j = 0 To lastIndex2
                    mSILACviewOptions(j).Visible = True

                    mSILACviewOptions(j).Tag = j 'For use when
                    '  handling an event - user clicking on the
                    '  checkbox.

                    AddHandler _
                      mSILACviewOptions(j).Click, _
                      AddressOf Me.SILACviewOptionsOnClick

                    'Later, somewhere:
                    '  RemoveHandler sender.Start, AddressOf Me.SILACviewOptionsOnClick
                Next j
            End If 'SILAC checkboxes setup.
        End If 'Block.

        Dim firstProtein As Boolean = True

        'One or more curves per protein. E.g. two for triple labelling.
        'Dim curveIndex As Integer = 0   not used.

        'Dim proteinInputIndex As Integer = 0 'For colouring of curves.

        Dim nextColourIndex As Integer = 0

        Dim PCPinfo As proteinPCPstructure
        For Each PCPinfo In anInPlotList 'One item for each protein 

            If PCPinfo.proteinDataIndex2 < 0 Then
                Dim peter2 As Integer = 2
            End If

            Dim lastIndex As Integer = dishes - 1
            Dim dishZbased As Integer
            For dishZbased = 0 To lastIndex

                Dim dishOneBased As Integer = dishZbased + 1

                'Two passes: the first to decide wether to include a
                '            protein or not.
                Dim acceptProtein As Boolean = True

                'Changed PM_PCP_PLOT_SILACFILTER_GUI 2008-10-24
                'If dishZbased = 0 Then
                '    acceptProtein = False 'For now: ignore the first dish.
                '    '  This is fine for ratios. But if we want to use
                '    '  absolute values, e.g. XICs then we need.

                '    'But it is a misnomer as we do accept the current
                '    'protein for other dishes...
                'End If
                Dim dishActive As Boolean = _
                  mSILACviewOptions(dishZbased).Checked 'Direct read from
                '    GUI. Bad idea?
                If Not dishActive Then
                    acceptProtein = False
                End If

                If acceptProtein Then
                    Dim identicalZeros2 As Integer = _
                      PCPinfo.profiles(dishZbased).identicalZeros

                    'For breakpoints.
                    If identicalZeros2 > 0 Then
                        Dim peter2 As Integer = 2
                    End If

                    If identicalZeros2 > aMaxZeroPoints Then
                        acceptProtein = False
                    End If
                End If 'Protein accepted.

                Dim proteinDataIndex As Integer = PCPinfo.proteinDataIndex2

                If Not proteinDataIndex >= 0 Then
                    'This can happen if dimensions and file mapping are not
                    'in order.
                    '
                    'Or if the protein has not been quantified.

                    'Allow us to continue without errors - otherwise we
                    'would get an index out of range exception below.
                    acceptProtein = False
                End If

                If acceptProtein Then
                    'Only count for dish 1 (for now).
                    If dishZbased = 1 Then
                        effectiveProteins += 1
                    End If

                    Dim protein As ProteinHitStructure = _
                      anInProteinList(proteinDataIndex)
                    Dim accNum As String = protein.accNum

                    'Changed PM_PCP_PLOT_TAGGING 2008-11-04
                    Dim tagIndex As Integer
                    Dim primaryTagStr As String = Nothing
                    If True Then 'Block.
                        Dim tags As List(Of taggingStruct) = _
                          tagging.extractTags(protein.description3)
                        primaryTagStr = tagging.primaryTag(tags, mSBscratch)
                        If mTag2colourIndex.TryGetValue(primaryTagStr, tagIndex) Then
                            Dim peter2 As Integer = 2 'Exists...
                        Else
                            mTag2colourIndex.Add(primaryTagStr, nextColourIndex)
                            tagIndex = nextColourIndex
                            nextColourIndex += 1
                        End If
                    End If 'Block.

                    Dim someCurve As PointPairList = New PointPairList

                    'Changed PM_PCP_PLOT_SEVERAL_DISHES 2008-10-16
                    'Dim yValue As Double

                    'Dim dimNumber As Integer = 1


                    Dim dimNumber As Integer = startDimensionBaseOne

                    'Dim someProfile As proteinProfileStructure
                    'For Each someProfile In PCPinfo.profiles 'One profile for each dish.
                    '    Dim yValue As Double = _
                    '      someProfile.
                    '    SILACvaluesForDimension.SILACdishes2(dishZbased).SILACratio2()
                    'Next
                    Dim someProfile As proteinProfileStructure = _
                      PCPinfo.profiles(dishZbased)
                    Dim someSingleSILACvalue As singleSILACvaluesStructure
                    For Each someSingleSILACvalue In someProfile.dimensionValues

                        Dim yValue As Double = _
                          someSingleSILACvalue.SILACratio2

                        Dim label As String = Nothing
                        If True Then 'Block.
                            sbScr.Length = 0

                            sbScr.Append("Hit ")
                            sbScr.Append(protein.hitNumber.ToString())
                            sbScr.Append(", ")
                            sbScr.Append(accNum)

                            'dishZbased

                            'Changed PM_EXTENDED_CONSENSUSSCORE 2008-11-28
                            ''Changed PM_CONSENSUSSCORE_ALLDISHES 2008-11-11
                            'Dim consensusScore As Double = _
                            '  ProteinHitStructure.getConsensusScore( _
                            '    protein.consensusScore2, dishZbased)
                            'Changed PM_CONSENSUSSCORE_ALLDISHES 2008-11-11
                            Dim consensusInfo As consensusScoreStruct = _
                              ProteinHitStructure.getConsensusScore2( _
                                protein.consensusScore3, dishZbased)
                            Dim consensusScore As Double = _
                              consensusInfo.consensusScore

                            'Also add number of non-zero points and points outside
                            'consensus?

                            Dim closeToZero As Double = 0.00001 'How low can
                            '  it be?
                            'Changed PM_APPARENT_IDENTICAL_ZERO 2008-10-22
                            sbScr.Append(". ")
                            If yValue > 0.02 Or yValue < closeToZero Then
                                sbScr.Append(yValue.ToString("0.00"))
                            Else
                                sbScr.Append(yValue.ToString("E2"))
                            End If
                            'Dim addLastTrailing As Boolean = True

                            'sbScr.Append(". Dim=")
                            'sbScr.Append(dimNumber)

                            'Moved down here so hit number is always first.
                            If consensusScore > 0.000001 Then
                                'addLastTrailing = False
                                sbScr.Append(". ")
                                sbScr.Append("Consensus score: ")
                                sbScr.Append(consensusScore.ToString("0.00"))
                            End If
                            If primaryTagStr <> "" Then
                                'addLastTrailing = False
                                sbScr.Append(". ")
                                sbScr.Append(primaryTagStr)
                            Else
                                Dim peter2 As Integer = 2
                            End If

                            sbScr.Append(". ")
                            label = sbScr.ToString()
                        End If 'Block.

                        Dim yValueToPlot As Double = 0.001 'If log(y) is undefined.
                        If yValue > 0.0 Then
                            yValueToPlot = yValue
                        Else
                            Dim peter2 As Integer = 2 'Zero for some reason (e.g. no data)
                        End If

                        someCurve.Add(dimNumber, yValueToPlot, label)
                        dimNumber += 1
                    Next 'Through some protein profile (for a particular dish).

                    'Changed PM_PCP_PLOT_TAGGING 2008-11-04
                    ''Changed PM_KEEP_PROTEIN_COLOURS 2008-10-14. Keep same
                    ''  colours no matter the filter.
                    ''Dim colourIndex As Integer = curveIndex Mod numColors
                    'Dim colourIndex As Integer = _
                    '  proteinInputIndex Mod numColors
                    Dim colourIndex As Integer = _
                      tagIndex Mod numColors

                    Dim colourToUse As Color = penColours(colourIndex)

                    Dim plotType As SymbolType = _
                      derivePlotType(dishZbased)

                    Dim curveLabel As String = ""
                    If firstProtein Then
                        'Note: not a legend for every protein and every
                        '      dish - only something to indicate the
                        '      symbol for different dishes, e.g. diamond 
                        '      for 2/1 and star for 3/1.

                        curveLabel = "Dish " & dishOneBased & "/1"
                    End If

                    Dim myCurve As LineItem = myPane.AddCurve( _
                      curveLabel, _
                      someCurve, colourToUse, plotType)

                    myCurve.Line.Fill = New Fill()

                    ''Turn off the line so it's a scatter plot.
                    'myCurve.Line.IsVisible = False

                    'curveIndex += 1
                End If 'Protein accepted.
            Next dishZbased 'Through SILAC dishes.

            'proteinInputIndex += 1

            firstProtein = False
        Next 'Through protein (results from).


        If Not aConsensusProfile2 Is Nothing Then
            Dim xValue2 As Double
            Dim yValue2 As Double

            Dim dishZ As Integer = 0
            Dim consensusDishInfo As frmProteinList.consensusDishInfoStruct
            For Each consensusDishInfo In aConsensusProfile2

                Dim dishActive As Boolean = _
                  mSILACviewOptions(dishZ).Checked 'Direct read from
                '    GUI. Bad idea?

                If dishActive Then
                    Dim someCurve As PointPairList = New PointPairList

                    Dim dishBaseOne As Integer = dishZ + 1
                    Dim labelPrefix As String = _
                      "Consensus profile for dish " & _
                      dishBaseOne.ToString & "." 'For now: same label for all
                    '  points in a consensus profile.

                    Dim dimNumber As Integer = startDimensionBaseOne
                    Dim somePoint As statsStructure
                    For Each somePoint In consensusDishInfo.profile

                        'Changed PM_CONSENSUSSCORE_LOGTRANSFORMED 2008-11-30
                        'somePoint.average(xValue2, yValue)
                        Dim transformedValue As Double
                        somePoint.average(xValue2, transformedValue)
                        yValue2 = inverseRatioTransform(transformedValue)

                        Dim N As Integer = somePoint.N
                        Dim minV As Double = somePoint.minY
                        Dim maxV As Double = somePoint.maxY

                        Dim label As String = _
                          labelPrefix & " " & yValue2.ToString("0.00") & _
                          ". N=" & N & _
                          ". [" & minV.ToString("0.00") & ";" & _
                          maxV.ToString("0.00") & "]."

                        someCurve.Add(dimNumber, yValue2, label)

                        dimNumber += 1
                    Next

                    'Not used for now.
                    'Dim plotType As SymbolType = _
                    '  derivePlotType(dish)

                    Dim curveLabel As String = ""
                    Dim colourToUse As Color = Color.Blue

                    Dim myCurve As LineItem = myPane.AddCurve( _
                      curveLabel, _
                      someCurve, colourToUse, SymbolType.Triangle)
                End If

                dishZ += 1
            Next 'Through aConsensusProfile

        End If

        myPane.XAxis.Title.Text = _
          anInPrimaryDimensionName

        myPane.YAxis.Title.Text = "Quantitation values"

        myPane.YAxis.MajorGrid.IsVisible = True
        myPane.YAxis.MajorGrid.Color = Color.BlueViolet

        'Changed PM_MEMORY_EFFICIENCY 2008-12-03
        'Dim title As String = _
        '  "PCP plot" & " for " & effectiveProteins & _
        '  " proteins (out of " & inputProteins & ")."
        mSBscratch.Length = 0
        mSBscratch.Append("PCP plot")
        mSBscratch.Append(" for ")
        mSBscratch.Append(effectiveProteins)
        mSBscratch.Append(" proteins (out of ")
        mSBscratch.Append(inputProteins)
        mSBscratch.Append(").")
        Dim title As String = mSBscratch.ToString
        myPane.Title.Text = title

        'Changed PM_TWOLEVEL_WINDOWNUMBERING_PREFIX 2008-12-03
        mSBscratch.Length = 0
        mSBscratch.Append("#")
        mSBscratch.Append(mParseIDnumber)
        mSBscratch.Append(". ")
        mSBscratch.Append(title)
        Dim windowTitle As String = mSBscratch.ToString
        Me.Text = windowTitle

        'myPane.XAxis.Scale.Min = aDataRanges.minX - 30.0
        'myPane.XAxis.Scale.Max = aDataRanges.maxX + 30.0

        ' Tell ZedGraph to refigure the
        ' axes since the data have changed.
        '
        ' The AxisChange() method call must be made
        ' any time you add or change the data.
        PCPplot_ZedGraph.AxisChange()
        PCPplot_ZedGraph.Refresh()
    End Sub 'updateDisplay()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Shared Sub commonGraph( _
      ByRef anInOutZgc As ZedGraphControl, _
      ByRef anInTitle As String, _
      ByRef anOutPane As GraphPane)

        ' Get a reference to the GraphPane. Note: this does not create a new
        ' one with some defaults. If a plot is already active then we get
        ' the current settings...
        anOutPane = anInOutZgc.GraphPane

        anOutPane.CurveList.Clear()

        'Defaults. Important if changing back to a pane
        'that relies on some defaults.
        anOutPane.XAxis.Type = AxisType.Linear

        'Important as for 2 out of 3 types of plots we now set 
        'the x-axis manually.
        anOutPane.XAxis.Scale.MinAuto = True
        anOutPane.XAxis.Scale.MaxAuto = True

        If True Then
            anOutPane.XAxis.Scale.TextLabels = Nothing
            anOutPane.XAxis.MajorTic.IsBetweenLabels = False

            'Note: this is everything: x-axis, y-axis, plot area, header.
            '
            'anOutPane.Fill = New Fill(Color.FromArgb(223, 223, 255)) 'Colour
            ''  is whitened blue-violet.
            'anOutPane.Fill = New Fill(Color.FromArgb(0, 0, 0)) 'Colour
            ''  is black.
            'anOutPane.Fill = New Fill(Color.FromArgb(255, 255, 255)) 'Colour
            ''  is white.

            'Region ***around*** actual curves.
            anOutPane.Fill = New Fill(Color.FromArgb(128, 128, 128)) 'Colour
            '  is dark-grey.
        End If

        'Region with the actual curves.
        anOutPane.Chart.Fill = New Fill(Color.FromArgb(223, 220, 215)) 'Colour
        '  is light grey

        anOutPane.Title.Text = anInTitle
        anInOutZgc.IsShowPointValues = True
    End Sub 'commonGraph


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub newMaxZeroPoints(ByVal aMaxZeroPoints As Integer)
        mMaxZeroPoints = aMaxZeroPoints
        Me.updateDisplay()
    End Sub 'newMassErrorUnits


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub rbMaxZero0_CheckedChanged( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles rbMaxZero0.CheckedChanged

        If Not mStartingUp Then
            'How do we get it from the event?
            Dim newVal As Boolean = rbMaxZero0.Checked
            If newVal = True Then
                newMaxZeroPoints(0)
            End If
        Else
            Dim peter2 As Integer = 2
        End If
    End Sub 'rbMaxZero0_CheckedChanged


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub rbMaxZero1_CheckedChanged( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles rbMaxZero1.CheckedChanged

        If Not mStartingUp Then
            'How do we get it from the event?
            Dim newVal As Boolean = rbMaxZero1.Checked
            If newVal = True Then
                newMaxZeroPoints(1)
            End If
        Else
            Dim peter2 As Integer = 2
        End If
    End Sub 'rbMaxZero1_CheckedChanged


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub rbMaxZero2_CheckedChanged( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles rbMaxZero2.CheckedChanged

        If Not mStartingUp Then
            'How do we get it from the event?
            Dim newVal As Boolean = rbMaxZero2.Checked
            If newVal = True Then
                newMaxZeroPoints(2)
            End If
        Else
            Dim peter2 As Integer = 2
        End If
    End Sub 'rbMaxZero2_CheckedChanged


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub rbMaxZero3_CheckedChanged( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles rbMaxZero3.CheckedChanged

        If Not mStartingUp Then
            'How do we get it from the event?
            Dim newVal As Boolean = rbMaxZero3.Checked
            If newVal = True Then
                newMaxZeroPoints(3)
            End If
        Else
            Dim peter2 As Integer = 2
        End If
    End Sub 'rbMaxZero3_CheckedChanged


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub rbMaxZero4_CheckedChanged( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles rbMaxZero4.CheckedChanged

        If Not mStartingUp Then
            'How do we get it from the event?
            Dim newVal As Boolean = rbMaxZero4.Checked
            If newVal = True Then
                newMaxZeroPoints(4)
            End If
        Else
            Dim peter2 As Integer = 2
        End If
    End Sub 'rbMaxZero4_CheckedChanged


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub rbMaxZero5_CheckedChanged( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles rbMaxZero5.CheckedChanged

        If Not mStartingUp Then
            'How do we get it from the event?
            Dim newVal As Boolean = rbMaxZero5.Checked
            If newVal = True Then
                newMaxZeroPoints(5)
            End If
        Else
            Dim peter2 As Integer = 2
        End If
    End Sub 'rbMaxZero5_CheckedChanged


    'Changed PM_PCP_PLOT_RESIZE 2008-10-02
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    ' SetSize() is separate from Resize() so we can 
    ' call it independently from the Form1_Load() method.
    '
    ' This leaves a 10 px margin around the outside of the control.
    ' Customize this to fit your needs.
    Private Sub SetSize()

        Dim yOffset As Integer = 52 + 10
        Dim xOffset As Integer = 13

        Dim rightBottomMargin As Integer = 20

        'Dim plotSeparation As Integer = 30

        Dim xSize As Integer = _
          ClientRectangle.Width - rightBottomMargin - xOffset

        Dim ySizeAll As Integer = _
          ClientRectangle.Height - yOffset - rightBottomMargin

        'Dim ySize As Integer = (ySizeAll - plotSeparation) \ 2

        Dim y1 As Integer = yOffset

        'Dim y2 As Integer = yOffset + ySize + plotSeparation
        Dim y2 As Integer = yOffset + ySizeAll + 0

        PCPplot_ZedGraph.Location = New Point(xOffset, y1)

        'PCPplot_ZedGraph.Size = New Size(xSize, ySize)
        PCPplot_ZedGraph.Size = New Size(xSize, ySizeAll)

        'massErrors2_ZedGraph.Location = New Point(xOffset, y2)
        'massErrors2_ZedGraph.Size = New Size(xSize, ySize)
    End Sub 'SetSize


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub frmPCPplot_Resize( _
      ByVal aSender As Object, ByVal anEvent As System.EventArgs) _
      Handles Me.Resize

        Me.SetSize()
    End Sub 'frmPCPplot_Resize


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function PCPplot_ZedGraph_MouseMoveEvent( _
      ByVal aSender As ZedGraph.ZedGraphControl, _
      ByVal anEvent As System.Windows.Forms.MouseEventArgs) _
      As Boolean _
      Handles PCPplot_ZedGraph.MouseMoveEvent

        Return False
    End Function 'massErrors_ZedGraph_MouseMoveEvent


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function PCPplot_ZedGraph_MouseUpEvent( _
      ByVal aSender As ZedGraph.ZedGraphControl, _
      ByVal anEvent As System.Windows.Forms.MouseEventArgs) _
      As Boolean _
      Handles PCPplot_ZedGraph.MouseUpEvent

        Return False
    End Function 'massErrors_ZedGraph_MouseMoveEvent


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function PCPplot_ZedGraph_MouseDownEvent( _
      ByVal aSender As ZedGraph.ZedGraphControl, _
      ByVal anEvent As System.Windows.Forms.MouseEventArgs) _
      As Boolean _
      Handles PCPplot_ZedGraph.MouseDownEvent

        Dim tagForHit As String = _
          frmRecalibrationVisualisation.getTagFromHitZedGraphCurve( _
            PCPplot_ZedGraph.GraphPane, anEvent.X, anEvent.Y)

        If tagForHit <> "" Then
            'xtract 

            'Extract protein hit and primary dimension number (e.g. sucrose
            'fraction 5) from the tag (that is also displayed
            'to the user if the mouse hovers above a plotted point.)

            Dim protNum As Integer
            If True Then
                Dim idx As Integer = tagForHit.IndexOf(",", 0)
                Trace.Assert(idx >= 0, _
                  "PIL ASSERT. "","" not found in: " & tagForHit)

                Dim len As Integer = idx

                'Extra memory garbage!! Eliminate?
                Dim hStr As String = tagForHit.Substring(0, len)

                Dim idx2 As Integer = hStr.IndexOf("Hit ", 0)
                idx2 += 4 'Step past "Hit ".

                Dim len2 As Integer = hStr.Length - idx2
                Dim hitNumStr As String = hStr.Substring(idx2, len2)

                protNum = CInt(hitNumStr)
            End If

            Dim dimensionNumber As Integer
            If True Then
                Dim idx As Integer = tagForHit.IndexOf("Dim=", 0)
                idx += 4 'Step past "Dim=".

                Dim idx2 As Integer = tagForHit.IndexOf(".", idx)
                Dim len2 As Integer = idx2 - idx

                Dim dimNumStr As String = tagForHit.Substring(idx, len2)
                dimensionNumber = CInt(dimNumStr)
            End If

            mParent.openProtein(protNum, dimensionNumber)
        Else
            'Nothing was hit.
            Dim peter2 As Integer = 2
        End If

    End Function 'PCPplot_ZedGraph_MouseDownEvent


    'Changed PM_PCP_PLOT_SILACFILTER_GUI 2008-10-24
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub SILACviewOptionsOnClick( _
      ByVal aSender As Object, ByVal anEvent As EventArgs)

        If Not mStartingUp Then
            Dim someCheckBox As CheckBox = DirectCast(aSender, CheckBox)
            Dim cbIndex As Integer = CInt(someCheckBox.Tag)

            Me.updateDisplay() 'This is all we need to do. This 
            '  function will read off the new setting from the
            '  checkbox.
        Else
            Dim peter2 As Integer = 2
        End If


    End Sub 'SILACviewOptionsOnClick()


    'Changed PM_CONSENSUSSCORE_LOGTRANSFORMED 2008-11-30
    'Move somewhere else. It has nothing to do in frmPCPplot.vb.
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Shared Function ratioTransform(ByVal aRatio As Double) _
      As Double

        'For now: only log (others could be the (1/x, x) thing or no transform).

        Return Math.Log(aRatio) 'math.Log is natural logaright, not log2
    End Function 'ratioTransform


    'Changed PM_CONSENSUSSCORE_LOGTRANSFORMED 2008-11-30
    'Move somewhere else. It has nothing to do in frmPCPplot.vb.
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Shared Function inverseRatioTransform( _
      ByVal aTransformedRatio As Double) _
      As Double

        'For now: only inverse log (others could be the (1/x, x) thing or
        '         no transform).

        Return Math.Exp(aTransformedRatio) 'math.Log is natural logaright, not log2
    End Function 'ratioTransform


End Class 'frmPCPplot


    

    

Generated by script codePublish.pl at 2009-01-05T15:20:59.