Entering edit mode
17 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)
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.