3
$\begingroup$

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: enter image description here

but I want: enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

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')

enter image description here

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')

enter image description here

$\endgroup$
7
  • $\begingroup$ 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 $\endgroup$
    – Charles
    Commented Jan 18, 2019 at 14:26
  • 1
    $\begingroup$ Yes, that function is part of Seurat v3. This answer will only work for v3 $\endgroup$
    – TimStuart
    Commented Jan 18, 2019 at 14:37
  • $\begingroup$ 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 $\endgroup$
    – Charles
    Commented Jan 18, 2019 at 15:34
  • $\begingroup$ 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? $\endgroup$
    – Charles
    Commented Jan 18, 2019 at 15:36
  • 1
    $\begingroup$ Can you confirm Seurat v3 has actually been installed and loaded before running UpdateSeuratObject? $\endgroup$
    – TimStuart
    Commented Jan 21, 2019 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.