gugl58
7/5/2018 - 8:15 AM

single.vector.allratios

miR_Ros.norm.geneRatios <- apply(Biobase::exprs(miR_Ros.set), 2, single.vector.allratios, data.is.log=TRUE)
single.vector.allratios <- function(named.num.vector, data.is.log=TRUE){
	# matrix with all ratios
	if(data.is.log){
		a <- outer(named.num.vector, named.num.vector, "-")
	}else{
		a <- outer(named.num.vector, named.num.vector, "/")
	}
	# i only need a part of it (upper or lower triangular matrix)
	a[upper.tri(a, diag=TRUE)] <- NA
	b <- na.omit(reshape2::melt(a))
	named.values <- b$value
	
	# to check if the naming is correct:
	#' exprs(miR_Ros.set)[1:3, 1]
	#' a <- outer(exprs(miR_Ros.set)[1:3, 1], exprs(miR_Ros.set)[1:3, 1], "/")
	#' a
	#' ## so I see, it is x-axis-gene / y-axis-gene
	#' a[upper.tri(a, diag=TRUE)] <- NA
	#' b <- na.omit(reshape2::melt(a))
	#' b
	#' ## so it is Var1/Var2
	names(named.values) <- paste0(b$Var1, "_/_", b$Var2)
	return(named.values)
}