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

How I can this nice feature plot #657

Closed
fereshtehizadi opened this issue Jul 25, 2018 · 3 comments
Closed

How I can this nice feature plot #657

fereshtehizadi opened this issue Jul 25, 2018 · 3 comments

Comments

@fereshtehizadi
Copy link

fereshtehizadi commented Jul 25, 2018

My problem is this when I am plotting a feature plot I expect DDB_G0267412 be high lighted only in cluster 0 but I noticed a sporadic expression of cell types genes. So that I wish have a tSNE plot on which in a cluster the ratio of the expression of DDB_G0267412 to DDB_G0277853 be spotted only in cluster 0

For example in this picture each gene is a marker of a cluster beautifully

[


](url)

While I am plotting the same although I know DDB_G0267412 is cell type marker of cluster 0 and DDB_G0277853 is cell type marker of cluster 1 but I am obtaining this uninformative picture

[


](url)

> > FeaturePlot(object = b, features.plot = c("DDB_G0277853", "DDB_G0267412"), no.legend = FALSE, 
 > +             min.cutoff = "q10", max.cutoff = "q90")
@leonfodoulian
Copy link
Contributor

Hi @fereshtehizadi,

If I understand you correctly, what you want to plot is a ratio of expression values of two genes, right? If that is the case, you can simply use the following code for that:

# Define a pseudocount to add to the data in order to avoid Inf and -Inf values
pseudocount <- 0.1

# Compute ratio of expression values of the two genes of interest
gene.exp.ratio <- (object@data["DDB_G0267412",] + pseudocount) / (object@data["DDB_G0277853",] + pseudocount)

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

# Plot ratio of expression values using Seurat::FeaturePlot()
Seurat::FeaturePlot(object = object, features.plot = "gene.exp.ratio")

It is an adaptation of the code from issue #528. Note that if your denominator is of value 0, the ratio will return Inf and -Inf (depending on the sign of the numerator). Therefore, I added a pseudo-count of 0.1 to all counts so to avoid this, as the presence of Inf and/or -Inf in the data return an error. I am however not sure to what extent this is of good practice.

Hope this helps anyway!

Best,
Leon

@satijalab
Copy link
Collaborator

I think you are hoping that the plot would reveal more discrimination between the two patterns.

Unfortunately, the two genes may not be strong cluster markers in your data, despite prior knowledge (you can visualize this with VlnPlot).

Alternately, the visualization min and max cutoffs set the coloring scale, and may be obscuring a more clear pattern

@fereshtehizadi
Copy link
Author

fereshtehizadi commented Aug 7, 2018

Hi,

Sorry, If I have a list of genes I know how to plot them in heat map on my cluster (let's say I have 8 clusters of cells for 8 time points), but I have also sub-clusters in each cluster. So could you please help me to figure out how I can have a heat map with sub-clusters for each cluster on which I am showing a list of genes. Something like like picture

[


](url)

Thank you so much in advance

yuhanH pushed a commit that referenced this issue Mar 29, 2023
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