R/MetaGenomicNetwork_class.R

#--------------------------------------#
#'@export
MetaGenomicNetwork <- R6::R6Class(
	classname="MetaGenomicNetwork" ,
	public=list(
		metaObj=NA,
		corr.fun=NA,
		weights=NA,
		adjacency=NA,
		graph=NA
	)
)


#--------------------------------------#
#'@noRd
MetaGenomicNetwork$set(which="public",
				name="initialize",
				value=function(metaObj, corr.fun){
					self$metaObj=metaObj
					self$corr.fun=corr.fun
					self$weights=corr.fun(self$mdata)
					self$validate()
				})

#--------------------------------------#
#'@noRd
MetaGenomicNetwork$set(which="public",
					   name="validate",
					   value=function(){
					   	assert(class(self$metaObj)[1]=="MetaGenomic", "MetaObj must be a Metagenomic class")
					   	assert(is.function(self$corr.fun))
					   	assert(nrow(self$weights)==ncol(self$weights), "weights, the result of corr.fun, must be a square matrix")
					   	assert(all(rownames(self$weights)==colnames(self$weights)), "at least a name of row and column in weights differ")
					   	assert(nrow(self$weights)==self$ntaxa, "weights dimension differ from taxa number")
					   	assert(all(rownames(self$weights)==self$taxa_name), "at least a name in weights differ from taxa name")
					   })
Fuschi/JAX documentation built on Dec. 17, 2021, 9:22 p.m.