| mosaic {MatrixQCvis} | R Documentation |
The function 'mosaic' creates a mosaic plot of two factors from an 'SummararizedExperiment' object. The columns 'f1' and 'f2' are taken from 'colData(se)'.
mosaic(se, f1, f2)
se |
'SummarizedExperiment' object |
f1 |
'character', 'f1' is one of the column names in 'colData(se)' |
f2 |
'character', 'f2' is one of the column names in 'colData(se)' |
Code partly taken from https://stackoverflow.com/questions/21588096/pass-string-to-facet-grid-ggplot2
'gg' object from 'ggplot2'
## create se
set.seed(1)
a <- matrix(rnorm(100), nrow = 10, ncol = 10,
dimnames = list(1:10, paste("sample", 1:10)))
a[c(1, 5, 8), 1:5] <- NA
cD <- data.frame(name = colnames(a),
type = c(rep("1", 5), rep("2", 5)),
cell_type = c("A", "B"))
rD <- data.frame(spectra = rownames(a))
se <- SummarizedExperiment::SummarizedExperiment(assay = a,
rowData = rD, colData = cD)
mosaic(se, "cell_type", "type")