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.
Why not use Seurat? It keeps benchmarking as the best-in-test (e.g. here and here).