Add number of mutations used for building targeting models in output

Issue #129 resolved
Julian Zhou created an issue

For the targeting model functions, it would be great to report the total number of mutations used for estimating the models. Currently, that number is not reported. 

Comments from @Jason Vander Heiden

You can define a new class that inherits from `matrix` and use that as the return object, in the same way that a tibble is both a "tbl" and a "data.frame". For example:

> MM <- setClass("MM", slots=c("count"), contains="matrix")
> x <- MM(data=1:9, nrow=3)
> x@count <- 50

> x[1, ]
[1] 1 4 7

> is(x, "matrix")
[1] TRUE

Thus, MM is a matrix with an extra slot `count`. Which you can access in the usual way and add an easy access method, if you want. For example, using the `summary` generic (like we do for `plot`):

> setMethod("summary", signature=c("MM"), function(object, ...) { cat("Count:", object@count) })
> summary(x)
Count: 50

Comments (3)

  1. Log in to comment