-1
$\begingroup$

I used FindMarkers to find the DEGs between two clusters in my dataset using Seurat. I am trying to visualize the outcome using a heatmap but I failed to write the command in R.

dput(cluster4_3.markers)
              p_val  avg_logFC pct.1 pct.2    p_val_adj
Vim    1.803527e-44 -1.1689785 0.996 0.999 3.458985e-40
Lgals7 1.479278e-38  1.7615232 0.993 0.552 2.837108e-34
Anxa2  1.797016e-37 -1.3971764 0.629 0.991 3.446497e-33
Tmsb10 6.936830e-31  0.7937881 1.000 1.000 1.330415e-26
Ptma   7.518439e-27  0.5622808 1.000 1.000 1.441961e-22
Jund   2.044576e-25 -0.9881766 0.993 0.999 3.921293e-21

When I tried:

DoHeatmap(cluster4_3.markers, features = NULL) + 
scale_fill_gradientn(colors = rev(RColorBrewer::brewer.pal(n = 7, name = "RdYlBu")))
Error in UseMethod(generic = "DefaultAssay", object = object) : 
  no applicable method for 'DefaultAssay' applied to an object of class "data.frame"

It didn't work. I was trying to replicate this command:

top10 <- pbmc.markers %>% group_by(cluster) %>% top_n(n = 10, wt = avg_logFC)
DoHeatmap(pbmc, features = top10$gene) + NoLegend() + 
  scale_fill_gradientn(colors = rev(RColorBrewer::brewer.pal(n = 7, name = "RdYlBu")))

I tried to extract some info from the csv file but I couldn't determine which parameter is important (p_val avg_logFC pct.1 pct.2 p_val_adj). Also, I didn't know which parameter to use to use the group_by function. That's one of my attempts:

clus4vs3 <- cluster4_3.markers$p_val %>% 
    group_by(pct.1) %>% 
    top_n(n = 10, wt = avg_logFC)
Error in UseMethod("group_by_") :
  no applicable method for 'group_by_' applied to an object of class "c('double', 'numeric')"

Now that I understand 'group_by' only accepts a categorical variable, how can I write a command that displays the top20 differentially expressed genes between cluster 4 and 3 in a heatmap ?

$\endgroup$
2
  • $\begingroup$ Please a) include a reproducible example of your data, (i.e. by using dput(cluster4_3.markers) b) tell us what didn't work because it's not 'obvious' to us since we can't see your data. Include details of all error messages. We can't help you otherwise. $\endgroup$
    – user438383
    Nov 9 '20 at 9:57
  • $\begingroup$ @user438383 Sorry for the ambiguity. I just attached the result of dput(cluster4_3.markers). $\endgroup$
    – Dahlia
    Nov 10 '20 at 1:21
0
$\begingroup$

In your DoHeatmap() call, you do not provide features so the function does not know which genes/features to use for the heatmap.

In your last function call, you are trying to group based on a continuous variable pct.1 whereas group_by expects a categorical variable.

$\endgroup$
7
  • $\begingroup$ I understand a little bit more now. I just want to show the DEGs expressed in both clusters in 1 heatmap. But I failed (still failing) to write the command logically. $\endgroup$
    – Dahlia
    Nov 10 '20 at 1:19
  • $\begingroup$ I am having a hard time understanding "DEGs expressed in both clusters", by definition a DEG is expressed in one of the clusters, not both. You can feed rownames(cluster4_3.markers) to the features variable of DoHeatmap(). $\endgroup$
    – haci
    Nov 10 '20 at 8:19
  • $\begingroup$ What I mean is to compare the DEGs expressed between those two clusters. Does that make sense? $\endgroup$
    – Dahlia
    Nov 11 '20 at 0:36
  • $\begingroup$ ``` > DoHeatmap(cluster4_3.markers, features = rownames(cluster4_3.markers)) + + scale_fill_gradientn(colors = rev(RColorBrewer::brewer.pal(n = 7, name = "RdYlBu"))) Error in UseMethod(generic = "DefaultAssay", object = object) : no applicable method for 'DefaultAssay' applied to an object of class "data.frame" $\endgroup$
    – Dahlia
    Nov 11 '20 at 0:38
  • $\begingroup$ DoHeatmap() takes a Seurat object as a first argument. Please go through the documentation and vignettes. $\endgroup$
    – haci
    Nov 11 '20 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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