Comments (10)
That code that you provide doesn't actually return NULL
. I returns a list of ggplot
objects, that contains 1 object.
This does
library(mia)
library(miaViz)
data(GlobalPatterns)
tse <- GlobalPatterns
tse <- relAbundanceCounts(tse)
p <- plotAbundance(tse,
abund_values="relabundance",
rank = "Phylum",
order_sample_by = "SampleType")
p <- p + scale_y_continuous(label = scales::percent)
print(p)
I think the bug lies on order_sample_by
and features
, and the function works similarly with relabundance
and counts
It is documented there that features
is added when order_sample_by
is specified. It is also documented that when features
is added, a list of ggplot
objects are returned. So, the function is working as expected in that manner: a list is returned.
However, what is does not do when order_sample_by
is specified is that it does not return "feature data" ggplot object
with the primary ggplot
; it return only one object in a list.
When features
is specified without order_sample_by
, it returns primary ggplot
object and feature data ggplot
.
Without further analysis, it would work if
if(length(list) == 1){
return(list[1]) }
However, I think it should be checked if those functionalities are working as expected in all sense
from miaviz.
Yes, this is a tricky one.
It is a realistic use case that one is simply willing to use order_sample_by
with a single variable, without features
list and the question originated from a new user.
I tend to suggest that the default behavior would be to return just the first list element in our example case above, and only return a list if this is explicitly required.
If this turns out to be a problematic choice in practice, we could return to evaluate the pros and cons of both solutions.
Alternatively, we could provide a function argument or examples to circumvent this explicitly, and add clear examples on this use case. This would seem unnecessarily complicated for this expected simplest use case.
What would @FelixErnst say?
from miaviz.
Also maybe include an example using patchwork
to plot a list of ggplot
objects (I think its wrap_plots
).
Then we can just say rtfm
the next time 😄
from miaviz.
This does work
p$abundance + scale_y_continuous(label = scales::percent)
The function returns a list when features are added, and a list cannot be scaled --> NULL
#' @return
#' a \code{\link[ggplot2:ggplot]{ggplot}} object or list of
#' \code{\link[ggplot2:ggplot]{ggplot}} objects, if `features` are added to
#' the plot.
from miaviz.
I checked that too quickly, because it shouldn't return a list
from miaviz.
The ggplot object should behave in the same, expected way for counts and relabundances.
from miaviz.
I think the combination of both your approaches should work.
I tend to suggest that the default behavior would be to return just the first list element in our example case above, and only return a list if this is explicitly required.
if(length(list) == 1){ return(list[1]) }
The conditional clause above should be as specific as possible and the documentation needs to be clarified accordingly as @tvborm has already described.
from miaviz.
I embrace these thoughts entirely.
from miaviz.
Currently, this returns 1 plot
p <- plotAbundance(tse,
abund_values="relabundance")
This returns 1 plot
a <- plotAbundance(tse,
abund_values="relabundance",
order_sample_by = "shannon")
This returns 2 plots
p <- plotAbundance(tse,
abund_values="relabundance",
features = "SampleType")
This returns 3 plots
p <- plotAbundance(tse,
abund_values="relabundance",
features = "SampleType",
rank = "Phylum",
order_sample_by = "shannon")
The main plot is always called abundance
.
In this 3 plot case, plots called abundance
, SampleType
and shannon
are returned.
In the documentation it says
#' @param order_sample_by A single character value from the chosen rank of abundance
#' data or from \code{colData} to select values to order the abundance
#' plot by. If the value is not part of \code{features}, it will be added.
#' (default: \code{order_sample_by = NULL})
Especially: If the value is not part of \code{features}, it will be added
However, should that be the case? Should order_sample_by
be used only in ordering? Currently it returns also an extra plot in addition to ordering, but only when also features
is specified.
If only abundance
and features
plots should be returned, it is easy to fix with plot_out[["abundance"]]
and plot_out[[features]]
.
from miaviz.
I do not see a clear need and support the suggested change
from miaviz.
Related Issues (20)
- plotAbundance problem HOT 2
- Boxplots significance HOT 3
- plotAbundanceDensity colors
- Plot by group HOT 1
- plotAbundanceDensity not working when counts assay is missing HOT 2
- Replace abund_values with assay_name
- print x-axis label in plotAbundance HOT 2
- Update the pkg in Bioc devel HOT 1
- Check fails HOT 2
- Ordination plots with trajectories: add examples HOT 3
- Enable examples and tests
- Update Bioc devel HOT 1
- argument names
- Default ranks HOT 3
- RDA influences from microViz
- plotAbundanceDensity options
- plotRDA, plot loadings HOT 1
- plotRowTree error
- sysreqs error
- Strange example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miaviz.