From a5de2cbaf9b810b0fae26cb826546b194c280259 Mon Sep 17 00:00:00 2001 From: ShixiangWang Date: Tue, 8 Jan 2019 11:57:39 +0800 Subject: [PATCH] v0.1.1 --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 6 ++++++ R/class.R | 36 ++++++++++++++++++++++++++++++++++++ R/read_series.R | 2 ++ man/CopyNumber-class.Rd | 4 ++++ man/subset.CopyNumber.Rd | 26 ++++++++++++++++++++++++++ 7 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 man/subset.CopyNumber.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 05c79b99..d57d058c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sigminer Title: Capture Genomic Variation Signatures using 'NMF' -Version: 0.1.0 +Version: 0.1.1 Authors@R: person(given = "Shixiang", family = "Wang", diff --git a/NAMESPACE b/NAMESPACE index ce0d687d..b03ac90b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method(subset,CopyNumber) export("%>%") export(CopyNumber) export(GenomicVariation) diff --git a/NEWS.md b/NEWS.md index 2dc09243..3cd0cc8e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ + +# sigminer 0.1.1 + +* add `subset.CopyNumber()` for subset CopyNumber object +* add `genome_measure` slot for CopyNumber object + # sigminer 0.1.0 * Added a `NEWS.md` file to track changes to the package. diff --git a/R/class.R b/R/class.R index 46c7ef84..c88f603b 100644 --- a/R/class.R +++ b/R/class.R @@ -47,6 +47,9 @@ setMethod( #' @slot data data.table of absolute copy number calling. #' @slot summary.per.sample data.table of copy number variation summary per sample. #' @slot genome_build genome build version, should be one of 'hg19' or 'hg38'. +#' @slot genome_measure Set 'called' will use autosomo called segments size to compute total size +#' for CNA burden calculation, this option is useful for WES and target sequencing. +#' Set 'wg' will autosome size from genome build, this option is useful for WGS, SNP etc.. #' @slot annotation data.table of annotation for copy number segments. #' @slot dropoff.segs data.table of copy number segments dropped from raw input. #' @slot clinical.data data associated with each sample in copy number profile. @@ -58,6 +61,7 @@ CopyNumber = setClass( data = "data.table", summary.per.sample = 'data.table', genome_build = "character", + genome_measure = "character", annotation = "data.table", dropoff.segs = "data.table", clinical.data = "data.table" @@ -100,3 +104,35 @@ setMethod( str(object, max.level = 2) } ) + + + +# Methods ----------------------------------------------------------------- + +#' Subsetting CopyNumber object +#' +#' Subset data slot of [CopyNumber] object, un-selected rows will move to +#' dropoff.segs slot, annotation slot will update in the same way. +#' +#' @param x a [CopyNumber] object to be subsetted. +#' @param subset logical expression indicating rows to keep. +#' @param ... further arguments to be passed to or from other methods. +#' Useless here. +#' @author Shixiang Wang +#' @return a [CopyNumber] object +#' @export +subset.CopyNumber = function(x, subset = TRUE, ...) { + data = x@data + enclos = parent.frame() + subset = substitute(subset) + row_selector = eval(subset, data, enclos) + + x@dropoff.segs = rbind(x@dropoff.segs, data[!row_selector]) + x@data = data[row_selector] + x@annotation = x@annotation[row_selector] + + x@summary.per.sample = get_cnsummary_sample(x@data, + genome_build = x@genome_build, + genome_measure = x@genome_measure) + x +} diff --git a/R/read_series.R b/R/read_series.R index 31e371b3..767e26dc 100644 --- a/R/read_series.R +++ b/R/read_series.R @@ -346,6 +346,7 @@ read_copynumber = function(input, 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() @@ -355,6 +356,7 @@ read_copynumber = function(input, 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) diff --git a/man/CopyNumber-class.Rd b/man/CopyNumber-class.Rd index 79ae4a49..bee36b38 100644 --- a/man/CopyNumber-class.Rd +++ b/man/CopyNumber-class.Rd @@ -17,6 +17,10 @@ S4 class for storing summarized absolute copy number profile. \item{\code{genome_build}}{genome build version, should be one of 'hg19' or 'hg38'.} +\item{\code{genome_measure}}{Set 'called' will use autosomo called segments size to compute total size +for CNA burden calculation, this option is useful for WES and target sequencing. +Set 'wg' will autosome size from genome build, this option is useful for WGS, SNP etc..} + \item{\code{annotation}}{data.table of annotation for copy number segments.} \item{\code{dropoff.segs}}{data.table of copy number segments dropped from raw input.} diff --git a/man/subset.CopyNumber.Rd b/man/subset.CopyNumber.Rd new file mode 100644 index 00000000..79ec0770 --- /dev/null +++ b/man/subset.CopyNumber.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/class.R +\name{subset.CopyNumber} +\alias{subset.CopyNumber} +\title{Subsetting CopyNumber object} +\usage{ +\method{subset}{CopyNumber}(x, subset = TRUE, ...) +} +\arguments{ +\item{x}{a \link{CopyNumber} object to be subsetted.} + +\item{subset}{logical expression indicating rows to keep.} + +\item{...}{further arguments to be passed to or from other methods. +Useless here.} +} +\value{ +a \link{CopyNumber} object +} +\description{ +Subset data slot of \link{CopyNumber} object, un-selected rows will move to +dropoff.segs slot, annotation slot will update in the same way. +} +\author{ +Shixiang Wang +}