Skip to content

Commit

Permalink
Change calculateOverlapRegionsMetric() to calculateOverlapMetric(); v…
Browse files Browse the repository at this point in the history
…ersion update to 0.1.2
  • Loading branch information
adeschen committed Feb 10, 2021
1 parent 4e57f3c commit 86bf5cc
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 280 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: CNVMetrics
Type: Package
Version: 0.1.1
Date: 2021-01-29
Version: 0.1.2
Date: 2021-02-10
Title: Copy Number Variant Metrics
Description: Calculate similarity metrics to facilite copy number variant
comparison among samples and/or methods.
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

S3method(is,CNVMetric)
S3method(print,CNVMetric)
export(calculateOverlapRegionsMetric)
export(calculateOverlapMetric)
export(calculateWeightedEuclideanDistance)
export(plotOverlapMetric)
export(prepareInformation)
Expand Down
14 changes: 13 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# CNVMetrics 0.1.2

NEW FEATURES

* Added a `NEWS.md` file to track changes to the package.
* `plotOneOverlapMetric()` method enables plotting result of overlapping metric calculation.

SIGNIFICANT USER-VISIBLE CHANGES

* `calculateOverlapRegionsMetric()` method changed to `calculateOverlapMetric()`.


# CNVMetrics 0.1.1

NEW FEATURES

* Added a `NEWS.md` file to track changes to the package.
* `calculateOverlapRegionsMetric()` enables calculation of similarity metrics using overlapping amplified/deleted regions.
* `calculateOverlapRegionsMetric()` method enables calculation of similarity metrics using overlapping amplified/deleted regions.

SIGNIFICANT USER-VISIBLE CHANGES

