View source: R/plotCellTypeProps.R
| plotCellTypeProps | R Documentation |
This is a plotting function that shows the cell type composition for each
sample as a stacked barplot. The plotCellTypeProps returns a
ggplot2 object enabling the user to make style changes as required.
plotCellTypeProps(x = NULL, clusters = NULL, sample = NULL)
x |
object of class |
clusters |
a factor specifying the cluster or cell type for every cell.
For |
sample |
a factor specifying the biological replicate for each cell.
For |
a ggplot2 object
Belinda Phipson
library(speckle)
library(ggplot2)
library(limma)
# Generate some fake data from a multinomial distribution
# Group A, 4 samples, 1000 cells in each sample
countsA <- rmultinom(4, size=1000, prob=c(0.1,0.3,0.6))
colnames(countsA) <- paste("s",1:4,sep="")
# Group B, 3 samples, 800 cells in each sample
countsB <- rmultinom(3, size=800, prob=c(0.2,0.05,0.75))
colnames(countsB) <- paste("s",5:7,sep="")
rownames(countsA) <- rownames(countsB) <- paste("c",0:2,sep="")
allcounts <- cbind(countsA, countsB)
sample <- c(rep(colnames(allcounts),allcounts[1,]),
rep(colnames(allcounts),allcounts[2,]),
rep(colnames(allcounts),allcounts[3,]))
clust <- rep(rownames(allcounts),rowSums(allcounts))
plotCellTypeProps(clusters=clust, sample=sample)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.