Skip to content

Instantly share code, notes, and snippets.

@johnschrom
Created June 5, 2015 17:05
Show Gist options
  • Save johnschrom/3f61097e78cedc7d5229 to your computer and use it in GitHub Desktop.
Save johnschrom/3f61097e78cedc7d5229 to your computer and use it in GitHub Desktop.
Quintile normalization
# Create a refernce distribution using the median of all samples
ref <- apply(apply(data.normalized[,3:ncol(data.normalized)],
2,
FUN=sort),
1,
FUN=median)
# Create a emperical cdf function for the reference distribution
ref.cdf <- ecdf(ref)
# Quintile normalize!
data.qn <- apply(data.normalized[,3:ncol(data.normalized)], 2, function(d) {
sample.cdf <- ecdf(d)
return(quantile(ref.cdf, sample.cdf(d))) })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment