Home >
Community >
Seurat VlnPlot presenting expression of multiple genes in a single cluster
Upvote
25
Downvote
+ Rstudio
+ R
+ Bioinformatics
Posted by
Ju Long
Seurat VlnPlot presenting expression of multiple genes in a single cluster
To do so one workaround it to have your data in "long format" and then use the column that holds the "gene names" as the x variable while plotting.
You can use FetchData() to extract data from a Seurat object. VlnPlot's default is the data slot (of the active assay if using Seurat v3 I suppose). And you can specify which cells and genes to retrieve.
Melt() would transform your data into "long format". By not specifying any arguments, we push for all of the info in the three variables to be gathered in two columns:
long_data <- melt(data)
No id variables; using all as measure variables
> head(long_data)
variable value
1 FZD9 0
2 FZD9 0
3 FZD9 0
> tail(long_data)
variable value
1870 APC 0
1871 APC 0
1872 APC 0
ggplot2 is used to add "violin" and "jitter" layers. You can customize the output to look (exactly) like the VlnPlot() output.
And here is the same graph generated by VlnPlot():
There are no "violins" as the counts are almost entirely zeros. And see how different the ranges are in the y axes of the VlnPlot. So the "tweak" I have presented here would only work for genes that are expressed at similar levels / similar ranges.
To do so one workaround it to have your data in "long format" and then use the column that holds the "gene names" as the x variable while plotting.
You can use FetchData() to extract data from a Seurat object. VlnPlot's default is the data slot (of the active assay if using Seurat v3 I suppose). And you can specify which cells and genes to retrieve.
Melt() would transform your data into "long format". By not specifying any arguments, we push for all of the info in the three variables to be gathered in two columns:
long_data <- melt(data)No id variables; using all as measure variables> head(long_data) variable value1 FZD9 02 FZD9 03 FZD9 0> tail(long_data) variable value1870 APC 01871 APC 01872 APC 0
ggplot2 is used to add "violin" and "jitter" layers. You can customize the output to look (exactly) like the VlnPlot() output.
And here is the same graph generated by VlnPlot():
There are no "violins" as the counts are almost entirely zeros. And see how different the ranges are in the y axes of the VlnPlot. So the "tweak" I have presented here would only work for genes that are expressed at similar levels / similar ranges.
To do so one workaround it to have your data in "long format" and then use the column that holds the "gene names" as the
xvariable while plotting.You can use
FetchData()to extract data from aSeuratobject.VlnPlot's default is thedataslot (of the active assay if using Seurat v3 I suppose). And you can specify which cells and genes to retrieve.Melt()would transform your data into "long format". By not specifying any arguments, we push for all of the info in the three variables to be gathered in two columns:ggplot2is used to add "violin" and "jitter" layers. You can customize the output to look (exactly) like theVlnPlot()output.And here is the same graph generated by
VlnPlot():There are no "violins" as the counts are almost entirely zeros. And see how different the ranges are in the y axes of the
VlnPlot. So the "tweak" I have presented here would only work for genes that are expressed at similar levels / similar ranges.To do so one workaround it to have your data in "long format" and then use the column that holds the "gene names" as the
xvariable while plotting.You can use
FetchData()to extract data from aSeuratobject.VlnPlot's default is thedataslot (of the active assay if using Seurat v3 I suppose). And you can specify which cells and genes to retrieve.Melt()would transform your data into "long format". By not specifying any arguments, we push for all of the info in the three variables to be gathered in two columns:ggplot2is used to add "violin" and "jitter" layers. You can customize the output to look (exactly) like theVlnPlot()output.And here is the same graph generated by
VlnPlot():There are no "violins" as the counts are almost entirely zeros. And see how different the ranges are in the y axes of the
VlnPlot. So the "tweak" I have presented here would only work for genes that are expressed at similar levels / similar ranges.More
VOTE
VOTE