scRNA-seq gene expression gradient onto tSNE plot
1
0
Entering edit mode
5.9 years ago
TJ ▴ 50

Hi All,

I am working with some scRNA-seq data and have generated a tSNE plot with different cell clusters using SIMLR. I would like to now color the clusters based on single gene expression with a gradient, similar to what is done in Seurat (but I'm not using Seurat).

I have my data stored in a sce (SingleCellExperiment) class. The log2 transformed counts are stored in assays as logcounts. I also have a data frame, my.df, that has the plot information (tSNE plot generated with SIMLR). I would like to color the plot based on GeneA's expression using a gradient. This is what I have:

# Extract logcounts matrix from SingleCellExperiment container as a data frame
countsdata <- as.data.frame(logcounts(mySCE))

# Subset GeneA
GeneA <- countsdata["GeneA",]
GeneA <- as.numeric(GeneA)

# my dataframe, called my.df, with the cell locations looks something like this (tSNE generated using SIMLR package):
          [,1]        [,2]
[1,]  22.10031   2.2608286
[2,]  14.38361  11.0612738
[3,]  20.60289   3.1783049
[4,]  20.97281   0.6743305
[5,] -15.15925 -15.8382650

# Using the colorRampPalette
mycolor <- colorRampPalette(c("red", "gray"))

# Create a new column based on GeneA
my.df$geneAnewcolumn <- mycolor(10)[cut(GeneA, breaks = 10)]

# Plot the result
plot(my.df$V1,
     my.df$V2,
     pch = 20, 
     col = my.df$geneAnewcolumn)

While this generates a plot with the clusters and certain cells highlighted, it doesn't produce a gradient (I've tried several known genes), more of an on/off. I also played around with the number in mycolor(10) and breaks without luck. Any help would be much appreciated.

Thank you.

singlecellexperiment RNA-Seq SIMLR • 3.2k views
ADD COMMENT
0
Entering edit mode

Why not use Seurat? It keeps benchmarking as the best-in-test (e.g. here and here).

ADD REPLY
0
Entering edit mode
5.9 years ago
TJ ▴ 50

Actually, I think I just figured this out with ggplot2 -

myGene <- as.numeric(logcounts(sce)["GeneA",])

ggplot(data = my.df ) + geom_point(aes( x = my.df$V1, y = my.df$V2, color=myGene)
) + scale_color_continuous(low = "grey", high = "red", guide = "colourbar",
                           aesthetics = "colour")
ADD COMMENT
0
Entering edit mode

I'm also trying to do the same thing. Can you please explain what that you have done here?

ADD REPLY
0
Entering edit mode

myGene <- as.numeric(logcounts(sce)["GeneA",]) - This takes the logcounts slots of the SingleCellExperiment object and subsets as a numeric only one row, which in this case is "GeneA" (your favorite gene you want to look at). So now you have a vector of numeric values of GeneA across all cells in your sce

  • Below, using ggplot is a datafame that contains coordinates for your cells and their locations using whatever dimension reduction technique you have (for example PCA/tSNE/UMAP). Remember it's just a 2D representation of your data that's been reduced from some higher dimension(s). Then using ggplot's geom_point(), you can use the my.df locations and color them based on your GeneA values, here as color=myGene. The scale_continuous() lets you pick the colors. ggplot(data = my.df ) + geom_point(aes( x = my.df$V1, y = my.df$V2, color=myGene) ) + scale_color_continuous(low = "grey", high = "red", guide = "colourbar", aesthetics = "colour")
ADD REPLY

Login before adding your answer.

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