R/formatData.R

Defines functions formatData

Documented in formatData

formatData <-
function(data, countThreshold=1000, normalizeThreshold=10000){
	if(missing(data))
		stop("A valid data set is required.")
	
	### Order the data and turn any NAs to 0
	data <- data[order(rownames(data)),, drop=FALSE]
	data[is.na(data)] <- 0
	
	### Keep only samples where the top level is above the count Threshold
	data <- data[, data[1,] >= countThreshold, drop=FALSE]
	
	### Make sure we havent removed everything
	if(ncol(data) == 0)
		stop("'countThreshold' is too high.")
	
	# Normalize the read counts
	if(normalizeThreshold > 0){
		for(i in ncol(data):1)
			data[,i] <- data[,i] * (normalizeThreshold/data[1, i])
	}
	
	return(data)
}

Try the HMPTrees package in your browser

Any scripts or data that you put into this service are public.

HMPTrees documentation built on May 2, 2019, 4:02 p.m.