How can I prevent a function from sorting my data groups (factors) in alphabetical order without affecting the integrity of the data? I am analysing single cell RNA sequencing data using Seurat 2.3.4. I want to be able to visualise the expression of two genes, Gene1 and Gene2 across cell clusters using the
FeatureHeatmap() function from Seurat. I have assigned to the metadata slot of my Seurat object the factors or conditions being tested in the experiment. However on the resulting FeatureHeatmap plot, the data are sorted and grouped in alphabetical order to my disfavour. I have attempted a solution given on stackoverflow such as the one below:
conditions <- c(rep("WTNaClctrl", 1229), rep("WTBlu", 1328), rep("ILKOBlu", 349)) conditions <- as.data.frame(conditions) email@example.com$conditions <- factor(conditions$conditions, levels=unique(conditions$conditions))
When I use the
FeatureHeatmap() function, the plot still sorts the data groups in alphabetical order:
FeatureHeatmap(seurat_object, features.plot = c("Gene1", "Gene2"), pt.size = 0.25, group.by = "conditions", max.exp = 3)
As previously suggested StackExchange, I have tried to upgrade my Seurat object to Seurat V3:
UpdateSeuratObject(Seurat_object): Object representation is consistent with the most current Seurat version. devtools::install_github(repo = 'satijalab/seurat', ref = 'release/3.0') : package ‘curl’ successfully unpacked and MD5 sums checked: Error: (converted from warning) cannot remove prior installation of package ‘curl’.
Thank you in advance for any suggestions.