Closed fly4all closed 5 years ago
Hi Maria,
This is happening because CombinePlots
using cowplot::plot_grid
which disables modifying individual plot components. CombinePlots
is automatically called when plotting multiple features to keep everything together nicely.
To get around this, pass combine = FALSE
to FeaturePlot
, modify your plots in a for-loop or with lapply
, then call CombinePlots
to stitch everything together for you.
baseplot <- FeaturePlot(object = decoder, features = features, reduction = 'tsne', pt.size = 0.1, combine = FALSE)
for (i in 1:length(x = baseplot) {
baseplot[[i]] <- baseplot[[i]] + DarkTheme()
}
# Can also use lapply
baseplot <- lapply(
X = baseplot,
FUN = function(p) {
return(p + DarkTheme())
}
)
CombinePlots(plots = baseplot, ncol = 2)
Hi Paul,
Thank you for the quick response. I tried both the methods but it gives me an error.
Upon doing it with for loop:
Error in baseplot[[i]] + DarkTheme() :
non-numeric argument to binary operator
In addition: Warning message:
In baseplot[[i]] + DarkTheme() :
Incompatible methods ("Ops.data.frame", "+.gg") for "+
Upon running the lapply method (I have always run into an error trying to run combinePlots, I'm not sure why):
> baseplot <- lapply(
+ X = baseplot,
+ FUN = function(p) {
+ return(p + DarkTheme())
+ }
+ )
Error in p + DarkTheme() : non-numeric argument to binary operator
In addition: Warning message:
In FUN(X[[i]], ...) :
Incompatible methods ("Ops.data.frame", "+.gg") for "+"
> CombinePlots(plots = baseplot, ncol = 2)
Error in plot_to_gtable(x) :
Argument needs to be of class "ggplot", "gtable", "grob", "recordedplot", or a function that plots to an R graphicsdevice when called, but is a data.frame
Hi Maria,
You need to rerun FeaturePlot
and pass combine = FALSE
like I said above.
Oh, sorry I missed on that. It works now, thank you!
The only problem remaining is that the cluster labels are still black
@ondina-draia just submitted PR #5314 to add this parameter to FeaturePlot
(already possible in DimPlot
).
Best, Sam
@samuel-marsh This is wonderful, thank you 😊
I tried applying dark theme onto my tSNE feature plot but it seems that font might still be black in color and so, I'm unable to see it with the dark background. Is there any fix for this?
Code:
baseplot <- FeaturePlot(object=decoder, features= features, reduction='tsne', pt.size=0.1)
baseplot + DarkTheme()