Skip to content

Commit

Permalink
release v0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ShixiangWang committed Jan 30, 2019
1 parent ed6c0a9 commit 4d6ad0c
Show file tree
Hide file tree
Showing 42 changed files with 263 additions and 407 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export(get_matrix)
export(hello)
export(prepare_copynumber)
export(read_copynumber)
export(read_maf)
export(read_variation)
export(sig_assign_samples)
export(sig_estimate)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# sigminer v0.1.5

* update intro for package
* update introduction for package `sigminer`
* fix text problem provided by CRAN check team
* add `sig_get_similarity` function
* add toy datasets & update examples
* fix typo in `sig_assign_samples`
* export `read_maf`
* update README

# sigminer v0.1.4

Expand Down
98 changes: 30 additions & 68 deletions R/draw_series.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
#' @import ggplot2
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' # Load copy number object
#' load(system.file("extdata", "toy_copynumber.RData",
#' package = "sigminer", mustWork = TRUE))
#' # Plot distribution
#' draw_cn_distribution(cn)
#' draw_cn_distribution(cn, mode = "cd")
#' draw_cn_distribution(cn, mode = "cd", fill = TRUE)
#' }
#' @family copy number plot
draw_cn_distribution = function(data,
rm_normal = TRUE,
Expand Down Expand Up @@ -169,16 +165,10 @@ draw_cn_distribution = function(data,
#' @import ggplot2
#' @family copy number plot
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' cn_prepare = sig_prepare(cn)
#' # Load copy number prepare object
#' load(system.file("extdata", "toy_copynumber_prepare.RData",
#' package = "sigminer", mustWork = TRUE))
#' draw_cn_features(cn_prepare$features)
#' }
#' @export
#'
draw_cn_features = function(features, ylab = "", ...) {
Expand Down Expand Up @@ -243,16 +233,10 @@ draw_cn_features = function(features, ylab = "", ...) {
#' @import ggplot2
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' cn_prepare = sig_prepare(cn)
#' # Load copy number prepare object
#' load(system.file("extdata", "toy_copynumber_prepare.RData",
#' package = "sigminer", mustWork = TRUE))
#' draw_cn_components(cn_prepare$features, cn_prepare$components)
#' }
#' @family copy number plot
#'
draw_cn_components = function(features, components, ...) {
Expand Down Expand Up @@ -376,17 +360,10 @@ draw_cn_components = function(features, components, ...) {
#' @import ggplot2
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' cn_prepare = sig_prepare(cn)
#' res = sig_extract(cn_prepare$nmf_matrix, 3, mode = "copynumber", nrun = 5)
#' # Load copy number signature
#' load(system.file("extdata", "toy_copynumber_signature.RData",
#' package = "sigminer", mustWork = TRUE))
#' draw_sig_profile(res$nmfObj)
#' }
#' @family signature plot
draw_sig_profile = function(nmfObj, mode = c("copynumber", "mutation"),
y_scale = c("relative", "absolute"), font_scale = 1) {
Expand Down Expand Up @@ -481,17 +458,10 @@ draw_sig_profile = function(nmfObj, mode = c("copynumber", "mutation"),
#' @importFrom grDevices rainbow
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' cn_prepare = sig_prepare(cn)
#' res = sig_extract(cn_prepare$nmf_matrix, 3, mode = "copynumber", nrun = 5)
#' # Load copy number signature
#' load(system.file("extdata", "toy_copynumber_signature.RData",
#' package = "sigminer", mustWork = TRUE))
#' draw_sig_activity(res$nmfObj)
#' }
#' @family signature plot
draw_sig_activity = function(nmfObj, mode = c("copynumber", "mutation"),
font_scale = 1, hide_samps = TRUE) {
Expand Down Expand Up @@ -574,14 +544,9 @@ draw_sig_activity = function(nmfObj, mode = c("copynumber", "mutation"),
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' cn_prepare = sig_prepare(cn)
#' res = sig_extract(cn_prepare$nmf_matrix, 3, mode = "copynumber", nrun = 5)
#' # Load copy number signature
#' load(system.file("extdata", "toy_copynumber_signature.RData",
#' package = "sigminer", mustWork = TRUE))
#' sig_activity = sig_get_activity(res$nmfObj)
#' sig_cor = sig_get_correlation(sig_activity)
#' draw_sig_corrplot(sig_cor)
Expand Down Expand Up @@ -622,23 +587,20 @@ draw_sig_corrplot = function(mat_list, order = "original", type = "lower",
#' @import ggplot2
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' cn_prepare = sig_prepare(cn)
#' res = sig_extract(cn_prepare$nmf_matrix, 3, mode = "copynumber", nrun = 5)
#' subtypes = sig_assign_samples(res$nmfObj)
#' # Load copy number signature
#' load(system.file("extdata", "toy_copynumber_signature.RData",
#' package = "sigminer", mustWork = TRUE))
#' # Assign samples to clusters
#' subtypes = sig_assign_samples(res$nmfObj, type = "samples")
#'
#' set.seed(1234)
#' # Add custom groups
#' subtypes$new_group = sample(c("1", "2","3", "4"), size = nrow(subtypes), replace = TRUE)
#' # Summarize subtypes
#' subtypes.sum = sig_summarize_subtypes(subtypes[, -1], col_subtype = "nmf_subtypes",
#' cols_to_summary = colnames(subtypes[, -1])[-1],
#' type = c("co", "ca"), verbose = TRUE)
#' plot_list = draw_subtypes_comparison(subtypes.sum)
#' }
#' cols_to_summary = colnames(subtypes[, -1])[c(-1,-2)],
#' type = c("co", "ca"), verbose = TRUE)
#' draw_subtypes_comparison(subtypes.sum)
#' @family signature plot
draw_subtypes_comparison = function(subtype_summary,
xlab = "subtype", ylab_co = NA,
Expand Down
39 changes: 16 additions & 23 deletions R/get_series.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@
#' @return a `list`
#' @export
#' @examples
#' \donttest{
#' extdata_dir = system.file("extdata", package = "sigminer", mustWork = TRUE)
#' cp = read_copynumber(extdata_dir, pattern = "txt", genome_build = "hg19")
#' cn_list = get_cnlist(cp)
#' }
#' @family internal calculation function series

get_cnlist = function(CopyNumber) {
Expand Down Expand Up @@ -75,12 +73,10 @@ get_cnlist = function(CopyNumber) {
#' @import foreach
#' @export
#' @examples
#' \donttest{
#' extdata_dir = system.file("extdata", package = "sigminer", mustWork = TRUE)
#' cp = read_copynumber(extdata_dir, pattern = "txt", genome_build = "hg19")
#' cn_list = get_cnlist(cp)
#' # Load copy number list
#' load(system.file("extdata", "toy_cnlist.RData",
#' package = "sigminer", mustWork = TRUE))
#' cn_features = get_features(cn_list, cores = 1)
#' }
#' @family internal calculation function series

get_features = function(CN_data,
Expand Down Expand Up @@ -179,10 +175,9 @@ get_features = function(CN_data,
#' @export
#' @examples
#' \donttest{
#' extdata_dir = system.file("extdata", package = "sigminer", mustWork = TRUE)
#' cp = read_copynumber(extdata_dir, pattern = "txt", genome_build = "hg19")
#' cn_list = get_cnlist(cp)
#' cn_features = get_features(cn_list, cores = 1)
#' # Load copy number features
#' load(system.file("extdata", "toy_cn_features.RData",
#' package = "sigminer", mustWork = TRUE))
#' cn_components = get_components(cn_features)
#' }
#' @family internal calculation function series
Expand Down Expand Up @@ -311,14 +306,14 @@ get_components = function(CN_features,
#' @importFrom utils data download.file str
#' @export
#' @examples
#' \donttest{
#' extdata_dir = system.file("extdata", package = "sigminer", mustWork = TRUE)
#' cp = read_copynumber(extdata_dir, pattern = "txt", genome_build = "hg19")
#' cn_list = get_cnlist(cp)
#' cn_features = get_features(cn_list, cores = 1)
#' cn_components = get_components(cn_features)
#' # Load copy number components
#' load(system.file("extdata", "toy_cn_components.RData",
#' package = "sigminer", mustWork = TRUE))
#' # Load copy number features
#' load(system.file("extdata", "toy_cn_features.RData",
#' package = "sigminer", mustWork = TRUE))
#'
#' cn_matrix = get_matrix(cn_features, cn_components)
#' }
#' @family internal calculation function series
get_matrix = function(CN_features,
all_components = NULL,
Expand Down Expand Up @@ -393,12 +388,10 @@ get_matrix = function(CN_features,
#' @return a data table
#' @export
#' @examples
#' \donttest{
#' extdata_dir = system.file("extdata", package = "sigminer", mustWork = TRUE)
#' cp = read_copynumber(extdata_dir, pattern = "txt", genome_build = "hg19")
#' cn_list = get_cnlist(cp)
#' # Load copy number list
#' load(system.file("extdata", "toy_cnlist.RData",
#' package = "sigminer", mustWork = TRUE))
#' annot = get_LengthFraction(cn_list, seg_cols = c("chromosome", "start", "end", "segVal"))
#' }
#' @family internal calculation function series
get_LengthFraction = function(CN_data,
genome_build = c("hg19", "hg38"),
Expand Down
9 changes: 3 additions & 6 deletions R/prepare_series.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' # Load copy number object
#' load(system.file("extdata", "toy_copynumber.RData",
#' package = "sigminer", mustWork = TRUE))
#' cn_prepare = prepare_copynumber(cn)
#' }
#' @family signature analysis prepare function series
Expand Down
57 changes: 21 additions & 36 deletions R/read_series.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#' laml.maf = system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
#' laml = read_maf(maf = laml.maf)
#' }
#'
#' @export
#' @family read genomic variation data function series

read_maf = function(
maf, clinicalData = NULL, removeDuplicatedVariants = TRUE,
Expand Down Expand Up @@ -68,14 +69,12 @@ read_maf = function(
#' @return a [CopyNumber] object
#' @export
#' @examples
#' \donttest{
#' load(system.file("extdata", "example_cn_list.RData",
#' # Load toy dataset of absolute copynumber profile
#' load(system.file("extdata", "toy_segTab.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' }
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19", complement = FALSE, verbose = TRUE)
#' @family read genomic variation data function series
read_copynumber = function(input,
pattern = NULL,
Expand Down Expand Up @@ -339,6 +338,9 @@ read_copynumber = function(input,
message(" Filter - ", nrow(dropoff_df))
}

# make sure seg value is integer
data_df[["segVal"]] = as.integer(round(data_df[["segVal"]]))

if (verbose) message("Anotating...")
annot = get_LengthFraction(data_df,
genome_build = genome_build,
Expand All @@ -350,27 +352,16 @@ read_copynumber = function(input,
genome_measure = genome_measure )

if (verbose) message("Done!")
if (is.null(clinical_data)) {
res = CopyNumber(
data = data_df,
summary.per.sample = sum_sample,
genome_build = genome_build,
genome_measure = genome_measure,
annotation = annot,
dropoff.segs = dropoff_df,
clinical.data = data.table::data.table()
)
} else {
res = CopyNumber(
data = data_df,
summary.per.sample = sum_sample,
genome_build = genome_build,
genome_measure = genome_measure,
annotation = annot,
dropoff.segs = dropoff_df,
clinical.data = data.table::as.data.table(clinical_data)
)
}

res = CopyNumber(
data = data_df,
summary.per.sample = sum_sample,
genome_build = genome_build,
genome_measure = genome_measure,
annotation = annot,
dropoff.segs = dropoff_df,
clinical.data = data.table::as.data.table(clinical_data)
)

res = validate_segTab(res, verbose = verbose)
res
Expand Down Expand Up @@ -415,20 +406,14 @@ validate_segTab = function(object, verbose = FALSE){
#' @return a [GenomicVariation] object
#' @export
#' @examples
#' \donttest{
#' # Read MAF
#' laml.maf = system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
#' laml = read_maf(maf = laml.maf)
#' # Read absolute copy number profile
#' load(system.file("extdata", "example_cn_list.RData",
#' # Load copy number object
#' load(system.file("extdata", "toy_copynumber.RData",
#' package = "sigminer", mustWork = TRUE))
#' segTabs = data.table::rbindlist(tcga_segTabs, idcol = "sample")
#' cn = read_copynumber(segTabs,
#' seg_cols = c("chromosome", "start", "end", "segVal"),
#' genome_build = "hg19")
#' # Combine as GenomicVariation object
#' gv = read_variation(cn, laml)
#' }
#' @family read genomic variation data function series
read_variation = function(copynumber, maf, clinical_data = NULL) {

Expand Down
Loading

0 comments on commit 4d6ad0c

Please sign in to comment.