R/AllClassses.R

#
# S4 class definitions
#

#' Data class for the Furlong dataset
#'
#' A class to hold data from (Zizen 2009) paper (Supp Table 8). This class contains methods to convert it to
#' both binary and continuous \link{DDDataSet} objects. 
#'
#' @slot signalMatrix the signal matrix
#' @slot targetClasses the target class names
#' 
#' @references Robert P. Zinzen et al., "Combinatorial binding predicts spatio-temporal cis-regulatory activity,"
#'            Nature 462, no. 7269 (November 5, 2009): 65-70.
#' @export 
setClass("FurlongDataSet",
	representation = representation(
		signalMatrix = "matrix", 
		targetClasses = "factor"
	)
)


#' Dataset class for Direct Dependence Graphs
#'
#' This is the main class to hold data to be used in Direct Dependence Graphs. The data is stored in a \code{data}
#' data.frame with the last column named "class". Dataset can be either binary, or continuous. Mixtures of
#' binary and continuous variables are currently not supported. 
#'
#' @slot name a descriptive name of this dataset used as caption for graphs, etc
#' @slot data data.frame containing the variables as columns, and the special column "class" as last column
#' @slot dataType either "binary" or "continuous" are supported, indicated the type of variables present 
#'       (all need to be either binary or continuous)
#'
#' @export
setClass("DDDataSet", 
	representation = representation(
		name = "character",
		data = "data.frame",
		dataType = "character"
	)
)

#' Direct Dependence Graph class
#'
#' This class represents one Direct Dependence Graphs (generated by a certain conditional independence test, alpha value, etc).
#' It contains the original \code{DDDataSet} object from which it stems, the set of parameters, the set of informative 
#' statistics as well as lists of direct, joint and indirect variables. Finally, it contains the edges needed to 
#' draw the graph. 
#' 
#' @param dataset the DDDataSet object used to make the DDGraph
#' @param params the parameters used in making the DDGraph
#' @param stats the values of statistics used to make the DDGraph
#' @param direct the list of indicies of direct variables
#' @param indirect the list of indicies of indirect variables
#' @param joint the list of indicies of joint variables
#' @param conditional the list of indicies of conditional variables
#' @param conditionalJoint the list of indicies of conditionally joint variables
#' @param edges the list of edges (type DDGraphEdge) the describe the graph
#'
#' @export
setClass("DDGraph", 
	representation = representation(
		dataset = "DDDataSet",
		params = "list",
		stats = "list",
		direct = "numeric",
		indirect = "numeric",
		joint = "numeric",
		conditional = "numeric",
		conditionalJoint = "numeric",
		edges = "list"
	)
)

#' Data class to store the results of a conditional independence test
#'
#' This class stored the results from \code{DDDataSet::ciTest()}. It stores the
#' indexes and names of two variables involved in the test, the conditioning set
#' as well as the P-value and type of test. 
#'
#' @slot targetInx the index of the first variable
#' @slot targetName the name of the first variable
#' @slot sourceInx the index of the second variable
#' @slot sourceName the name of the second variable
#' @slot condSetInx the indexes of variables we condition on
#' @slot condSetName the names of variables we condition on
#' @slot pValue the associated p value
#' @slot testType the type of the conditional independence test performed
#' @slot reliable if this appears to be a reliable test of conditional independence
#'
#' @export
setClass("CITestResult",
	representation = representation(
		targetInx = "numeric",
		targetName = "character",
		sourceInx = "numeric",
		sourceName = "character",
		condSetInx = "numeric",
		condSetName = "character",
		pValue = "numeric",
		testType = "character",
		reliable = "logical"
	)
)


#' An edge in an DDGraph
#'
#' This class represents an edge in an Direct Dependence Graph. It is normally found in the
#' \code{DDGraph::edges} list. It records the source and target nodes for the edge, the
#' edge type, as well as the conditional independence tests it represents. 
#'
#' @slot fromInx the index of the first variable from which the edge goes
#' @slot fromName the name of the first variable from which the edge goes
#' @slot toInx the index of the second variable to which the edge goes
#' @slot toName the name of the second variable to which the edge goes
#' @slot ciTests a list of associated \code{CITestResult} objects
#' @slot type type of edge: "directed", "undirected", "bidirectional", "dashed"
#'
#' @export
setClass("DDGraphEdge",
	representation = representation(
		fromInx = "numeric",
		fromName = "character",
		toInx = "numeric",
		toName = "character",
		ciTests = "list",
		type = "character"
	)
)

#' NCPC resampling robustness
#'
#' Data class that stores the robustness information associated with an NCPC result from
#' resampling runs (bootstrap of jackknifing). It contains the results from the resampling
#' runs as well as summary statistics. The \code{final.calls} slot contains the final
#' assigned types based on resampling. 
#'
#' @slot dataset the associated DDDataSet object
#' @slot raw the raw data from the robustness analysis         
#' @slot params the parameters used to generate the data (including the resampling method)
#' @slot tables the frequencies of assigning each variable to a class
#' @slot runs the number of resampling runs
#' @slot enriched.pss the table with reports for consistently enriched variables split 
#        into the three classes: direct, joint, indirect
#' @slot enriched.ps the table with reports for consistently enriched variable split
#'       into two classes: directAndJoint, indirect
#' @slot not.enriched the table with reports for the consistently not enriched variables
#' @slot final.calls the table with finals calls for types of variables
#'
#' @export
setClass("NCPCRobustness",
	representation = representation(
		dataset = "DDDataSet",
		raw = "list",
		params = "list",
		tables = "list",
		runs = "numeric",		
		enriched.pss = "data.frame",
		enriched.ps = "data.frame",
		not.enriched = "data.frame",
		final.calls = "data.frame"
	)
)

Try the ddgraph package in your browser

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

ddgraph documentation built on Nov. 17, 2017, 10:50 a.m.