Skip to content

Commit

Permalink
🆕 Add show_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
ShixiangWang committed May 26, 2020
1 parent 907f4d4 commit 04f2e25
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export(show_cn_profile)
export(show_cosmic_sig_profile)
export(show_group_comparison)
export(show_group_mapping)
export(show_groups)
export(show_sig_bootstrap_error)
export(show_sig_bootstrap_exposure)
export(show_sig_bootstrap_stability)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# sigminer 1.0.6

- Added `show_groups()` to show the signature contribution in each group from `get_groups()`.
- Expanded clustering in `get_groups()` to result of `sig_fit()`.
- Properly handled null-count samples in `sig_fit_bootstrap_batch()`.
- Added strand bias labeling for INDEL.
Expand Down
2 changes: 1 addition & 1 deletion R/get_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#' # Use k-means clustering
#' get_groups(sig, method = "k-means")
#' }
#' @seealso [NMF::predict()]
#' @seealso [NMF::predict()], [show_groups].
get_groups <- function(Signature,
method = c("consensus", "k-means", "exposure", "samples"),
n_cluster = NULL,
Expand Down
17 changes: 17 additions & 0 deletions R/show_groups.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' Show Signature Contribution in Clusters
#'
#' See example section in [sig_fit()] for an examples.
#'
#' @param grp_dt a result `data.table` from [get_groups].
#' @param ... parameters passing to [legend()], e.g. `x = "topleft"`.
#'
#' @return nothing.
#' @export
#' @seealso [get_groups], [sig_fit].
show_groups <- function(grp_dt, ...) {
x2 <- attr(grp_dt, "map_table")
if (is.null(x2)) {
send_stop("Wrong input, should be result from 'get_groups'.")
}
barplot(t(x2), legend.text = TRUE, args.legend = list(...))
}
4 changes: 4 additions & 0 deletions R/sig_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
#' H_infer
#' H
#'
#' ## Get clusters/groups
#' z <- get_groups(H_infer, method = "k-means")
#' show_groups(z)
#'
#' H_dt <- sig_fit(V, W, return_class = "data.table")
#' H_dt
#'
Expand Down
2 changes: 1 addition & 1 deletion man/get_groups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/show_groups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/sig_fit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion tests/testthat/test-roxytest-testexamples-sig_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

context("File R/sig_fit.R: @testexamples")

test_that("Function sig_fit() @ L93", {
test_that("Function sig_fit() @ L97", {

W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
colnames(W) <- c("sig1", "sig2")
Expand All @@ -19,6 +19,10 @@ test_that("Function sig_fit() @ L93", {
H_infer
H

## Get clusters/groups
z <- get_groups(H_infer, method = "k-means")
show_groups(z)

H_dt <- sig_fit(V, W, return_class = "data.table")
H_dt

Expand Down

0 comments on commit 04f2e25

Please sign in to comment.