1
$\begingroup$

I am looking for a way to present some single-cell RNA sequencing data on expression of a certain gene. My dataset has 2 variables, cell type and condition. I'm looking to create a grouped aligned scatter plot bar graph of the expression of the gene, where the y-axis is expression levels, while X axis is the different cell types, with each cell type having 2 bars (1 for healthy, 1 for diseased). My dataset has 3 healthy and 3 diseased samples, but all of the data is integrated into a Seurat object. To first create an aligned scatter plot bar graph, what I did was generate a DotPlot for the expression of gene X in each sample, split by cell-type. Then I realized that DotPlot() prints out a data table with values including avg.exp, pct.exp and avg.scaled.exp. I used the avg.exp metric to plot the data, but I was posting this question to see if there are other ways I can access and present expression data from a Seurat object. Is the way I've presented accurate? I've posted a sample bar graph of what I'm looking for, and the main question is how I can gather the expression levels across cell types AND diseased or healthy condition.

Thanks! Example Bar Graph

$\endgroup$

2 Answers 2

1
$\begingroup$

In single-cell data a bargraph with error bar is not usually shown since the gene expression does not have a normal distribution due to drop-outs. A violin-plot is commonly used. In your case, first set the active.ident to cell types

seuratObj <- SetIdent(seuratObj , value = "Cell.Types")

Then call the violin plot

VlnPlot(seuratObj , features = "geneX", split.by = "condition")

If you still specifically need bargraph, you can get the output of the violin plot as a dataframe and then draw the barplot.

$\endgroup$
1
$\begingroup$

Following the answer of @Ajay.

You can add + geom_boxplot() after the command to turn the violin plot to a box plot.

As for the barplot, you can do it with these:

# the object is your seurat object
data.df <- object@meta.data[, c("celltypes", "condition")]
data.df["value"] <- object$RNA@data["geneX", ]
data.df <- data.df %>% mutate(group = paste(celltypes, condition, sep=":"))

# remove cells that do not express the gene
data.df <- data.df %>% filter(value > 0)

data.df.2 <- data.df %>% group_by(group) %>% summarise(sd=sd(value),value=mean(value))
X <- str_split(data.df.2$'group', ":", 2, simplify=TRUE)
data.df.2$'celltypes' <- X[, 1]
data.df.2$'condition' <- X[, 2]

ggplot(data.df.2, aes(fill=condition, y=value, x=celltypes)) + 
    geom_bar(color="black", position="dodge", stat="identity") +
    geom_errorbar(
        aes(ymin=value, ymax=value+sd), width=.2,
        position=position_dodge(.9)
    )

Dropout is very usual in single-cell data. If you really want to show the expression with barplot, I would suggest removing the zero values or using denoised data for better visualisation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.