# How to set the position of groups in a Seurat object on a FeatureHeatmap plot

I am analysing singe cell sequence data and I have followed this tutorial, https://satijalab.org/seurat/pbmc3k_tutorial.html to perform QC and various differential analyses using the Seurat package on my data up till now.

How can I rearrange on the resulting plot, the order in which the groups of my samples appear when I use the FeatureHeatmap() function to visualise the differential gene expression of Gene1 and Gene2 across the cell clusters?

FeatureHeatmap(object = object, features.plot = c("Gene1", "Gene2"),
group.by = "Conditions",
pt.size = 0.25, key.position = "top",
max.exp = 3)


produces:

but I want:

## 1 Answer

I don't think this is possible in Seurat v2, but in v3 you can change the factor levels of the grouping variable to change the plot order:

library(Seurat)

FeaturePlot(object = pbmc_small,
features = head(VariableFeatures(pbmc_small), 2),
split.by = 'groups')


Change the order:

pbmc_small$$groups <- factor(pbmc_small$$groups, levels = c('g2', 'g1'))

FeaturePlot(object = pbmc_small,
features = head(VariableFeatures(pbmc_small), 2),
split.by = 'groups')


• Thanks a lot. However the function VariableFeatures is not present in my Seurat package. I get the error: Error in VariableFeatures(object) : could not find function "VariableFeatures" @TimStuart Jan 18 '19 at 14:26
• Yes, that function is part of Seurat v3. This answer will only work for v3 Jan 18 '19 at 14:37
• How do I get the Seurat V3 package? My computer is having issue downloading it automaticaally, so I wish to download the Seurat V3 package manually and then load it. Thanks. @TimStuart Jan 18 '19 at 15:34
• Will it also be advisable that I move to Seurat V3 at this level or I may need to restart my analyses afresh and repeat all steps with Seurat V3? Jan 18 '19 at 15:36
• Can you confirm Seurat v3 has actually been installed and loaded before running UpdateSeuratObject? Jan 21 '19 at 14:33