Expand Down
1 change: 1 addition & 0 deletions R/CNVMetrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
#' Maintainer:
#' Astrid Deschênes <[email protected]>
#'
#' @encoding UTF-8
#' @keywords package
NULL
30 changes: 15 additions & 15 deletions R/CNVMetricsOverlapInternalMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@
#' state = c("AMPLIFICATION", "DELETION", "DELETION"))
#'
#' ## Calculate Sorensen metric for the amplified regions
#' CNVMetrics:::calculateOverlapMetric(sample01, sample02, method="sorensen",
#' type="AMPLIFICATION")
#' CNVMetrics:::calculateOneOverlapMetric(sample01, sample02,
#' method="sorensen", type="AMPLIFICATION")
#'
#' ## Calculate Szymkiewicz-Simpson metric for the amplified regions
#' ## Amplified regions of sample02 are a subset of the amplified
#' ## regions in sample01
#' CNVMetrics:::calculateOverlapMetric(sample01, sample02, method="szymkiewicz",
#' type="AMPLIFICATION")
#' CNVMetrics:::calculateOneOverlapMetric(sample01, sample02,
#' method="szymkiewicz", type="AMPLIFICATION")
#'
#' ## Calculate Sorensen metric for the deleted regions
#' CNVMetrics:::calculateOverlapMetric(sample01, sample02, method="sorensen",
#' type="DELETION")
#' CNVMetrics:::calculateOneOverlapMetric(sample01, sample02,
#' method="sorensen", type="DELETION")
#'
#' ## Calculate Szymkiewicz-Simpson metric for the deleted regions
#' CNVMetrics:::calculateOverlapMetric(sample01, sample02, method="szymkiewicz",
#' type="DELETION")
#' CNVMetrics:::calculateOneOverlapMetric(sample01, sample02,
#' method="szymkiewicz", type="DELETION")
#'
#' @author Astrid Deschênes
#' @encoding UTF-8
#' @keywords internal
calculateOverlapMetric <- function(sample01, sample02, method, type) {
calculateOneOverlapMetric <- function(sample01, sample02, method, type) {

sample01 <- sample01[sample01$state == type,]
sample02 <- sample02[sample02$state == type,]
Expand Down Expand Up @@ -246,7 +246,7 @@ calculateSzymkiewicz <- function(sample01, sample02) {
#' amplified/deleted regions.
#'
#' @param metric a \code{CNVMetric} object containing the metrics calculated
#' by \code{calculateOverlapRegionsMetric}.
#' by \code{calculateOverlapMetric}.
#'
#' @param type a \code{character} string indicating which graph to generate.
#' This should be (an unambiguous abbreviation of) one of
Expand Down Expand Up @@ -291,7 +291,7 @@ calculateSzymkiewicz <- function(sample01, sample02) {
#' state = c("AMPLIFICATION", "DELETION"))
#'
#' ## Calculating Sorensen metric
#' metric <- calculateOverlapRegionsMetric(demo, method="sorensen")
#' metric <- calculateOverlapMetric(demo, method="sorensen")
#'
#' ## Plot both amplification metrics using darkorange color
#' CNVMetrics:::plotOneOverlapMetric(metric, type="AMPLIFICATION",
Expand All @@ -314,8 +314,8 @@ plotOneOverlapMetric <- function(metric, type, colorRange, show_colnames, ...)

## Prepare main title (might not be used if main argument given by user)
metricInfo <- switch(attributes(metric)$metric,
"szymkiewicz"="Szymkiewicz-Simpson",
"sorensen"="Sorensen")
"szymkiewicz"="Szymkiewicz-Simpson",
"sorensen"="Sorensen")
metricInfo <- paste0(type, " - ", metricInfo, " metric")

## Create heatmap
Expand All @@ -328,10 +328,10 @@ plotOneOverlapMetric <- function(metric, type, colorRange, show_colnames, ...)

if (!hasArg("main")) {
pheatmap(metricMat, main=metricInfo, show_colnames=show_colnames,
color=colors, breaks=breaks, ...)[[4]]
color=colors, breaks=breaks, ...)[[4]]
} else {
pheatmap(metricMat, show_colnames=show_colnames,
color=colors, breaks=breaks, ...)[[4]]
color=colors, breaks=breaks, ...)[[4]]
}
} else {
if (!hasArg("main")) {
Expand Down
12 changes: 6 additions & 6 deletions R/CNVMetricsOverlapMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@
#' state = c("AMPLIFICATION", "DELETION"))
#'
#' ## Calculating Sorensen metric
#' calculateOverlapRegionsMetric(demo, method="sorensen")
#' calculateOverlapMetric(demo, method="sorensen")
#'
#' ## Calculating Szymkiewicz-Simpson metric
#' calculateOverlapRegionsMetric(demo, method="szymkiewicz")
#' calculateOverlapMetric(demo, method="szymkiewicz")
#'
#' @author Astrid Deschênes, Pascal Belleau
#' @import GenomicRanges
#' @encoding UTF-8
#' @export
calculateOverlapRegionsMetric <- function(segmentData,
calculateOverlapMetric <- function(segmentData,
method=c("sorensen", "szymkiewicz")) {

method <- match.arg(method)
Expand Down Expand Up @@ -143,7 +143,7 @@ calculateOverlapRegionsMetric <- function(segmentData,

for(i in seq_len(nb)[-1]) {
for(j in seq_len(i-1)) {
dataTMP[i, j] <- calculateOverlapMetric(
dataTMP[i, j] <- calculateOneOverlapMetric(
sample01=segmentData[[names[i]]],
sample02=segmentData[[names[j]]],
method=method, type=type)
Expand All @@ -169,7 +169,7 @@ calculateOverlapRegionsMetric <- function(segmentData,
#' heatmap related to amplified, deleted regions or both.
#'
#' @param metric a \code{CNVMetric} object containing the metrics calculated
#' by \code{calculateOverlapRegionsMetric}.
#' by \code{calculateOverlapMetric}.
#'
#' @param type a \code{character} string indicating which graph to generate.
#' This should be (an unambiguous abbreviation of) one of "\code{BOTH}",
Expand Down Expand Up @@ -215,7 +215,7 @@ calculateOverlapRegionsMetric <- function(segmentData,
#' state = c("AMPLIFICATION", "DELETION"))
#'
#' ## Calculating Sorensen metric
#' metric <- calculateOverlapRegionsMetric(demo, method="sorensen")
#' metric <- calculateOverlapMetric(demo, method="sorensen")
#'
#' ## Plot both amplification and deletion metrics
#' plotOverlapMetric(metric, type="BOTH")
Expand Down
1 change: 1 addition & 0 deletions man/CNVMetrics-package.Rd

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

101 changes: 101 additions & 0 deletions man/calculateOneOverlapMetric.Rd

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

Loading

0 comments on commit 86bf5cc

Please sign in to comment.