addDiffStatus-methods: Add a status column

addDiffStatusR Documentation

Add a status column

Description

Add a status column based on significance and estimated change

Usage

addDiffStatus(x, ...)

## S4 method for signature 'data.frame'
addDiffStatus(
  x,
  fc_col = "logFC",
  sig_col = c("FDR", "hmp_fdr", "p_fdr", "adj.P.Value"),
  alpha = 0.05,
  cutoff = 0,
  up = "Increased",
  down = "Decreased",
  other = "Unchanged",
  missing = "Undetected",
  new_col = "status",
  drop = FALSE,
  ...
)

## S4 method for signature 'DataFrame'
addDiffStatus(x, new_col = "status", ...)

## S4 method for signature 'GRanges'
addDiffStatus(x, ...)

## S4 method for signature 'GRangesList'
addDiffStatus(x, ...)

## S4 method for signature 'SummarizedExperiment'
addDiffStatus(x, ...)

Arguments

x

Object to be classified

...

Used to pass arguments between methods

fc_col

Name of the fold-change column

sig_col

Name of the column with significance values

alpha

significance threshold

cutoff

minimum estimated change to be considered in either of the up or down categories

up, down, other

factor levels to annotate regions based on the above criteria

missing

Value to add when either fc_col or sig_col has NA values

new_col

name of the new column to be added

drop

logical(1) Drop unused factor levels from the status column

Details

This takes a simple object and adds a new column classifying entries into one of three categories, as specified using up, down or other. Results in the new column will always be returned as a factor with levels in order of the values provided in the arguments other, down and up

Value

An object of the same type as provided

Examples

## Working with a data.frame
set.seed(101)
df <- data.frame(logFC = rnorm(20), p = rbeta(20, shape1 = 1, shape2 = 20))
df$FDR <- p.adjust(df$p, "fdr")
addDiffStatus(df)

## This works identically with a GRanges object, amongst others
gr <- GRanges(paste0("chr1:", seq_len(20)))
mcols(gr) <- df
addDiffStatus(gr)


steveped/chipExtra documentation built on Aug. 1, 2024, 12:33 a.m.