Well, of course, there is a way. You can use iterate over the genes in the data frame returned by FindMarkers and get the average expression of that gene in the idents corresponding to your two groups.
You can use the AverageExpression
function of Seurat for this purpose. This can be done for both scaled as well as raw data.
cluster1vs2.markers <- FindMarkers(seurat_obj, ident.1 = 8, ident.2 = 9, min.pct = 0.25)
cluster1vs2.markers
# calculate average expression of genes across idents
avg_exp_df_counts_scaled <- AverageExpression(seurat_obj, slot = "scale.data")
avg_exp_df_counts_raw <- AverageExpression(seurat_obj, slot = "data")
# for scaled`
cluster1vs2.markers$group_1_exp_scaled <- sapply(rownames(cluster1vs2.markers), function(x) avg_exp_df_counts_scaled$RNA[x, 8])
cluster1vs2.markers$group_2_exp_scaled <- sapply(rownames(cluster1vs2.markers), function(x) avg_exp_df_counts_scaled$RNA[x, 9])
# for raw
cluster1vs2.markers$group_1_exp_raw <- sapply(rownames(cluster1vs2.markers), function(x) avg_exp_df_counts_raw$RNA[x, 8])
cluster1vs2.markers$group_2_exp_raw <- sapply(rownames(cluster1vs2.markers), function(x) avg_exp_df_counts_raw$RNA[x, 9])
head(cluster1vs2.markers)
In the end, you will get the columns in the same data frame corresponding to your two idents (8 and 9 in this example)
@Elucidata Thank you so much for the code! I managed to retrieve the raw and scaled counts for genes alongside FC values by following the steps you generously provided. I am now googling to find out how they arrive at their FC values because manually I can't seem to get to that.
Great! That's a good question, happy to answer. Possibly we could have that as a separate dedicated question so that it doesn't get lost in the comments here.