How to extract list of top 10 markers from each cluster?
0
0
Entering edit mode
10 months ago
Bioinfo ▴ 30

I have a list (markers.l) of dataframes. Each dataframe denotes to one cluster. I try the following function to get the list of top 10 markers.

# Extract top 10 markers per cluster
top10 <- markers.l %>% 
  mutate(avg_fc = (Sample1_avg_log2FC + Sample2_avg_log2FC) /2) %>% 
  group_by(cluster_id) %>% 
  top_n(n = 10, 
        wt = avg_2fc)

# Visualize top 10 markers per cluster
View(top10)

Error in UseMethod("mutate"): no applicable method for 'mutate' applied to an object of class "list"
Traceback:

1. markers.l %>% mutate(avg_fc = (Sample1_avg_logFC + Sample2_avg_logFC)/2) %>% 
 .     group_by(cluster_id) %>% top_n(n = 10, wt = avg_fc)
2. top_n(., n = 10, wt = avg_fc)
3. filter(x, top_n_rank({
 .     {
 .         n
 .     }
 . }, !!wt))
4. group_by(., cluster_id)
5. mutate(., avg_fc = (Sample1_avg_logFC + Sample2_avg_logFC)/2)
R Seurat single-cell cluster • 576 views
ADD COMMENT
0
Entering edit mode

You're trying to run the code on the list of dataframes, not on each dataframe. You should have a loop iterating over the dataframes, then do the mutate etc. on each one.

ADD REPLY

Login before adding your answer.

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