Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot: legend=FALSE gives error #30

Open
rdiaz02 opened this issue Jan 3, 2025 · 0 comments
Open

plot: legend=FALSE gives error #30

rdiaz02 opened this issue Jan 3, 2025 · 0 comments

Comments

@rdiaz02
Copy link
Owner

rdiaz02 commented Jan 3, 2025

MRE:

library(OncoSimulR)

## From vignette
set.seed(1)
r7b <- rfitness(7, scale = c(1.2, 0, 1))

## Large pop sizes: clonal interference
(sr7b <- oncoSimulIndiv(allFitnessEffects(genotFitness = r7b),
                        model = "McFL",
                        mu = 1e-6,
                        onlyCancer = FALSE,
                        finalTime = 400,
                        initSize = 1e7,
                        keepEvery = 4,
                        detectionSize = 1e10))

plot(sr7b, show = "genotypes")

plot(sr7b, show = "genotypes", legend = FALSE)
## Error in rep(0L, n.legpercol * ncol - n) : invalid 'times' argument

The error occurs in the call to legend. plot.oncosimul does not use legend for anything, but passes it to other functions (via "...").

There are actually two issues:

  1. The error
  2. That we cannot prevent the legend from being shown. Arguably, this is a feature, not a bug? I mean, what use is the plot if one cannot tell what the things being plotted are?

But then, we should allow users to modify, for example, the font size so as to minimize overlap with plot stuff. The workaround for now is to play with legend.ncols and the y and maybe x axis range (this is also used in the vignette (https://rdiaz02.github.io/OncoSimul/OncoSimulR.html#655_Simulation_with_order_effects_and_McFL_model)

## Workaround
plot(sr7b, show = "genotypes", legend.ncols = 4, ylim = c(0, 2e7))

That workaround really works if we ask for type = "line". Just need to be aware of the scale of the y axis!

plot(sr7b, show = "genotypes",
     legend.ncols = 5, 
     type = "line",
     ylim = c(1, 1e12))

(Issue originally reported by Deyanira Borroto Alburquerque, from PRSTR class 2024-25).

@rdiaz02 rdiaz02 changed the title plot: legend=FALSE gives error plot: legend=FALSE gives error and ylim does nothing with type = "line" Jan 3, 2025
@rdiaz02 rdiaz02 changed the title plot: legend=FALSE gives error and ylim does nothing with type = "line" plot: legend=FALSE gives error Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant