satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.29k stars 914 forks source link

Issue with displaying Seurat plots in R shiny #401

Closed bapoorva closed 6 years ago

bapoorva commented 6 years ago

Hi,

I'm creating a Shiny website for easy visualization of single set data analyzed using seurat pipeline. I am, however, having trouble displaying the plots. I dug a little deeper and it so happens that Vlnplot and Featureplot return a list despite giving do.return ==T. With feature plot, you can subselect like this

p1 <- FeaturePlot(object = scrna, features.plot = "nUMI", cols.use = c("grey", "blue"),reduction.use = "tsne",do.return=T)
plot <- p1$nUMI

where plot is now a ggplot object which can be used within shiny renderPlot. How can I do the same for a violin plot or say a Featureplot with 2 genes overlaid using the overlay=TRUE option ?

Thanks

mojaveazure commented 6 years ago

When overlay = TRUE, the individual plots in the plot list returned from FeaturePlot aren't named. However, you can still access them using the standard list [[ subset operator.

plot.list <- FeaturePlot(object = scrna, features.plot = c('nUMI', feature2), do.return = TRUE, ...) # Fill in 'feature2' and '...' with your own second feature and other arguments, respectively
plot <- plot.list[[1]] # Use the standard list `[[` subset operator to get the plot, this has the advantage of being portable and non-reliant on plot names
bapoorva commented 6 years ago

Perfect. That worked. Thank you