Graphical representation of the aberrations found in a number of cases

The analysis of a number of cases severly depends on how data are stored on your system (databases, text files etc.). An example program showing the analysis of data downloaded into a textfile from the Mitelman database is available from the Download section.

Overview

Here we assume that the karyotype description of the cases are stored in an array, aKaryotypes. We will loop through that array and initialise Karyotype objects. If the ISCN formulae describe polyclonal karyotypes, a Karyotypes object is initialised first and from that the composite karyotype is queried.

From each karyotype, the objects for structural aberrations and for quantitative aberrations are queried. They are added into collections of structural aberrations and quantitative aberrations for all cases.

After looping through the array, from the above collections the object containing the aberrations on a per band level are queried at the requested resolution. This is quite a slow step, and hence we did not collect the data with this type of object while looping through the array, but with the considerably faster objects for structural and quantitative aberrations.

Next, the object representing aberrations on a per base level is passed into the appropriate function of the CyDASGraphics class and the bitmap returned is shown on a form in a panel.

Details

Variables

Let us start withh the variables declaration:

Module wide variables

The bitmap with the result ought to be module wide, since it will be used in the referesh event procedure of its drawing location.

'a bitmap which will store the result
Dim oBitmap As System.Drawing.Bitmap

Local variables

'the array with the textual descriptions of the (polyclonal) karyotypes
Dim aKaryotypes As String()

'a Karyotypes object to be initialised with each polyclonal karyotype
Dim cKaryotypes As Karyotypes

'the Karyotype object for the composite Karyotype
Dim cKaryotype As Karyotype

'the QuantitativeAberrations object for the quantitative aberrations of all cases
'we can initialise it here
Dim cQuantitativeAberrations As QuantitativeAberrations = New QuantitativeAberrations()

'the QualitativeAberrations object for the structural aberrations of all cases
'we can initialise it here
Dim cQualitativeAberrations As QualitativeAberrations = New QualitativeAberrations()

'the GainsLossesStructs object which will contain the aberrations on a per band level
'at 400 bphs for all cases
'its initialistaion with the resolution causes an ordered set of all bands at that resolution
'to be calculated, thus enhancing later performance
Dim cGainsLossesStructs as GainsLossesStructs = New GainsLossesStructs(Band.eResolutionLevel.Resolution400Bands)

'a counter variable
Dim i As Integer

Loop through the array

Now we can start the loop through the array. Be aware, that many functions of the CyDAS package may through exceptions if a karyotype is not described properly. You may want to add several Try-Catch clauses.

For i = 0 to aKaryotypes.Length - 1
    'initialise a Karyotypes object
    cKaryotypes = New Karyotypes(aKaryotypes(i))

    'get the composite karyotype for analysis
    oKaryotype = cKaryotypes.getCompositeKaryotype

    'get the quantitative aberrations from it and it to the collection of
    'quantitative aberrations for all cases
    cQuantitativeAberrations.addRange(oKaryotype.getQuantitativeAberrations)

    'get the qualitative aberrations from it and it to the collection of
    'qualitative aberrations for all cases
    cQualitativeAberrations.addRange(oKaryotype.getQualitativeAberrations)

Next

Per Bands Level

The QualitativeAberrations and QuantitativeAberrations are now translated into aberrations per bands level. The appropriate GainsLossesStructs object has been initialised above.

'get aberrations per bands from Quantitative aberration and
'add it to the collection object
cGainsLossesStructs.addRange(cQuantitativeAberrations.getGainsLossesStructs(Band.eResolutionLevel.Resolution400Bands))

'get aberrations per bands from Qualitative aberration and
'add it to the collection object
cGainsLossesStructs.addRange(cQualitativeAberrations.getGainsLossesStructs(Band.eResolutionLevel.Resolution400Bands))

Graphics

The GainsLossesStructs object contains all relevant information for drawing the bitmap. Depending on which type of aberrations you want to see, choose:

Quantitative aberrations

mBitmap = CyDASGraphics.drawGainsAndLossesForAllChromosomes(cGainsLossesStructs)

Qualitative aberrations

mBitmap = CyDASGraphics.drawStructsForAllChromosomes(cGainsLossesStructs)

The bitmap may be bigger than the panel on which it is to be drawn, hence the size of that panel is adjusted. The form should have the Autoscroll property set to true, so the user can scroll and see all of the bitmap.

'the size of the Panel is adjusted to the size of the bitmap
'that may cause scroll bars on the form
Panel1.Height = mBitmap.Height
Panel1.Width = mBitmap.Width

'make the panel draw the result
Panel1.Refresh()

For a nice look, we have to tell the panel with the bitmap what to when it is refreshed:

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
    'we must redraw the bitmap at the paint event, else it may be displayed wrongly
    If Not mBitmap Is Nothing Then
        Dim oGraphics As Graphics = Panel1.CreateGraphics
        oGraphics.DrawImage(mBitmap, 0, 0)
    End If
End Sub