pythonplotgraphrepresentation

Plot to represent coverage of a sequence


Does anyone have an idea of generating a plot that would look something like this: plot

Basically, I would have sequences, say T1 and T2, which need to be aligned to the "main" sequence. Also, please note that there is no need for actual alignment here, the sequence range is already known (For eg. T1 is 7-12, 32-36). These regions simply needs to be place accordingly and represented.

I thought of representing it in a bar plot, but as there would be breaks in the region it wouldnt be helpful.


Solution

  • Here is a very minimalistic example that should get you going:

    import matplotlib.pyplot as plt
    
    
    Main = "123684651984656497243684986425465798"
    T1 = "651984"
    T2 = "864"
    
    
    f, ax = plt.subplots()
    ax.set_axis_off()
    ax.text(.1,.5, 
            "\n".join(
                [Main, 
                 " "*Main.index(T1) + T1, 
                 " "*Main.index(T2) + T2]),
            ha="left", 
            va="center",
            family="monospace")
    

    enter image description here