Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncertain about how to implement average expression FeaturePlot code #6218

Closed
s-storey opened this issue Jul 20, 2022 · 1 comment
Closed

Comments

@s-storey
Copy link

s-storey commented Jul 20, 2022

Good day,

I am a little lost after essentially inheriting a scRNAseq pipeline, but I'd love to use this tool as an 'unbiased' annotation strategy. I'm looking for help as to how to apply this to my own seurat objects but don't quite understand the application of metadata well enough to do this on my own.

Any help parsing through this code would be really appreciated.

# Select genes of interest (using sample() here for demonstration purposes)
gene.set <- sample(x = rownames(x = object@data), size = 100, replace = FALSE)

# Get mean expression of genes of interest per cell
mean.exp <- colMeans(x = object@data[gene.set, ], na.rm = TRUE)

# Add mean expression values in 'object@meta.data$gene.set.score'
if (all(names(x = mean.exp) == rownames(x = object@meta.data))) {
  cat("Cell names order match in 'mean.exp' and 'object@meta.data':\n", 
      "adding gene set mean expression values in 'object@meta.data$gene.set.score'")
  object@meta.data$gene.set.score <- mean.exp
}

# Plot mean expression using Seurat::FeaturePlot()
FeaturePlot(object = object, features.plot = "gene.set.score")

Originally posted by @leonfodoulian in #528 (comment)

@andrewwbutler
Copy link
Collaborator

Hi,

I'm not sure I can add much beyond what the comments already explain but basically, what this code chunk is doing is computing the per-cell mean for a set of genes and storing this as a cell-level meta.data entry. Those values are then being used by the FeaturePlot function to display these values in a scatter plot where cells are colored by gene set mean. Please feel free to update though if you have a more specific question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants