stratify-methods: stratify

Description Usage Arguments Details Value Author(s)

Description

stratify x into 0,1, based on a percentile or a threshold

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
stratify(x, percentile, threshold, as.factor = FALSE)

## S4 method for signature 'numeric,numeric,missing,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'numeric,missing,numeric,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'numeric,numeric,numeric,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'matrix,numeric,missing,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'matrix,missing,numeric,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'matrix,numeric,numeric,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'data.frame,ANY,ANY,logicalORmissing'
stratify(x, percentile,
  threshold, as.factor = FALSE)

## S4 method for signature 'list,ANY,ANY,logicalORmissing'
stratify(x, percentile, threshold,
  as.factor = FALSE)

## S4 method for signature 'ANY,missing,missing,missing'
stratify(x, percentile, threshold,
  as.factor = FALSE)

Arguments

x

a numeric vector, matrix, data.frame or list

percentile

numeric: The percentile at which to cut the data, in the range (0,1). Eg 75th percentile = 0.75 If x is 2D, then you can specify 1 percentile for all rows, or 1 percentile per row in x.

threshold

numeric: The numeric threshold at which to cut the data. This should not be NULL, or NA, and if specified, should be within the range of (min(x), max(x)). If x is 2D, then you can specify 1 threshold for all rows, or 1 threshold per row in x. percentile overrides threshold if both are specified.

as.factor

logical: controls whether the return value should be a factor or not.

Details

This was designed to convert continuous data (eg gene expression levels) and discretize into low/high as 0/1, respectively. These data can be a simple vector, or 2D matrix or data.frame, or a list where each element is a numeric(1). You can stratify that data using either a percentile, eg 0.25 or 0.5 for the 25th and 50th percentile; or a threshold, eg 6.5.

If your data is 1D, then you should supply either a single percentile or threshold. If you have 2D data, then you can provide a single percentile or threshold, or 1 percentile or threshold for each row in x. these values are recycled if necessary to match nrow(x).

If you supply both percentile and threshold, then the percentile will be used. If you supply neither, then percentile=0.5 is used.

Value

a numeric vector, matrix, data.frame or list of 0/1 values, where 0 means below the cutpoint, and 1 means >= the cutpoint.

Author(s)

Mark Cowley, 2011-09-01


drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.