Skip to main content
added 146 characters in body
Source Link
0x90
  • 1.4k
  • 10
  • 21

Here is the main function:

WIDTH = 221
HEIGHT = 100;
def create_pileup_images(candidate_variants):
 for candidate in candidate_variants:
 for biallelic_variant in split_into_biallelics(candidate):
 start = biallelic_variant.start - (WIDTH-1) / 2
 end = WIDTH - span_start
 ref_bases = reference.get_bases(start, end)
 image = Image(WIDTH, HEIGHT)
 row_i = fill_reference_pixels(ref, image)
 for read in reads.get_overlapping(start, end):
 if row_i < HEIGHT and is_usable_read(read):
 add_read(image, read, row_i)
 row_i += 1
 yield image

def fill_reference_pixels(ref, image):
 for row in range(5):
 for col in range(WIDTH):
 alpha = 0.4
 ref_base = ref[col]
 red = get_base_color(ref_base)
 green = get_quality_color(60) # The reference is high quality
 blue = get_strand_color(True) # The reference is on the positive strand
 image[row, col] = make_pixel(red, green, blue, alpha)
 return 5
WIDTH = 221
HEIGHT = 100

def create_pileup_images(candidate_variants):
    for candidate in candidate_variants:
        for biallelic_variant in split_into_biallelics(candidate):
            start = biallelic_variant.start - (WIDTH - 1) / 2
            end = WIDTH - span_start
            ref_bases = reference.get_bases(start, end)
            image = Image(WIDTH, HEIGHT)
            row_i = fill_reference_pixels(ref_bases, image)
            for read in reads.get_overlapping(start, end):
                if row_i < HEIGHT and is_usable_read(read):
                    add_read(image, read, row_i)
                    row_i += 1
            yield image

def fill_reference_pixels(ref, image):
    for row in range(5):
        for col in range(WIDTH):
            alpha = 0.4
            ref_base = ref[col]
            red = get_base_color(ref_base)
            green = get_quality_color(60)  # The reference is high quality
            blue = get_strand_color(True)  # The reference is on the positive strand
            image[row, col] = make_pixel(red, green, blue, alpha)
    return 5

Here is the main function

WIDTH = 221
HEIGHT = 100;
def create_pileup_images(candidate_variants):
 for candidate in candidate_variants:
 for biallelic_variant in split_into_biallelics(candidate):
 start = biallelic_variant.start - (WIDTH-1) / 2
 end = WIDTH - span_start
 ref_bases = reference.get_bases(start, end)
 image = Image(WIDTH, HEIGHT)
 row_i = fill_reference_pixels(ref, image)
 for read in reads.get_overlapping(start, end):
 if row_i < HEIGHT and is_usable_read(read):
 add_read(image, read, row_i)
 row_i += 1
 yield image

def fill_reference_pixels(ref, image):
 for row in range(5):
 for col in range(WIDTH):
 alpha = 0.4
 ref_base = ref[col]
 red = get_base_color(ref_base)
 green = get_quality_color(60) # The reference is high quality
 blue = get_strand_color(True) # The reference is on the positive strand
 image[row, col] = make_pixel(red, green, blue, alpha)
 return 5

Here is the main function:

WIDTH = 221
HEIGHT = 100

def create_pileup_images(candidate_variants):
    for candidate in candidate_variants:
        for biallelic_variant in split_into_biallelics(candidate):
            start = biallelic_variant.start - (WIDTH - 1) / 2
            end = WIDTH - span_start
            ref_bases = reference.get_bases(start, end)
            image = Image(WIDTH, HEIGHT)
            row_i = fill_reference_pixels(ref_bases, image)
            for read in reads.get_overlapping(start, end):
                if row_i < HEIGHT and is_usable_read(read):
                    add_read(image, read, row_i)
                    row_i += 1
            yield image

def fill_reference_pixels(ref, image):
    for row in range(5):
        for col in range(WIDTH):
            alpha = 0.4
            ref_base = ref[col]
            red = get_base_color(ref_base)
            green = get_quality_color(60)  # The reference is high quality
            blue = get_strand_color(True)  # The reference is on the positive strand
            image[row, col] = make_pixel(red, green, blue, alpha)
    return 5

Source Link
0x90
  • 1.4k
  • 10
  • 21

Based on the supplementary material as mentioned in a comment by Devon Ryan:

The second phase of DeepVariant encodes the reference and read support for each candidate variant into an RGB image. The pseudo-code for this component is shown below; it contains all of the key operations to build the image, leaving out for clarity error handling, code to deal with edge cases like when variants occur close to the start or end of the chromosome, and the implementation of non-essential and/or obvious functions.

Here is the main function

WIDTH = 221
HEIGHT = 100;
def create_pileup_images(candidate_variants):
 for candidate in candidate_variants:
 for biallelic_variant in split_into_biallelics(candidate):
 start = biallelic_variant.start - (WIDTH-1) / 2
 end = WIDTH - span_start
 ref_bases = reference.get_bases(start, end)
 image = Image(WIDTH, HEIGHT)
 row_i = fill_reference_pixels(ref, image)
 for read in reads.get_overlapping(start, end):
 if row_i < HEIGHT and is_usable_read(read):
 add_read(image, read, row_i)
 row_i += 1
 yield image

def fill_reference_pixels(ref, image):
 for row in range(5):
 for col in range(WIDTH):
 alpha = 0.4
 ref_base = ref[col]
 red = get_base_color(ref_base)
 green = get_quality_color(60) # The reference is high quality
 blue = get_strand_color(True) # The reference is on the positive strand
 image[row, col] = make_pixel(red, green, blue, alpha)
 return 5
Post Made Community Wiki by 0x90