Skip to contents

Used internally by processExpressionSet. Code to either take the average across a set of duplicated "keys" (can be probes or genes, which correspond to the rows in the expression matrix "expr"), or take the keys that has the highest variance across the set of duplicated keys.

Usage

collapseDupProbes(
  expr,
  sampleColNames = colnames(expr),
  keys,
  method = c("average", "highestVariance"),
  debug = TRUE,
  removeNA_keys = TRUE,
  varMetric = c("everything", "all.obs", "complete.obs", "na.or.complete",
    "pairwise.complete.obs")
)

Arguments

expr

An expression matrix with genes in the rows and samples in the columns.

sampleColNames

Sample column names. Needed for internal debugging; usually the default colnames(expr) is appropriate.

keys

Generally the list of gene symbols, or some molecular key, that needs to be "collapsed" because it contains duplicated names.

method

Method used to collapse probes: take the mean across all duplicated keys, or just pick the key with the highest variance?

debug

Use internal unit tests that will stop the code if it detects a bug?

removeNA_keys

Remove any NA keys?

varMetric

Standard options taken from the base var() function. May be important if you have NA values in your data matrix; otherwise, "everything" is usually fine.

Value

Returns a processed list with the items "expr" and "keys", the expression matrix and final keys list.

Author

Katie Planey <katie.planey@gmail.com>

Examples

#load up our datasets
curatedBreastDataExprSetList <- getCuratedBreastDataExprSetList(test=TRUE)

#just perform on second dataset, GSE2034, as an example.
#This dataset has no NAs already but does have duplicated genes
#highestVariance calculation make take a minute to run.
collapsedData <- collapseDupProbes(expr=exprs(curatedBreastDataExprSetList[[2]]),  
keys=fData(curatedBreastDataExprSetList[[2]])[, "gene_symbol"], 
method = c("highestVariance"), debug = TRUE, removeNA_keys = TRUE, 
varMetric = c("everything"))
#> It's best to impute NA values before running this function
#> otherwise it may set averages to NA if there is 1 NA present.
#> This function just removes any genes whose key is NA.
#> 
#> You may get a notification here because key (usually gene) names are
#>   duplicated so it can't use them as row names. 
#>   That's OK, because we are immediately collapsing them into one feature.
#look at names of outputs
names(collapsedData)
#> [1] "expr" "keys"