Skip to content

FeatureAssayPlot: horizontal layout + alternate background shading #548

Open

Description

@lgeistlinger

I am writing to say that iSEE is just great. I mean really, just great. Great work.

Now one question, is there an easy way to coord_flip my feature assay plot, ie have tissue on the y-axis and the gene expression on the x-axis ( = a horizontal instead of a vertical layout)?

image

I was already about to follow the vignette for customization of panels and/or writing an own panel class, but wanted to check in whether there is not something that I am missing.

My understanding is that FeatureAssayPlot makes use of .violin_plot internally - which has a horizontal argument:

by_row=FALSE, is_subsetted=FALSE, is_downsampled=FALSE, horizontal=FALSE)

But I am struggling to find the place in the code where FeatureAssayPlot actually calls .violin_plot - which would be my entry point to potential customization ...

On a related note:

I am also wondering whether there is an easy way to add alternate background shading by column data to my Feature Assay Plot as shown in this example:

image

And I guess the general theme arising from these questions is: what's a developer's approach to change certain appearance features / plot layout aspects of a certain panel type beyond the options provided in the UI. Will that always be writing a new Panel class or could a helper such as .refineParameters be used for this purpose?

Activity

  1. LTLA commented on Mar 18, 2021

    @LTLA
    Member

    Now one question, is there an easy way to coord_flip my feature assay plot, ie have tissue on the y-axis and the gene expression on the x-axis ( = a horizontal instead of a vertical layout)?

    Not right now, but it's something that could be fairly easily added.

    But I am struggling to find the place in the code where FeatureAssayPlot actually calls .violin_plot - which would be my entry point to potential customization ...

    It's a long rabbit hole through S4. The plotting expression is inherited from DotPlot:

    iSEE/R/family_DotPlot.R

    Lines 1234 to 1239 in 79d232e

    plot_cmds <- switch(plot_type,
    square=do.call(.square_plot, args),
    violin=do.call(.violin_plot, args),
    violin_horizontal=do.call(.violin_plot, c(args, list(horizontal=TRUE))),
    scatter=do.call(.scatter_plot, args)
    )

    what's a developer's approach to change certain appearance features / plot layout aspects of a certain panel type beyond the options provided in the UI. Will that always be writing a new Panel class or could a helper such as .refineParameters be used for this purpose?

    A new panel class is pretty much always the answer, as there's no way to affect the behavior of the iSEE() function at the level you desire without writing S4 methods. In this particular case, it is kind-of straightforward:

    1. Create a class that inherits from FeatureAssayPlot.
    2. Write a new method for .defineDataInterface that creates a UI element to choose the column variable to use for splitting. This should be as easy as doing callNextMethod() and then adding the desired selectInput() to the resulting list.
    3. Write a new method for .generateDotPlotData that extracts the desired colData variable and appends it to the data.frame. Again, this should be as easy as doing callNextMethod() and just adding another appropriately named column.
    4. Write a new method for .generateDotPlot that actually does the splitting. If you're able to get the desired result by applying more ggplot2 stuff on the object that's already produced by the FeatureAssayPlot, then again, this could be as simple as doing callNextMethod() and just modifying the output to add more ggplot2 layers.

    If you can't do your customization by just adding more ggplot2 layers, then 4 is the most difficult step if you want to be a "good citizen", as your panel would be expected to respond to the 20 other parameters that the user might be fiddling with (e.g., faceting, color by, size by, shape by, blah blah blah). The current panels already respond to those settings, so if you can callNextMethod(), you get that for free, but if not then you'll have to do it yourself. You could of course just ignore parameters you don't care about but that would be pretty confusing to users who would expect the widgets to do something.

  2. lgeistlinger commented on Mar 18, 2021

    @lgeistlinger
    Author

    Thanks a lot for taking the time to walk me through that. I'll try that out.

  3. kevinrue commented on Sep 2, 2024

    @kevinrue
    Member

    Still interested? If it's popular, we could spend the time to develop a "horizontal feature assay plot" panel for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions