Skip to contents

Generates a named vector of sign values (+1 = repressive, -1 = active, 0 = unclassified) for chromatin states based on user-specified patterns. This is typically used to weight states in functions such as ErosionScore.

Usage

ChromatinStateSigns(
  state_names,
  state_col = "name",
  active_patterns = c("TssA", "TssFlnk", "Tx", "EnhA", "EnhG", "EnhWk"),
  repressive_patterns = c("ReprPC", "Quies", "Het"),
  error_if_unclassified = FALSE
)

Arguments

state_names

Character string containing a unique list of chromatin state names.

state_col

Character string specifying the metadata column name in chromHMM_states@elementMetadata containing the state names. Default = "name".

active_patterns

Character vector of regex patterns used to identify active states. Default = c("TssA","TssFlnk","Tx","EnhA","EnhG","EnhWk").

repressive_patterns

Character vector of regex patterns used to identify repressive states. Default = c("ReprPC","Quies","Het").

error_if_unclassified

Logical indicating whether to stop with an error if any states remain unclassified (sign = 0). Default = FALSE (issues a message instead).

Value

A named numeric vector of signs with one entry per unique chromatin state:

  • -1: Active state

  • +1: Repressive state

  • 0: Unclassified (did not match any pattern)

Details

The function:

  1. Extracts unique chromatin state names from chromHMM_states.

  2. Initializes all state signs to 0 (unclassified).

  3. Assigns -1 for states matching any active_patterns.

  4. Assigns +1 for states matching any repressive_patterns.

The returned vector can be supplied to ErosionScore as the state_signs argument.

See also

Examples

if (FALSE) { # \dontrun{
state_signs <- ChromatinStateSigns(
  chromHMM_states = chromHMM_gr,
  state_col = "name",
  error_if_unclassified = TRUE
)
} # }