Based on the [supplementary material][1] 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: ```python 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 ``` [1]: https://www.biorxiv.org/content/biorxiv/suppl/2016/12/19/092890.DC2/092890-1.pdf