YuLab-SMU / ggmsa

:traffic_light: Visualizing publication-quality multiple sequence alignment using ggplot2
http://yulab-smu.top/ggmsa
198 stars 22 forks source link

Plotting alignment in wide format #56

Open vhfsantos opened 1 year ago

vhfsantos commented 1 year ago

Hi, Thank you so much for this amazing package!

I was wondering if there is a way of making the alignment plot wider (i.e., bigger in width, than in height). I am working with a matrix of 200 sequences, with 70nt each. I plotted the alignment with:

ggmsa(seq, seq_name = F,
            char_width = 0.5,
            font = NULL, border = NA, color = "Chemistry_NT") +
            geom_seqlogo(color = "Chemistry_NT")

Which resulted in the following alignment:

original

However, I would like to generate a wider visualization, like this (edited with an image editing tool):

wider

I tried to address this by changing the size parameters of a downstream ggsave() call, but it doesn't affect the width/height of the alignment matrix itself, only the size of the device (e.g., the output png image). Do you know how can I generate this straight from ggmsa(), without needing external image editing tools?

You can find the fasta file here, in case you want it.

Best, Vinícius

jayoung commented 8 months ago

I was wondering the same thing, and I think I figured it out. Adding a facet_msa layer, although it doesn't seem necessary, it seems to mean that the plot respects the dimensions specified by ggsave:

p <- ggmsa(seq, seq_name = F,
           char_width = 0.5,
           font = NULL, border = NA, color = "Chemistry_NT") +
    facet_msa(field=80) +
    geom_seqlogo(color = "Chemistry_NT")
ggsave(filename = "ggmsa_testPlot.pdf", p, height=3, width=11)

I don't understand why, but I like that it works!