virajbdeshpande / AmpliconArchitect

AmpliconArchitect (AA) is a tool to identify one or more connected genomic regions which have simultaneous copy number amplification and elucidates the architecture of the amplicon. In the current version, AA takes as input next generation sequencing reads (paired-end Illumina reads) mapped to the hg19/GRCh37 reference sequence and one or more regions of interest. Please "watch" this repository for improvements in runtime, accuracy and annotations for GRCh38 human reference genome coming up soon.
Other
131 stars 42 forks source link

matplotlib figure memory leak #64

Open auberginekenobi opened 4 years ago

auberginekenobi commented 4 years ago

bam_to_breakpoint.py does not close matplotlib figures after saving, which creates a memory leak with each interval plotted. Should be a simple fix by adding plt.close() to the end of the plot_segmentation function:

    # Plot coverage, meanshift copy count estimates and discordant edges in interval
    def plot_segmentation(self, ilist, amplicon_name, segments=[], scale_list=[], eilist=None, font='small'):
...
        fig.subplots_adjust(hspace=0)
        fig.savefig(amplicon_name + '.png', dpi=dpi)
        fig.savefig(amplicon_name + '.pdf', dpi=dpi)
        plt.close()

Did some basic testing to confirm the fix works.

virajbdeshpande commented 4 years ago

Owen, Excellent catch and great work figuring out the fix! I have add the fix to the branch runtime_discordant_clustering and will merge into master once I am finished testing some improvements on the branch.