GangCaoLab / CoolBox

Jupyter notebook based genomic data visualization toolkit.
https://gangcaolab.github.io/CoolBox/index.html
GNU General Public License v3.0
224 stars 37 forks source link

Plot saving in API mode #96

Open DexinYang1998 opened 5 months ago

DexinYang1998 commented 5 months ago

Hi,

Thanks for your wonderful tools. In practice, I can successfully plot the tracks in Notebook, and I am wondering whether there is a way to save the current plot in PDF format.

Thanks so much for your help!

HiC_frame = HiCMat(HiC, balance = False) + \
    Spacer(0.5) 

with highlights_locus, highlights_cebpa:
    bw_frame = Virtual4C(HiC, "chr7:3512000-35125000") + Title("Virtual4C") + \
        Spacer(0.5) + \
        BigWig(H3K27ac_bw) + MinValue(0) +  Vlines(locus) + Title("H3K27ac") + \
        Spacer(0.5) + \
        BigWig(ATAC_bw) + MinValue(0) +  Vlines(locus) + Title("ATAC") + \
        Spacer(0.5) + \
        BigWig(NKX2_1_bw) + MinValue(0) +  Vlines(locus) + Title("Nkx2-1") + \
        GTF(gtf_mm10)
#frame.plot("chr7:35104964-35161193") 

frame = HiC_frame + bw_frame + XAxis()
frame.plot("chr7:35010000-35200000")

image

Meanwhile, I try to use two different commands with the same genomics coordinates to save figures, but I encountered some errors.

fig = frame.plot("chr7:35010000-35200000")
fig.savefig(fname= "test.pdf")

image

bsr = Browser(frame, reference_genome = "mm10")
bsr.goto("chr7:35010000-35200000")
bsr.save("test.pdf")

image

wbszhu commented 4 months ago

Hi, can you try as below:

bsr = Browser(frame, reference_genome = "mm10")
bsr.goto("chr7:35010000-35200000")
bsr.show()
bsr.save("test.pdf")