R/create.training.validation.split.R

Defines functions create.training.validation.split

Documented in create.training.validation.split

create.training.validation.split <- function(exp.data = NULL, ann.data = NULL, seed.number = 51214) {


	# sanity test
	if (!identical(colnames(exp.data), rownames(ann.data))) {
		stop("\nDieing gracefully bcoz colnames(exp.data) != rownames(ann.data)");
		}

	# length of training set
	# 66:34 split, otherwise 50:50
	if (ncol(exp.data) < 200) {
		training.length <- round(ncol(exp.data)*0.66);
		}
	else {
		training.length <- round(ncol(exp.data)*0.5);	
		}

	# set seed
	set.seed(seed.number);
	samples.T.indices <- sample(1:ncol(exp.data), training.length, replace = FALSE);

	samples.T <- colnames(exp.data)[samples.T.indices];
	samples.V <- setdiff(colnames(exp.data), samples.T);

	return(
		list(
			"exp.T" = exp.data[, samples.T],
			"ann.T" = ann.data[samples.T, ],
			"exp.V" = exp.data[, samples.V],
			"ann.V" = ann.data[samples.V, ]
			)
		);
	}

Try the iDOS package in your browser

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

iDOS documentation built on July 4, 2024, 1:09 a.m.