Skip to content

Commit 880d73b

Browse files
author
Charles Plessy
committed
Remove the returnInterquantileWidth option.
Closes #114
1 parent 9639a9b commit 880d73b

7 files changed

+47
-114
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ BACKWARDS-INCOMPATIBLE CHANGES
44

55
- Remove `CTSSclusteringMethod()` function and stop recording clustering
66
method name.
7+
- Remove `returnInterquantileWidth` argument of functions and always return
8+
that width when quantile information is provided. Closes #114
79

810
NEW FEATURES
911

R/AggregationMethods.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ setMethod( "aggregateTagClusters", "CAGEr"
102102
# Prepare the GRangesList object containing the TCs.
103103
if (all( !is.null(qLow), !is.null(qUp))) {
104104
# If using quantiles, correct start and end.
105-
TC.list <- tagClustersGR(object, returnInterquantileWidth = TRUE, qLow = qLow, qUp = qUp)
105+
TC.list <- tagClustersGR(object, qLow = qLow, qUp = qUp)
106106
# Define start and and according to quantile positions.
107107
# Quantile coordinates are relative to start position: a value of "1" means
108108
# "first base of the cluster". Therefore, 1 base must be subtracted in the

R/ExportMethods.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ setMethod( "plotInterquantileWidth", "CAGEexp"
264264

265265
# Extract a list of data frames in "long" format for ggplot
266266
iqwidths <- lapply(seq_along(sampleLabels(object)), function(x) {
267-
gr <- getClustFun(object, x, returnInterquantileWidth = TRUE, qLow = qLow, qUp = qUp)
267+
gr <- getClustFun(object, x, qLow = qLow, qUp = qUp)
268268
gr <- gr[score(gr) >= tpmThreshold]
269269
data.frame(
270270
sampleName = sampleLabels(object)[[x]],
@@ -482,7 +482,7 @@ setMethod( "exportToTrack", "CAGEexp"
482482
, CTSS = if (oneTrack) { CTSScoordinatesGR(object)
483483
} else { CTSStagCountGR(object, samples = "all") }
484484
, tagClusters = tagClustersGR( object, qLow = qLow, qUp = qUp)
485-
, consensusClusters = consensusClustersGR(object, qLow = qLow, qUp = qUp, returnInterquantileWidth = ifelse(is.null(qLow), FALSE, TRUE))) # See issue 108
485+
, consensusClusters = consensusClustersGR(object, qLow = qLow, qUp = qUp))
486486

487487
exportToTrack( clusters, qLow = qLow, qUp = qUp
488488
, colorByExpressionProfile = colorByExpressionProfile

R/GetMethods.R

+22-47
Original file line numberDiff line numberDiff line change
@@ -398,20 +398,17 @@ setMethod( "CTSSnormalizedTpmGR", "CAGEexp", function (object, samples) {
398398
#' extract tag clusters. If `samples = NULL`, a list of all the clusters for
399399
#' each sample is returned.
400400
#'
401-
#' @param returnInterquantileWidth Return the interquantile width for each tag cluster.
402-
#'
403401
#' @param qLow,qUp Position of which quantile should be used as a left (lower)
404402
#' or right (upper) boundary (for `qLow` and `qUp` respectively) when
405403
#' calculating interquantile width. Default value `NULL` results in using the
406-
#' start coordinate of the cluster. Used only when
407-
#' `returnInterquantileWidth = TRUE`, otherwise ignored.
404+
#' start coordinate of the cluster.
408405
#'
409406
#' @return Returns a `GRangesList` or a `TagClusters` object with genomic coordinates,
410407
#' position of dominant TSS, total CAGE signal and additional information for
411-
#' all TCs from specified CAGE dataset (sample). If
412-
#' `returnInterquantileWidth = TRUE`, interquantile width for each TC is also
413-
#' calculated using provided quantile positions. The [`S4Vectors::metadata`]
414-
#' slot of the object contains a copy of the `CAGEexp` object's _column data_.
408+
#' all TCs from specified CAGE dataset (sample). If quantile information is
409+
#' provided, interquantile width for each TC is also calculated. The
410+
#' [`S4Vectors::metadata`] slot of the object contains a copy of the `CAGEexp`
411+
#' object's _column data_.
415412
#'
416413
#' @author Vanja Haberle
417414
#' @author Charles Plessy
@@ -421,21 +418,18 @@ setMethod( "CTSSnormalizedTpmGR", "CAGEexp", function (object, samples) {
421418
#' @export
422419
#'
423420
#' @examples
424-
#' tagClustersGR( exampleCAGEexp, "Zf.high", TRUE, 0.1, 0.9 )
425-
#' tagClustersGR( exampleCAGEexp, 1
426-
#' , returnInterquantileWidth = TRUE, qLow = 0.1, qUp = 0.9 )
421+
#' tagClustersGR( exampleCAGEexp, "Zf.high", 0.1, 0.9 )
422+
#' tagClustersGR( exampleCAGEexp, 1, qLow = 0.1, qUp = 0.9 )
427423
#' tagClustersGR( exampleCAGEexp )@metadata$colData
428424
#'
429425
#' @export
430426

431427
setGeneric( "tagClustersGR"
432-
, function( object, sample = NULL
433-
, returnInterquantileWidth = FALSE, qLow = NULL, qUp = NULL) {
428+
, function( object, sample = NULL, qLow = NULL, qUp = NULL) {
434429
if (is.null(sample)) {
435430
tc.list <- GRangesList( lapply( sampleLabels(object)
436431
, tagClustersGR
437432
, object = object
438-
, returnInterquantileWidth = returnInterquantileWidth
439433
, qLow = qLow, qUp = qUp))
440434
names(tc.list) <- sampleLabels(object)
441435
metadata(tc.list)$colData <- colData(object)
@@ -448,15 +442,12 @@ setGeneric( "tagClustersGR"
448442
#' @rdname tagClusters
449443

450444
setMethod( "tagClustersGR", "CAGEexp"
451-
, function (object, sample, returnInterquantileWidth, qLow, qUp) {
445+
, function (object, sample, qLow, qUp) {
452446
tc <- metadata(object)$tagClusters[[sample]]
453447
if (is.null(tc))
454448
stop( "No clusters found, run ", sQuote("clusterCTSS"), " first." , call. = FALSE)
455449

456-
if (returnInterquantileWidth) {
457-
if (is.null(qLow) | is.null(qUp))
458-
stop( "No quantiles specified! Set the ", sQuote("qLow")
459-
, " and ", sQuote("qUp"), "arguments.")
450+
if (! is.null(qLow) & ! is.null(qUp)) {
460451
qLowName <- paste0("q_", qLow)
461452
qUpName <- paste0("q_", qUp)
462453
if(! all( c(qLowName, qUpName) %in% colnames(mcols(tc))))
@@ -487,20 +478,9 @@ setMethod("filteredCTSSidx", "CAGEexp", function (object){
487478
#' @param object A [`CAGEr`] object.
488479
#'
489480
#' @param sample Optional. Label of the CAGE dataset (experiment, sample) for
490-
#' which to extract sample-specific information on consensus clusters.
491-
#' When no sample is specified (NULL), sample-agnostic information
492-
#' on consensus clusters is provided. This includes the `dominant_ctss`
493-
#' and `tpm.dominant_ctss` for each consensus cluster.
494-
#'
495-
#' @param returnInterquantileWidth Should the interquantile width of consensus
496-
#' clusters be returned? When `sample` argument is specified, the
497-
#' interquantile widths of the consensus clusters in that specified
498-
#' sample are returned, otherwise, the (sample-agnostic) interquantile
499-
#' width of the consensus cluster itself is returned.
481+
#' which to extract sample-specific information on consensus clusters.
500482
#'
501-
#' @param qLow,qUp Position of which quantile should be used as a left (lower)
502-
#' or right (upper) boundary when calculating interquantile width. Used
503-
#' only when `returnInterquantileWidth = TRUE`, otherwise ignored.
483+
#' @param qLow,qUp Lower and upper quantiles to compute interquantile width.
504484
#'
505485
#' @return `consensusClustersGR` returns a [`ConsensusClusters`] object, which
506486
#' wraps the [`GRanges`] class. The `score` columns indicates the
@@ -510,10 +490,10 @@ setMethod("filteredCTSSidx", "CAGEexp", function (object){
510490
#' NOT specified, total CAGE signal across all CAGE datasets (samples) is
511491
#' returned in the `tpm` column. When `sample` argument is specified, the `tpm`
512492
#' column contains CAGE signal of consensus clusters in that specific sample.
513-
#' When `returnInterquantileWidth = TRUE`, additional sample-specific information
514-
#' is returned, including position of the dominant TSS, and interquantile width
515-
#' of the consensus clusters in the specified sample or otherwise,
516-
#' sample-agnostic information is returned.
493+
#' In addition, sample-specific information is returned, including position of
494+
#' the dominant TSS, and (if applicable) interquantile width of the consensus
495+
#' clusters in the specified sample or otherwise, sample-agnostic information is
496+
#' returned.
517497
#'
518498
#' @author Vanja Haberle
519499
#' @author Charles Plessy
@@ -525,24 +505,22 @@ setMethod("filteredCTSSidx", "CAGEexp", function (object){
525505
#'
526506
#' @examples
527507
#' consensusClustersGR( exampleCAGEexp, sample = 2
528-
#' , returnInterquantileWidth = TRUE
529508
#' , qLow = 0.1, qUp = 0.9)
530509
#'
531510
#' @importFrom GenomicRanges granges
532511
#' @export
533512

534513
setGeneric( "consensusClustersGR"
535514
, function( object
536-
, sample = NULL
537-
, returnInterquantileWidth = FALSE
515+
, sample = NULL
538516
, qLow = NULL, qUp = NULL) {
539517
validSamples(object, sample)
540518
standardGeneric("consensusClustersGR")})
541519

542520
#' @rdname consensusClusters
543521

544522
setMethod( "consensusClustersGR", "CAGEexp"
545-
, function (object, sample, returnInterquantileWidth, qLow, qUp) {
523+
, function (object, sample, qLow, qUp) {
546524
cc <- rowRanges(consensusClustersSE(object))
547525
## Comment and edits added: 2022-OCT-06
548526
## If sample is NULL, provide sample-agnostic information.
@@ -554,12 +532,9 @@ setMethod( "consensusClustersGR", "CAGEexp"
554532
if (!is.null(qUp))
555533
mcols(cc)[[paste0("q_", qUp)]] <-
556534
consensusClustersQuantile(object, sample, qUp)
557-
if (returnInterquantileWidth == TRUE) {
558-
if (is.null(qLow) | is.null(qUp))
559-
stop( "Set ", sQuote("qLow"), " and ", sQuote("qUp")
560-
, " to specify the quantile positions used to calculate width.")
561-
mcols(cc)[["interquantile_width"]] = mcols(cc)[[paste0("q_", qUp )]] -
562-
mcols(cc)[[paste0("q_", qLow)]] + 1
535+
if (! is.null(qLow) & ! is.null(qUp)) {
536+
mcols(cc)[["interquantile_width"]] = mcols(cc)[[paste0("q_", qUp )]] -
537+
mcols(cc)[[paste0("q_", qLow)]] + 1
563538
}
564539
cc$tpm <- cc$score <- consensusClustersTpm(object)[,sample]
565540

@@ -570,7 +545,7 @@ setMethod( "consensusClustersGR", "CAGEexp"
570545
score(ctss) <- CTSSnormalizedTpmDF(object) |> rowSums.RleDataFrame()
571546
ctss <- ctss[ctss$filteredCTSSidx]
572547
cc <- .ctss_summary_for_clusters(ctss, cc, removeSingletons = FALSE)
573-
if(isTRUE(returnInterquantileWidth)) {
548+
if (! is.null(qLow) & ! is.null(qUp)) {
574549
qLowName <- paste0("q_", qLow)
575550
qUpName <- paste0("q_", qUp)
576551
mcols(cc)[["interquantile_width"]] <-

man/consensusClusters.Rd

+8-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tagClusters.Rd

+9-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/CAGEexp.Rmd

+3-7
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,7 @@ ce <- quantilePositions(ce, clusters = "tagClusters", qLow = 0.1, qUp = 0.9)
544544
Tag clusters and their interquantile width can be retrieved by calling `tagClusters` function:
545545

546546
```{r}
547-
tagClustersGR( ce, "Zf.unfertilized.egg"
548-
, returnInterquantileWidth = TRUE, qLow = 0.1, qUp = 0.9)
547+
tagClustersGR(ce, "Zf.unfertilized.egg", qLow = 0.1, qUp = 0.9)
549548
```
550549

551550
Once the cumulative distributions and the positions of quantiles have been calculated, the
@@ -608,17 +607,14 @@ different samples. Sample-specific information on consensus clusters can be ret
608607
tag clusters):
609608

610609
```{r}
611-
consensusClustersGR( ce, sample = "Zf.unfertilized.egg"
612-
, returnInterquantileWidth = TRUE, qLow = 0.1, qUp = 0.9)
610+
consensusClustersGR(ce, sample = "Zf.unfertilized.egg", qLow = 0.1, qUp = 0.9)
613611
```
614612

615613
This will, in addition to genomic coordinates of the consensus clusters, which are constant across all samples, also return the position of the dominant TSS, the CAGE signal (tpm) and the interquantile width specific for a given sample. Note that when specifying individual sample, only the consensus clusters that have some CAGE signal in that sample will be returned (which will be a subset of all consensus clusters).
616614
When setting `sample = NULL` sample-agnostic information per consensus cluster
617615
is provided.
618616
This includes the interquantile width and dominant TSS information for each
619-
consensus cluster independent of the samples.
620-
Again, specifying interquantile boundaries, qLow and qUp, has a similar
621-
behaviour for `returnInterquantileWidth = TRUE`.
617+
consensus cluster independent of the samples when specifying interquantile boundaries `qLow` and `qUp`.
622618

623619

624620

0 commit comments

Comments
 (0)