55# ' @slot parameters A list of parameters used in the analysis
66# ' @slot consensus A list containing consensus DEG results (e.g., from consensusList)
77# '
8- # ' @export
8+ # ' @importFrom methods new setClass setMethod
9+ # ' @exportClass ExpressionResultSet
10+
911setClass ("ExpressionResultSet ",
1012 slots = list (
11- results = " list" ,
12- methods = " character" ,
13- parameters = " list" ,
14- consensus = " list"
13+ results = " list" ,
14+ methods = " character" ,
15+ parameters = " list" ,
16+ consensus = " list"
1517 ))
1618
1719# ' Constructor for ExpressionResultSet
@@ -23,62 +25,68 @@ setClass("ExpressionResultSet",
2325# ' @return An ExpressionResultSet object
2426# ' @export
2527createExpressionResultSet <- function (results , methods , parameters = list ()) {
26- # Verifica se todos os elementos são data.frames ou NULL
27- if (! all(sapply(results , function (x ) is.null(x ) || inherits(x , " data.frame" )))) {
28- stop(" All elements in 'results' must be data.frames or NULL." )
29- }
28+ # Verifica se todos os elementos são data.frames ou NULL
29+ if (! all(sapply(results , function (x ) is.null(x ) || inherits(x , " data.frame" )))) {
30+ stop(" All elements in 'results' must be data.frames or NULL." )
31+ }
3032
31- if (! is.character(methods )) {
32- stop(" 'methods' must be a character vector." )
33- }
33+ if (! is.character(methods )) {
34+ stop(" 'methods' must be a character vector." )
35+ }
3436
35- if (! is.list(parameters )) {
36- stop(" 'parameters' must be a list." )
37- }
37+ if (! is.list(parameters )) {
38+ stop(" 'parameters' must be a list." )
39+ }
3840
39- new(" ExpressionResultSet" ,
40- results = results ,
41- methods = methods ,
42- parameters = parameters )
41+ new(" ExpressionResultSet" ,
42+ results = results ,
43+ methods = methods ,
44+ parameters = parameters )
4345}
4446
4547
4648# ' Show method for ExpressionResultSet
4749# '
4850# ' @param object An ExpressionResultSet object
49- # ' @export
51+ # ' @importFrom methods setMethod show
52+ # ' @exportMethod show
53+ # ' @return Invisibly returns \code{NULL}. This method is called for its
54+ # ' side effect of printing a summary of the object to the console.
5055setMethod ("show ", "ExpressionResultSet", function(object) {
51- cat(" ExpressionResultSet object\n " )
52- cat(" Methods executed:" , paste(object @ methods , collapse = " , " ), " \n " )
53- cat(" Results available:" , length(object @ results ), " data.frames\n " )
56+ cat(" ExpressionResultSet object\n " )
57+ cat(" Methods executed:" , paste(object @ methods , collapse = " , " ), " \n " )
58+ cat(" Results available:" , length(object @ results ), " data.frames\n " )
5459
55- if (length(object @ consensus ) == 0 ) {
56- cat(" Consensus: not computed or empty.\n " )
57- } else {
58- cat(" Consensus: available (" , length(object @ consensus ), " gene(s) listed)\n " )
59- }
60+ if (length(object @ consensus ) == 0 ) {
61+ cat(" Consensus: not computed or empty.\n " )
62+ } else {
63+ cat(" Consensus: available (" , length(object @ consensus ), " gene(s) listed)\n " )
64+ }
6065})
6166
6267# ' Summary method for ExpressionResultSet
6368# '
6469# ' @param object An ExpressionResultSet object
65- # ' @export
70+ # ' @exportMethod summary
71+ # ' @param object An ExpressionResultSet object
72+ # ' @return Invisibly returns \code{NULL}. This method is used for its
73+ # ' side effect of printing a summary to the console.
6674setMethod ("summary ", "ExpressionResultSet", function(object) {
67- cat(" Summary of ExpressionResultSet\n " )
68- cat(" ---------------------------------\n " )
69- cat(" Methods used:" , paste(object @ methods , collapse = " , " ), " \n " )
75+ cat(" Summary of ExpressionResultSet\n " )
76+ cat(" ---------------------------------\n " )
77+ cat(" Methods used:" , paste(object @ methods , collapse = " , " ), " \n " )
7078
71- nTables <- length(object @ results )
72- cat(" Number of result tables:" , nTables , " \n " )
79+ nTables <- length(object @ results )
80+ cat(" Number of result tables:" , nTables , " \n " )
7381
74- if (nTables > 0 ) {
75- sizes <- sapply(object @ results , function (x ) if (is.null(x )) 0 else nrow(x ))
76- cat(" Average number of DEGs per method:" , round(mean(sizes ), 2 ), " \n " )
77- }
82+ if (nTables > 0 ) {
83+ sizes <- sapply(object @ results , function (x ) if (is.null(x )) 0 else nrow(x ))
84+ cat(" Average number of DEGs per method:" , round(mean(sizes ), 2 ), " \n " )
85+ }
7886
79- if (length(object @ consensus ) == 0 ) {
80- cat(" Consensus list is empty or not defined.\n " )
81- } else {
82- cat(" Number of genes in consensus:" , length(object @ consensus ), " \n " )
83- }
87+ if (length(object @ consensus ) == 0 ) {
88+ cat(" Consensus list is empty or not defined.\n " )
89+ } else {
90+ cat(" Number of genes in consensus:" , length(object @ consensus ), " \n " )
91+ }
8492})
0 commit comments