Browse code

Imports updated and dataType function added for SequenceData/Frame class

Felix Ernst authored on 10/07/2019 12:07:41
Showing12 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: RNAmodR
2 2
 Type: Package
3 3
 Title: Detection of post-transcriptional modifications in high throughput sequencing data
4
-Version: 0.99.29
4
+Version: 0.99.30
5 5
 Date: 2019-06-11
6 6
 Authors@R: c(person("Felix G.M.", 
7 7
                     "Ernst", 
... ...
@@ -17,7 +17,7 @@ Description: RNAmodR provides classes and workflows for loading/aggregation data
17 17
     modifications through analysis of specific patterns. In addition, utilities
18 18
     are provided to validate and visualize the results. The RNAmodR package
19 19
     provides a core functionality from which specific analysis strategies can
20
-    be easily implemented as seperate package.
20
+    be easily implemented as a seperate package.
21 21
 biocViews: 
22 22
     Software, Infrastructure, WorkflowStep, Visualization, Sequencing
23 23
 License: Artistic-2.0
... ...
@@ -37,12 +37,12 @@ Imports:
37 37
     grid,
38 38
     matrixStats,
39 39
     assertive,
40
-    XVector,
41 40
     BiocGenerics,
41
+    XVector,
42
+    Biostrings,
42 43
     BiocParallel,
43 44
     GenomicFeatures,
44 45
     GenomicAlignments,
45
-    Biostrings,
46 46
     GenomeInfoDb,
47 47
     rtracklayer,
48 48
     Rsamtools,
... ...
@@ -55,7 +55,6 @@ Imports:
55 55
     reshape2,
56 56
     stringi,
57 57
     stringr,
58
-    dplyr,
59 58
     ROCR
60 59
 Suggests:
61 60
     BiocStyle,
... ...
@@ -120,6 +120,7 @@ exportMethods(settings)
120 120
 exportMethods(subsetByCoord)
121 121
 exportMethods(validAggregate)
122 122
 exportMethods(validModification)
123
+import(BiocGenerics)
123 124
 import(GenomicRanges)
124 125
 import(Gviz)
125 126
 import(S4Vectors)
... ...
@@ -137,9 +138,6 @@ importClassesFrom(IRanges,SplitDataFrameList)
137 138
 importClassesFrom(Rsamtools,BamFileList)
138 139
 importClassesFrom(Rsamtools,PileupFiles)
139 140
 importFrom(BSgenome,seqnames)
140
-importFrom(BiocGenerics,conditions)
141
-importFrom(BiocGenerics,path)
142
-importFrom(BiocGenerics,which)
143 141
 importFrom(BiocParallel,SerialParam)
144 142
 importFrom(BiocParallel,bplapply)
145 143
 importFrom(BiocParallel,bpmapply)
... ...
@@ -184,7 +182,6 @@ importFrom(Rsamtools,scanFa)
184 182
 importFrom(S4Vectors,splitAsList)
185 183
 importFrom(biovizBase,getBioColor)
186 184
 importFrom(colorRamps,matlab.like)
187
-importFrom(dplyr,mutate_)
188 185
 importFrom(ggplot2,geom_raster)
189 186
 importFrom(ggplot2,ggplot)
190 187
 importFrom(grDevices,col2rgb)
... ...
@@ -197,7 +194,6 @@ importFrom(matrixStats,rowSds)
197 194
 importFrom(reshape2,dcast)
198 195
 importFrom(reshape2,melt)
199 196
 importFrom(rtracklayer,GFF3File)
200
-importFrom(stats,D)
201 197
 importFrom(stats,setNames)
202 198
 importFrom(stringi,stri_rand_strings)
203 199
 importFrom(stringr,str_detect)
... ...
@@ -337,7 +337,6 @@ S4Vectors::setValidity2(Class = "Modifier", .valid_Modifier)
337 337
 }
338 338
 
339 339
 #' @rdname Modifier-functions
340
-#' @importFrom BiocGenerics path
341 340
 setMethod(
342 341
   f = "show",
343 342
   signature = signature(object = "Modifier"),
... ...
@@ -231,7 +231,6 @@ NULL
231 231
 }
232 232
 
233 233
 #' @importFrom graphics par abline title legend plot.new
234
-#' @importFrom colorRamps matlab.like
235 234
 #' @importFrom ROCR prediction performance
236 235
 .plot_ROCR <- function(data, prediction.args, performance.args, plot.args,
237 236
                        score){
... ...
@@ -1,44 +1,6 @@
1 1
 #' @include RNAmodR.R
2 2
 NULL
3 3
 
4
-# error propagation ------------------------------------------------------------
5
-
6
-################################################################################
7
-# modified from Lee Pang, 2015,
8
-# (https://oddhypothesis.blogspot.com/2015/01/easy-error-propagation-in-r.html)
9
-# (https://www.r-bloggers.com/easy-error-propagation-in-r/)
10
-################################################################################
11
-
12
-#' @importFrom dplyr mutate_
13
-#' @importFrom stats D
14
-.mutate_with_error <- function(.data, f){
15
-  exprs = list(
16
-    # expression to compute new variable values
17
-    deparse(f[[3]]),
18
-    # expression to compute new variable errors
19
-    sprintf('sqrt(%s)',
20
-            paste(vapply(all.vars(f[[3]]),
21
-                         function(v) {
22
-                           dfdp = deparse(stats::D(f[[3]], 
23
-                                                   v))
24
-                           sprintf('(d%s*(%s))^2', 
25
-                                   v,
26
-                                   dfdp)
27
-                         },
28
-                         character(1)),
29
-                  collapse = '+'))
30
-  )
31
-  names(exprs) = c(
32
-    deparse(f[[2]]),
33
-    sprintf('d%s', deparse(f[[2]]))
34
-  )
35
-  if( nrow(.data) > 0 ){
36
-    # the standard evaluation alternative of mutate()
37
-    .data <- dplyr::mutate_(.data, .dots = exprs)
38
-  }
39
-  return(.data)
40
-}
41
-
42 4
 # construct GRanges object from found modifications ----------------------------
43 5
 
44 6
 #' @rdname RNAmodR-development
... ...
@@ -166,7 +166,6 @@ setMethod(f = "relistToClass",
166 166
 }
167 167
 
168 168
 #' @importFrom Rsamtools BamFileList 
169
-#' @importFrom BiocGenerics path
170 169
 .contains_only_bamfiles <- function(x){
171 170
   x <- unname(x)
172 171
   classNames <- vapply(x, function(z){class(z)[[1]]},character(1))
... ...
@@ -326,6 +326,7 @@ setMethod("compareByCoord",
326 326
 }
327 327
 
328 328
 #' @importFrom ggplot2 ggplot geom_raster
329
+#' @importFrom colorRamps matlab.like
329 330
 #' @importFrom reshape2 melt
330 331
 .plot_compare_ModifierSet_by_GRanges <- function(x, coord, normalize,  ...){
331 332
   args <- .norm_compare_plot_args(list(...))
... ...
@@ -65,10 +65,10 @@ NULL
65 65
 
66 66
 #' @import methods
67 67
 #' @import assertive
68
-#' @import XVector
69 68
 #' @import S4Vectors
70 69
 #' @import GenomicRanges
71
-#' @importFrom BiocGenerics which conditions
70
+#' @import BiocGenerics
71
+#' @import XVector
72 72
 #' @importFrom Biostrings DNAString RNAString DNAStringSet RNAStringSet getSeq
73 73
 #' @importFrom Modstrings ModRNAString ModRNAStringSet combineIntoModstrings
74 74
 #' shortName fullName
... ...
@@ -825,6 +825,11 @@ setMethod(f = "seqinfo",
825 825
 setMethod(f = "sequences", 
826 826
           signature = signature(x = "SequenceData"),
827 827
           definition = function(x){relist(sequences(unlist(x)),x)})
828
+#' @rdname SequenceData-functions
829
+#' @export
830
+setMethod(f = "dataType",
831
+          signature = signature(x = "SequenceData"),
832
+          definition = function(x){dataType(unlist(x))})
828 833
 
829 834
 # dummy functions --------------------------------------------------------------
830 835
 # this needs to be implemented by each subclass
... ...
@@ -256,6 +256,11 @@ setMethod(
256 256
   f = "seqinfo", 
257 257
   signature = signature(x = "SequenceDataFrame"),
258 258
   definition = function(x){x@seqinfo})
259
+#' @rdname SequenceData-functions
260
+#' @export
261
+setMethod(f = "dataType",
262
+          signature = signature(x = "SequenceDataFrame"),
263
+          definition = function(x){gsub("SequenceDataFrame","",class(x))})
259 264
 
260 265
 # internals --------------------------------------------------------------------
261 266
 
... ...
@@ -3,8 +3,7 @@ NULL
3 3
 
4 4
 # Annotation -------------------------------------------------------------------
5 5
 
6
-#' @importFrom rtracklayer GFF3File 
7
-#' @importFrom BiocGenerics path
6
+#' @importFrom rtracklayer GFF3File
8 7
 .norm_gff <- function(x, className, .xname = assertive::get_name_in_parent(x)){
9 8
   if(!is(x,"GFF3File")){
10 9
     x <- try(rtracklayer::GFF3File(x), silent = TRUE)
... ...
@@ -22,7 +21,6 @@ NULL
22 21
 }
23 22
 
24 23
 #' @importFrom GenomicFeatures makeTxDbFromGFF
25
-#' @importFrom BiocGenerics path
26 24
 # Returns a TxDb or a GRangesList object
27 25
 .norm_annotation <- function(annotation, className, 
28 26
                   .annotationname = assertive::get_name_in_parent(annotation)){
... ...
@@ -63,7 +61,6 @@ NULL
63 61
 # Sequences --------------------------------------------------------------------
64 62
 
65 63
 #' @importFrom Rsamtools FaFile
66
-#' @importFrom BiocGenerics path
67 64
 # Either return a FaFile or BSgenome object
68 65
 .norm_sequences <- function(seq, className){
69 66
   if(!is(seq,"FaFile") && !is(seq,"BSgenome")){
... ...
@@ -92,7 +89,6 @@ NULL
92 89
 SAMPLE_TYPES <- c("treated","control")
93 90
 
94 91
 #' @importFrom Rsamtools BamFileList
95
-#' @importFrom BiocGenerics path
96 92
 .norm_bamfiles <- function(x, className, 
97 93
                            .xname = assertive::get_name_in_parent(x)){
98 94
   if(is.list(x)){
... ...
@@ -13,6 +13,7 @@
13 13
 \alias{conditions,SequenceDataFrame-method}
14 14
 \alias{bamfiles,SequenceDataFrame-method}
15 15
 \alias{seqinfo,SequenceDataFrame-method}
16
+\alias{dataType,SequenceDataFrame-method}
16 17
 \alias{show,SequenceData-method}
17 18
 \alias{getData,SequenceData,BamFileList,GRangesList,XStringSet,ScanBamParam-method}
18 19
 \alias{bamfiles,SequenceData-method}
... ...
@@ -21,6 +22,7 @@
21 22
 \alias{replicates,SequenceData-method}
22 23
 \alias{seqinfo,SequenceData-method}
23 24
 \alias{sequences,SequenceData-method}
25
+\alias{dataType,SequenceData-method}
24 26
 \alias{show,SequenceDataSet-method}
25 27
 \alias{seqinfo,SequenceDataSet-method}
26 28
 \alias{names,SequenceDataSet-method}
... ...
@@ -56,6 +58,8 @@ replicates(x)
56 58
 
57 59
 \S4method{seqinfo}{SequenceDataFrame}(x)
58 60
 
61
+\S4method{dataType}{SequenceDataFrame}(x)
62
+
59 63
 \S4method{show}{SequenceData}(object)
60 64
 
61 65
 
... ...
@@ -74,6 +78,8 @@ replicates(x)
74 78
 
75 79
 \S4method{sequences}{SequenceData}(x)
76 80
 
81
+\S4method{dataType}{SequenceData}(x)
82
+
77 83
 \S4method{show}{SequenceDataSet}(object)
78 84
 
79 85
 \S4method{seqinfo}{SequenceDataSet}(x)