Counts alongside Fold changes - FindMarkers Seurat
1
0
Entering edit mode
3.1 years ago

Is there a way to retrieve counts for genes alongside logFC, pct.1,pct.2, adjusted p-val, when using FindMarkers function on Seurat? We are doing integrated analyses, so basically counts for genes in group 1, group 2 alongside logFC etc. it seems like having access to this will help interpret fold changes better.

RNA-Seq seurat • 2.0k views
ADD COMMENT
0
Entering edit mode

@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 providedimage below. I am now googling to find out how they arrive at their FC values because manually I can't seem to get to that.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
3
Entering edit mode
3.1 years ago
Elucidata ▴ 270

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) image-Seurat

ADD COMMENT

Login before adding your answer.

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