How to use the plotExprHeatmap function to draw heat maps according to groups
0
0
Entering edit mode
@582b8f2e
Last seen 12 months ago
China

Hi, I want to use the plotExprHeatmap function to draw heat maps according to groups,as shown in the figure,

but I can't achieve it.

enter image description here

plotExprHeatmap(sce, features = "type", 
                by = "cluster_id", k = "meta30", 
                row_clust = F,
                bars = TRUE, perc = TRUE)

This method can only draw heat maps of all groups.

I try to extract sce with subset, but it will reduce the number of antibodies, which is obviously unscientific

sce1 <- subset(sce,levels(sce@colData$group)=="WT")

In addition, I have tried the following methods:

colData1 <- sce@colData[which(sce@colData$group=="WT"),]
colData<- sce@colData
sce1 <- sce
sce1@colData <- colData1

sce1@assays@data$counts <-sce1@assays@data$counts[,164769] 
sce1@assays@data$exprs <-sce1@assays@data$exprs[,164769] 

But an error occurred:

> plotExprHeatmap(sce1, features = "type", 
+                 by = "cluster_id", k = "meta30", 
+                 row_clust = F,
+                 bars = TRUE, perc = TRUE)
Error in validObject(result) : 
  invalid class “SingleCellExperiment” object: 
    'x@assays' is not parallel to 'x'

Is there any way to achieve my goal? Thank you!

grou heatmaps CyTOFpower cytofWorkflow • 878 views
ADD COMMENT
0
Entering edit mode

Generally, I'd highly recommend against @ for anything, but instead using the designated SingleCellExperiment accessor and replacement methods.

Also, you want to filter the SCE, not the cell metadata (colData). The class is designed to keep everything in synch (i.e., assays, feature- and observation-metadata). So by subsetting the object, there is no need to also adjust other slots manually.

Finally, note that CATALYST has a function specifically for filtering (while this can be done using basic commands, it also assures that internal metadata and factor levels etc. are corrected under the hood)...

This should do the trick:

sub <- filterSCE(sce, group == "WT")
# which is equivalent to...
# sub <- sce[, sce$group == "WT"]
# ...but with some internal extras
plotExprHeatmap(sub, ...)
ADD REPLY
0
Entering edit mode

Wow, that's great! Thank you!

ADD REPLY

Login before adding your answer.

Traffic: 516 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