Seurat: DoHeatmap not working after SCTransform

Created on 9 Dec 2019  路  9Comments  路  Source: satijalab/seurat

I'm having issues using DoHeatmap in Seurat and get the error below

Error in data.frame(group = sort(x = group.use), x = x.divs) : arguments imply differing number of rows: 4286, 0

I can use dotplot just fine and make umaps, ridgeplots ect all just fine but the heatmap function has stopped working and I've tried uninstalling and reinstalling devtools and Seurat but it hasn't resolved the issue. Below is the full code showing how I built the object. I've downsampled here just to make it run faster but I get the same error if I downsample or don't downsample.

sample.list<- list(sample15_1, sample15_2,sample24_1, sample24_2, sample27_1, sample27_2, sample29_1, sample29_2, sample33_1, sample33_2,sample45_1, sample45_2,sample46_1, sample46_2,sample48_1, sample48_2)

sample.list <- lapply(X = sample.list, FUN = function(x) {
  x <- SCTransform(x)
})

sample.features <- SelectIntegrationFeatures(object.list = sample.list, nfeatures = 3000)
sample.list <- PrepSCTIntegration(object.list = sample.list, anchor.features = sample.features)

sample.list <- lapply(X = sample.list, FUN = RunPCA, verbose= FALSE, features= sample.features)

sample.anchors <- FindIntegrationAnchors(object.list = sample.list, anchor.features = sample.features, normalization.method = "SCT", reduction = "rpca")

sample.integrated <- IntegrateData(anchorset = sample.anchors, normalization.method = "SCT", verbose = TRUE)

DefaultAssay(immunecombined)<- "SCT"

immunecombined <- ScaleData(immunecombined)

immunecombined <- FindVariableFeatures(object = immunecombined, selection.method= "mvp")

immunecombined <- RunPCA(immunecombined, verbose = FALSE, npcs=50)

immunecombined <- RunUMAP(immunecombined, dims = 1:20, verbose = TRUE)

immunecombined <- FindNeighbors(immunecombined, dims = 1:20, verbose = TRUE)

immunecombined <- FindClusters(immunecombined, verbose = TRUE, resolution = 0.2)

DimPlot(immunecombined, reduction = "umap")

immuneombined.small <- subset(immunecombined, downsample = 500)

DoHeatmap(immuneombined.small , assay = "SCT", angle = 90) + NoLegend()

Most helpful comment

I also got this problem. I was checked visualization.R file, and found the error in line 363, this script is used to get the labels. So I add the parameter label = F in DoHeatmap. Then, it worked !!!

DoHeatmap(a_m_combined, features = top3$gene, label = F)

I don't know why this error happens, I processed another 10X dataset use the same pipeline, everything is fine.

All 9 comments

Hi,

same problem here (but without SCTransform):

prepared Seurat object with "standard" conditions (online tutorial).

DoHeatmap(pbmc,features="Gapdh")
Error in data.frame(group = sort(x = group.use), x = x.divs) :
arguments imply differing number of rows: 2812, 0
traceback()
3: stop(gettextf("arguments imply differing number of rows: %s",
paste(unique(nrows), collapse = ", ")), domain = NA)
2: data.frame(group = sort(x = group.use), x = x.divs)
1: DoHeatmap(pbmc, features = "Gapdh")

Error appears in linux VM, but not under local R-Studio with same Seurat versions (3.1.2).

Version VM:

platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 6.1
year 2019
month 07
day 05
svn rev 76782
language R
version.string R version 3.6.1 (2019-07-05)

Version local:

platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.2
year 2018
month 12
day 20
svn rev 75870
language R
version.string R version 3.5.2 (2018-12-20)

I still haven't found a solution yet sorry I couldn't help

Hi,
Same happen to me.
You need to make sure that the assay you are using exist and correct.
For me the problem was a mismatch between the active.ident that I used and the levels that I set for it.
I think that maybe the problem is when you created the subset, have you tried to DoHeatmap on the original object?
Try running Idents(object) and see if things make sense or not. This is how I fount my mistake.

You need to specify

1) What features you are using
2) The assay you are using (SCT or RNA)
3) Make sure that the features you wish to plot exist in the scale.data slot. If not, you can use ScaleData (for the RNA workflow) or GetResidual (for the SCT workflow) to add them in

DoHeatmap(pbmc, features = top10$gene) + NoLegend()
Error in data.frame(group = sort(x = group.use), x = x.divs) :
arguments imply differing number of rows: 2638, 0

I used the pbmc3k tutorial data been described in: https://satijalab.org/seurat/v3.1/pbmc3k_tutorial.html

The Rstudio Server 1.2.1335 is running with R 3.6 on a Debian/Linux 9. All other steps work flawlessly.

I also got this problem. I was checked visualization.R file, and found the error in line 363, this script is used to get the labels. So I add the parameter label = F in DoHeatmap. Then, it worked !!!

DoHeatmap(a_m_combined, features = top3$gene, label = F)

I don't know why this error happens, I processed another 10X dataset use the same pipeline, everything is fine.

I have the same issue and I believe it has to do with updates I did to some packages. I ran my code just fine 30 mins ago, then installed some new packages, and when I tried rerunning the same code in a new session, I got the same error as above.

Removing the labels works for me as well, so it must be at that step the error occurs.

Thanks a lot lzmcboy and asabjorklund. Turn off the label seems to work. It must be associate with package version ( work previously just having trouble recently, since there are so many packages were used in this Suite, very hard to pin point which package trigger the error). Wish there is a docker image with latest version of Seurat with all the dependency working properly (most of them in docker hub seems more than 1 year old)

@xmzhuo A docker image that is updated regularly is here: https://hub.docker.com/r/satijalab/seurat

Was this page helpful?
0 / 5 - 0 ratings