karyoploteR icon indicating copy to clipboard operation
karyoploteR copied to clipboard

saving several zoom in regions

Open mea2712 opened this issue 4 years ago • 5 comments

Hi!

  1. I wonder if there is a way of plotting several zoom regions in different chromosomes in the same plot.
  2. right now I'm plotting each zoom region in a separate plot and saving them in a list. How do I do to print that list to a file (w several pages) or files? I've tried a for loop using png()/dev.off, I've tried print(), I've tried converting them to grob and use ggsave(). But nothing seem to work.

Thanks!

mea2712 avatar Nov 23 '20 10:11 mea2712

Hi @mea2712

1 - It is not possible right now and it might not be possible in the future, due to the complexity it would add to the internal drawing code. However, you can combine several independent karyoplots using ggplotify and cowplot. You can find an example here: https://github.com/bernatgel/karyoploteR/issues/51

2 - karyoploteR does not use ggplot for graphics, but base R, so ggsave won't work for it. You can make it work with ggplotify as in the issue linked above or use a plot device that accepts pages such as pdf. With pdf you can start your pdf (with "pdf(file...)"), then plot several plots with multiple calls to plotKaryotype and finally call dev.off(). With that you should end with a single pdf file with multiple pages, one per plot.

Just a note, take into account that the object returned by plotKaryotype contain information on how the plot was created and the data plotted, but it's not "the plot" itself. Contrary to ggplot objects, you can not use it to recreate the plot as in ggsave and others.

Hope this helps

Bernat

bernatgel avatar Nov 23 '20 15:11 bernatgel

Thank you for your reply! One additional question, to create an svg for some reason the generic svg() is not working. Are there any other options to outputting svg files? Thanks!!

Maria. Arceo DVM, MSc +46 073 786 0483

On Mon, Nov 23, 2020 at 4:52 PM Bernat Gel [email protected] wrote:

Hi @mea2712 https://github.com/mea2712

1 - It is not possible right now and it might not be possible in the future, due to the complexity it would add to the internal drawing code. However, you can combine several independent karyoplots using ggplotify and cowplot. You can find an example here: #51 https://github.com/bernatgel/karyoploteR/issues/51

2 - karyoploteR does not use ggplot for graphics, but base R, so ggsave won't work for it. You can make it work with ggplotify as in the issue linked above or use a plot device that accepts pages such as pdf. With pdf you can start your pdf (with "pdf(file...)"), then plot several plots with multiple calls to plotKaryotype and finally call dev.off(). With that you should end with a single pdf file with multiple pages, one per plot.

Just a note, take into account that the object returned by plotKaryotype contain information on how the plot was created and the data plotted, but it's not "the plot" itself. Contrary to ggplot objects, you can not use it to recreate the plot as in ggsave and others.

Hope this helps

Bernat

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bernatgel/karyoploteR/issues/93#issuecomment-732247253, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM2LO2EWXAHDDN37SQSJB6DSRKALRANCNFSM4T7JGMKQ .

mea2712 avatar Dec 01 '20 09:12 mea2712

Hi Maria,

Could you explain me how is svg not working? I use it frequently with karyoploteR and works for me. Does it give you an error message? does it produce a broken image? what code are you using?

Bernat

bernatgel avatar Dec 01 '20 10:12 bernatgel

Hi Bernatgel/Karyoploter You're right. It's working now. It produced an empty plot. It was a broken call to svg inside my plot function. I'm sorry I bothered you about this

Maria. Arceo DVM, MSc +46 073 786 0483

On Tue, Dec 1, 2020 at 11:30 AM Bernat Gel [email protected] wrote:

Hi Maria,

Could you explain me how is svg not working? I use it frequently with karyoploteR and works for me. Does it give you an error message? does it produce a broken image? what code are you using?

Bernat

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bernatgel/karyoploteR/issues/93#issuecomment-736385650, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM2LO2H662D4H7J7UZZXBM3SSTAT3ANCNFSM4T7JGMKQ .

mea2712 avatar Dec 01 '20 10:12 mea2712

No problem at all :)

Glad it worked!

On Tue, Dec 1, 2020 at 11:35 AM mea2712 [email protected] wrote:

Hi Bernatgel/Karyoploter You're right. It's working now. It produced an empty plot. It was a broken call to svg inside my plot function. I'm sorry I bothered you about this

Maria. Arceo DVM, MSc +46 073 786 0483

On Tue, Dec 1, 2020 at 11:30 AM Bernat Gel [email protected] wrote:

Hi Maria,

Could you explain me how is svg not working? I use it frequently with karyoploteR and works for me. Does it give you an error message? does it produce a broken image? what code are you using?

Bernat

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/bernatgel/karyoploteR/issues/93#issuecomment-736385650 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AM2LO2H662D4H7J7UZZXBM3SSTAT3ANCNFSM4T7JGMKQ

.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/bernatgel/karyoploteR/issues/93#issuecomment-736388583, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAPQNQRFXOLFTGIXACVFLSSTBINANCNFSM4T7JGMKQ .

bernatgel avatar Dec 01 '20 10:12 bernatgel