scater::plotHeatmap with swap_rownames gives error
1
0
Entering edit mode
enricoferrero ▴ 660
@enricoferrero-6037
Last seen 3.0 years ago
Switzerland

Hello,

When I try to use the swap_rownames argument in scater::plotHeatmap() I get an error.

Here is a minimal example:

library(scuttle)
library(scater)

example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)

# add mock rowData columns
rowData(example_sce) <- DataFrame(id = rownames(example_sce), gene_name = paste0("ABC", sample(1000)))
rowData(example_sce)
DataFrame with 2000 rows and 2 columns
                   id   gene_name
          <character> <character>
Gene_0001   Gene_0001      ABC916
Gene_0002   Gene_0002      ABC794
Gene_0003   Gene_0003      ABC466
Gene_0004   Gene_0004      ABC989
Gene_0005   Gene_0005      ABC827
...               ...         ...
Gene_1996   Gene_1996      ABC934
Gene_1997   Gene_1997      ABC120
Gene_1998   Gene_1998      ABC197
Gene_1999   Gene_1999       ABC26
Gene_2000   Gene_2000      ABC921

# this works
plotHeatmap(example_sce, features=rownames(example_sce)[1:10])

# this doesn't
plotHeatmap(example_sce, features=rownames(example_sce)[1:10], swap_rownames = "gene_name")
Error in assay(object, exprs_values)[feats, , drop = FALSE] : 
  subscript out of bounds

Actually, the real error I'm getting with my data is:

Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
  invalid character indexing

But I can't quite reproduce it with a minimal example, and hopefully understanding/fixing the error in the minimal example will help me fix the error in the real data.

Thank you!

scater • 1.5k views
ADD COMMENT
0
Entering edit mode

Tagging Alan and Aaron for visibility: alan.ocallaghan Aaron Lun

ADD REPLY
2
Entering edit mode
@guillaume-devailly-8722
Last seen 3 months ago
Toulouse, France

Thanks for the minimal example! features should match the new swap_rownames. I.e. if you swap rownames, the features you're asking should be in gene_name, and no longer in id.

This should work:

plotHeatmap(example_sce, features=rowData(example_sce)$gene_name[1:10], swap_rownames = "gene_name")
ADD COMMENT
0
Entering edit mode

Thanks Guillame! That indeed works, and I see the logic behind it.

ADD REPLY

Login before adding your answer.

Traffic: 679 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6