简体   繁体   中英

How to integrate confidence values into DNA chromatogram images?

I'm using biojava to create a chromatogram.

The chromatogram is an image. Each basecall is held within a rectange.

To get x coordinate (left side): gfx.getCallboxBounds(int i).getX();

To get width: gfx.getCallboxBounds(int i).getX()

where the integer i represents the rectangle in the arrangement of rectangles that build the chromatogram.

To get the confidence value of a given base:

(I create an array called confidence) confidence[i - 1];

where i is, again, the base in question.

Confidence values are reported between 1 and 70. The height of the image is 240 pixels.

I want to print 2 pixel thick, gray lines at relatives heights along the sequence, for the width of each basecall.

For instance, if the quality of basecall (Rectangle) 60 is 40 and its width is 20, a gray line will be drawn at 137 pixels (40 / 70 * 240) for its width.

Here is the method that draws the trace:

    ChromatogramFactory chromFactory = new ChromatogramFactory();

    Chromatogram chrom = ChromatogramFactory.create(abi);

    ChromatogramGraphic gfx = new ChromatogramGraphic(chrom);

    BufferedImage bi = new BufferedImage(
            gfx.getWidth(),
            gfx.getHeight(),
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = bi.createGraphics();
    g2.setBackground(Color.white);
    g2.clearRect(0, 0, bi.getWidth(), bi.getHeight());
    if (g2.getClip() == null) {
        g2.setClip(new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
    }
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    gfx.drawTo(g2);

    g2.draw(new java.awt.Rectangle(-10, -10, 5, 5));

EDIT: Also, the sequence length is the same as the number of rectangles. Each letter in the sequence represents a basecall, as does each rectangle.

Using the code below, I was able to add lines at relative locations to give the confidence values:

    int leftBound = 0;
    int rightBound = 0;
    double confVal = 0;
    double heightDouble = 0;
    int height = 0;

    g2.setColor(Color.LIGHT_GRAY);

    for (int i = 0; i < gfx.getCallboxCount(); i++) {
        leftBound = (int) gfx.getCallboxBounds(i).getX();
        rightBound = (int) ((int) leftBound + gfx.getCallboxBounds(i).getWidth());
        confVal = confidence[i] * 2.67;
        heightDouble = 200 - confVal;
        height = (int) heightDouble;
        g2.drawLine(leftBound, height, rightBound, height);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM