Learn R Programming

stoRy (version 0.1.0)

TEA: Theme enrichment analysis (TEA).

Description

TEA calculates enrichment scores for themes in a storset relative to a background set of stories according to the hypergeometric test.

Usage

TEA(mystorysets, background_storyset = c("TOS", "TAS", "TNG"),
  theme_levels = c("choice", "major", "minor"), min_storyset_size = 5,
  min_theme_occurrence = 1)

Arguments

mystorysets

A storysets class object that contains one or many individual storysets.

background_storyset

default c("TOS", "TAS", "TNG"). A string indicating the storyset to use as background. Possible values are TOS, TAS, TNG and their combinations.

theme_levels

c("choice", "major", "minor"). A string indicating the theme levels to use in the analysis. Possible values are choice, major, minor and their combinations.

min_storyset_size

default 5. The minimum allowable size for a storyset. For small samples the hypergeometric test may be unreliable.

min_theme_occurrence

default 1. The minimum number of times a theme must occur in a storyset. For small samples the hypergeometric test may be unreliable.

Value

Returns a data frame where each row corresponds to a theme. The column Pvalue contains raw enrichment scores, i.e., hypergeometric test P-values. The column Padj contains the corresponding Benjamini-Hotchberg adjusted P-values.

Examples

Run this code
# NOT RUN {
#######################################################################
# Load the Star Trek series storysets smt file and storysets object   #
#######################################################################
file <- system.file("storysets", "series.smt", package = "stoRy")
mystorysets <- storysets$new(file)
print(mystorysets)
#######################################################################
# Perform the theme enrichment analysis for each of TOS, TAS, and TNG #
# relative to default TOS/TAS/TNG background                          #
#######################################################################
results <- TEA(mystorysets)
#######################################################################
# Output top ten enriched TOS themes                                  #
#######################################################################
results$TOS[1:10,c("Theme", "NSample", "NOmega", "Pvalue", "Padj")]
#######################################################################
# Output top ten enriched TAS themes                                  #
#######################################################################
results$TOS[1:10,c("Theme", "NSample", "NOmega", "Pvalue", "Padj")]
#######################################################################
# Output top ten enriched TNG themes                                  #
#######################################################################
results$TOS[1:10,c("Theme", "NSample", "NOmega", "Pvalue", "Padj")]
# }

Run the code above in your browser using DataLab