mosaic: Mosaic plot for two factors in colData(se)

View source: R/tab_samplesfeatures.R

mosaicR Documentation

Mosaic plot for two factors in colData(se)

Description

The function mosaic creates a mosaic plot of two factors from an SummarizedExperiment object. The columns f1 and f2 are taken from colData(se).

Usage

mosaic(se, f1, f2)

Arguments

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)

Details

Code partly taken from https://stackoverflow.com/questions/21588096/pass-string-to-facet-grid-ggplot2

Value

gg object from ggplot2

Examples

## create se
set.seed(1)
a <- matrix(rnorm(100), nrow = 10, ncol = 10,
            dimnames = list(seq_len(10), paste("sample", seq_len(10))))
a[c(1, 5, 8), seq_len(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")


tnaake/MatrixQCvis documentation built on May 6, 2024, 8:19 p.m.