Giter VIP home page Giter VIP logo

Comments (5)

samuel-marsh avatar samuel-marsh commented on June 15, 2024

Hi Niko,

Can you provide example of the issue you are describing?

Best,
Sam

from sccustomize.

nikofleischer avatar nikofleischer commented on June 15, 2024

Hey Sam,
sorry I didn't attach one as I saw you were commenting on the same issue over at the Seurat GitHub explaining that their Function doesn't support this. Here you go with the mwe and resulting plots:

library(Seurat)
library(scCustomize)
library(tidyverse)
data("pbmc_small")
pbmc_small %>% VlnPlot_scCustom(features = rownames(pbmc_small)[1:10])
pbmc_small %>% Stacked_VlnPlot(features = rownames(pbmc_small)[1:10])

ce973b93-e523-4b86-96d7-e7666046c00a
c4aa0213-2343-4522-ac56-e024e269202b

from sccustomize.

samuel-marsh avatar samuel-marsh commented on June 15, 2024

Oh sorry do you just want the legend to appear on the plot?

from sccustomize.

nikofleischer avatar nikofleischer commented on June 15, 2024

Hey,
sorry I messed the example up and forgot the split.by = 'groups' option.
What I actually meant was:

library(Seurat)
library(scCustomize)
library(tidyverse)
library(patchwork)

data("pbmc_small")
p = list()
p[[1]] = pbmc_small %>% VlnPlot_scCustom(features = rownames(pbmc_small)[1:4],split.by = 'groups') + theme(legend.position = 'bottom')
p[[2]] = pbmc_small %>% VlnPlot_scCustom(features = rownames(pbmc_small)[1:4],split.by = 'groups') & theme(legend.position = 'bottom') 
p[[3]] = pbmc_small %>% Stacked_VlnPlot(features = rownames(pbmc_small)[1:4],split.by = 'groups') + theme(legend.position = 'bottom')
p[[4]] = pbmc_small %>% Stacked_VlnPlot(features = rownames(pbmc_small)[1:4],split.by = 'groups') & theme(legend.position = 'bottom')

wrap_plots(p)

Here we can see that & works to add the legend in both cases, but + only works for VlnPlot and not for Stacked.

Originally I thought it also doesn't work with VlnPlot_scCustom, but this was a problem with patchwork and parentheses as I've just realized. Sorry for that.

6db53be2-f45b-4bf6-94b4-266b30010ea2

from sccustomize.

samuel-marsh avatar samuel-marsh commented on June 15, 2024

Hi,

So fix for this is now live in the develop branch v0.7.09926. I chose to solve the issue by adding extra parameter to the function. You can now use plot_legend = TRUE in order to display a single legend so stacked vlnplots.

This parameter is still compatible with ggplot/patchwork theming in order to move/edit legend.

If you run into any issues getting this work please let me know and I'll reopen the issue.

Best,
Sam

library(tidyverse)
library(Seurat)
library(scCustomize)

pbmc <- pbmc3k.SeuratData::pbmc3k.final
pbmc <- UpdateSeuratObject(pbmc)

Stacked_VlnPlot(pbmc, c("FOS", "CD3E"), plot_legend = TRUE)

Stacked_VlnPlot(pbmc, c("FOS", "CD3E"), plot_legend = TRUE) & theme(legend.position = "bottom")

image

image

from sccustomize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.