lmrodriguezr / nonpareil

Estimate metagenomic coverage and sequence diversity
http://enve-omics.ce.gatech.edu/nonpareil/
Other
42 stars 11 forks source link

nonpareil.curve.batch - double legend? #43

Closed russejenn closed 4 years ago

russejenn commented 4 years ago

Hello,

I am trying to graph 24 samples together using Nonpareil.curve.batch, and the regular command outputs a legend that goes right over top of my curves, and the box isn't see-through. When I try to move the legend using nonpareil.legend, it makes a second legend (so the graph has two). Is there a way to remove the legend from the Nonpareil.curve.batch command? Or am I doing something wrong? (note that I am currently just working with 2 samples to get it to work).

Here is my code: samples <- read.table('Nonpareil.samples.txt', sep='\t', header=TRUE) attach(samples) non <- Nonpareil.curve.batch(File, libnames=Name, skip.model=TRUE, plot=TRUE) image

Nonpareil.legend(non, 'topright') image

Thanks!

lmrodriguezr commented 4 years ago

Hello @russejenn Note that you're using a syntax that is no longer supported (kept for backwards compatibility). I'm suggesting below the easier-to-use version of the same code you have (using Nonpareil.set instead of Nonpareil.curve.batch).

There are two ways to achieve this. My preferred option is to turn off the legend first, and then plot the legend separately:

samples <- read.table('Nonpareil.samples.txt', sep = '\t', header = TRUE, as.is = TRUE)
non <- Nonpareil.set(samples$File,
  labels = samples$Name,
  plot.opts = list(plot.model = FALSE, legend.opts = FALSE))
Nonpareil.legend(non, 'topright')

However, you can also achieve that with a single command:

samples <- read.table('Nonpareil.samples.txt', sep = '\t', header = TRUE, as.is = TRUE)
non <- Nonpareil.set(samples$File,
  labels = samples$Name,
  plot.opts = list(plot.model = FALSE, legend.opts = list(x = 'topright')))
lmrodriguezr commented 4 years ago

Please feel to reopen if this doesn't work for you

ReneKat commented 2 years ago

Hello! First, a big THANK YOU for making nonpareil and its documentation. This is just a comment on manipulating legends. I had a similar issue to others that have posted regarding legends. I wanted to share what worked for me. As was already mentioned, any argument in legend() can be applied to legend.opts . I found cex = XX to be an easy fix to shrink or enlarge a legend. For example, Nonpareil.set(File, col=Color, labels=Name, plot.opts = list(legend.opts = list(cex = 0.6))) shrank my legend so all of it could be visible. Hope this helps someone! Take Care, Rene