Skip to content

Commit

Permalink
fix broken plotting index
Browse files Browse the repository at this point in the history
  • Loading branch information
nhejazi committed Feb 23, 2018
1 parent 208b919 commit fb64198
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ print.data_adapt <- function(x, ...) {
print(get_composition(x, type = "small")[[1]])
}

################################################################################

#' Method of \code{shinyprint} for objects of class \code{data_adapt}
#'
#' Provides HTML-based printing utility for examining data-adaptive statistics
Expand Down Expand Up @@ -71,6 +73,7 @@ shinyprint.data_adapt <- function(x) {
))
}

################################################################################

#' Generic plot method for data_adapt class
#'
Expand Down Expand Up @@ -99,39 +102,42 @@ plot.data_adapt <- function(x, ..., plot_type = c("biomarker", "adapt_param")) {

mean_rank_top <- x$mean_rank_top
prob_in_top <- x$prob_in_top

n_top.want <- length(top_index)

if ("biomarker" %in% plot_type) {
# Plot sorted average CV-rank
plot(
mean_rank_top, ylab = "Mean CV-rank", pch = 20,
main = "Mean CV-rank of selected covariates \n (Smaller the better)"
main = "Mean CV-rank of selected covariates \n (smaller is better)"
)

calibrate::textxy(
(1:n_top.want) - 0.3, mean_rank_top + 0.5, top_index,
offset = .6
(seq_len(n_top.want)) - 0.3, mean_rank_top + 0.5, top_index,
offset = 0.6
)
abline(a = 0, b = 1, lty = 3)
}

if ("adapt_param" %in% plot_type) {
# plot sorted q-values, labeled with index
temp.top_index <- c(1:n_top.want)[order(q_value)]
temp.top_index <- c(seq_len(n_top.want))[order(q_value)]
plot(
sort(q_value),
pch = 20,
ylab = "q-value",
main = "q-value of selected covariates \n (Smaller the better)"
main = "q-value of selected covariates \n (smaller is better)"
)
calibrate::textxy(
(1:n_top.want) - 0.3, sort(q_value), temp.top_index,
(seq_len(n_top.want))[seq_len(x$n_top)] - 0.3, sort(q_value),
temp.top_index,
offset = 1
)
abline(h = 0.05, lty = 2)
}
}

################################################################################

#' Summary tables of the `adaptest` object
#'
#' @param object (data_adapt) object as returned by \code{adaptest}
Expand Down
4 changes: 2 additions & 2 deletions vignettes/differentialExpression.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ matrix. We demonstrate the necessary syntax for calling `adaptest` below:
adaptest_out <- adaptest(Y = Y,
A = A,
W = NULL,
n_top = 5,
n_top = 25,
n_fold = 3,
SL_lib = 'SL.glm',
SL_lib = c("SL.glm", "SL.mean"),
parameter_wrapper = adaptest::rank_DE,
absolute = FALSE,
negative = FALSE)
Expand Down

0 comments on commit fb64198

Please sign in to comment.