Browse code

changePostCutoff works for univariate peak calls without keep.posteriors=TRUE

ataudt authored on 18/04/2018 08:41:49
Showing 3 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: chromstaR
2 2
 Type: Package
3 3
 Title: Combinatorial and Differential Chromatin State Analysis for ChIP-Seq Data
4
-Version: 1.5.2
4
+Version: 1.5.3
5 5
 Author: Aaron Taudt, Maria Colome Tatche, Matthias Heinig, Minh Anh Nguyen
6 6
 Maintainer: Aaron Taudt <aaron.taudt@gmail.com>
7 7
 Description: This package implements functions for combinatorial and differential analysis of ChIP-seq data. It includes uni- and multivariate peak-calling, export to genome browser viewable files, and functions for enrichment analyses.
... ...
@@ -1,3 +1,11 @@
1
+CHANGES IN VERSION 1.5.3
2
+------------------------
3
+
4
+SIGNIFICANT USER-LEVEL CHANGES
5
+
6
+    o Function 'changePostCutoff()' works on univariate peak calls without posterior needing to be present.
7
+    
8
+    
1 9
 CHANGES IN VERSION 1.5.1
2 10
 ------------------------
3 11
 
... ...
@@ -448,13 +448,20 @@ changePostCutoff.univariate <- function(model, post.cutoff) {
448 448
     threshold <- post.cutoff
449 449
     model$post.cutoff <- post.cutoff
450 450
 
451
-    if (is.null(model$bins$posteriors)) stop("Cannot recalculate states because posteriors are missing. Run 'callPeaksUnivariate' again with option 'keep.posteriors' set to TRUE.")
451
+    if (is.null(model$bins$posteriors) & is.null(model$bins$posterior.modified)) stop("Cannot recalculate states because posteriors are missing. Run 'callPeaksUnivariate' again with option 'keep.posteriors' set to TRUE.")
452
+    
452 453
     ## Calculate states
453 454
     ptm <- startTimedMessage("Calculating states from posteriors ...")
454
-    states <- rep(NA,length(model$bins))
455
-    states[ model$bins$posteriors[,3]<threshold & model$bins$posteriors[,2]<=model$bins$posteriors[,1] ] <- 1
456
-    states[ model$bins$posteriors[,3]<threshold & model$bins$posteriors[,2]>model$bins$posteriors[,1] ] <- 2
457
-    states[ model$bins$posteriors[,3]>=threshold ] <- 3
455
+    if (is.null(model$bins$posteriors)) {
456
+        warning("Using column 'posterior.modified' to recalculate states, there will be no state 'zero-inflation' in the output. Run 'callPeaksUnivariate' again with option 'keep.posteriors' set to TRUE to also obtain 'zero-inflation' states.")
457
+        states <- rep(2,length(model$bins))
458
+        states[ model$bins$posterior.modified>=threshold ] <- 3
459
+    } else {
460
+        states <- rep(NA,length(model$bins))
461
+        states[ model$bins$posteriors[,3]<threshold & model$bins$posteriors[,2]<=model$bins$posteriors[,1] ] <- 1
462
+        states[ model$bins$posteriors[,3]<threshold & model$bins$posteriors[,2]>model$bins$posteriors[,1] ] <- 2
463
+        states[ model$bins$posteriors[,3]>=threshold ] <- 3
464
+    }
458 465
     states <- state.labels[states]
459 466
     model$bins$state <- states
460 467
     stopTimedMessage(ptm)