plotTopicProfiles: Plot NMF topic profiles

View source: R/plotTopicProfiles.R

plotTopicProfilesR Documentation

Plot NMF topic profiles

Description

This function takes in the fitted NMF model and returns the topic profiles learned for each cell facet = FALSE or cell type facet = TRUE. Ideal training will return all the cell from the same cell type to share a unique topic profile.

Usage

plotTopicProfiles(x, y, facet = FALSE, min_prop = 0.01, ncol = NULL)

Arguments

x

NMFfit object

y

vector of group labels. Should be of length ncol(coef(x)).

facet

logical indicating whether to stratify by group. If FALSE (default), weights will be the median across cells for each group (point = topic weight for a given cell type). If TRUE, cell-specific weights will be shown (point = topic weight of a given cell).

min_prop

scalar in [0,1]. When facet = TRUE, only cells with a weight > min_prop will be included.

ncol

integer scalar specifying the number of facet columns.

Value

ggplot object

Author(s)

Marc Elosua Bayes & Helena L Crowell

Examples

library(ggplot2)
x <- mockSC()
y <- mockSP(x)
z <- getMGS(x)

res <- SPOTlight(x, y,
    groups = x$type,
    mgs = z,
    group_id = "type",
    verbose = FALSE)

plotTopicProfiles(res[[3]], x$type, facet = TRUE)
plotTopicProfiles(res[[3]], x$type, facet = FALSE)

MarcElosua/SPOTlight documentation built on March 7, 2024, 4:58 p.m.