Browse code

updated how the mbias table is generated

Divyagash authored on 21/03/2018 00:42:10
Showing 3 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: scmeth
2 2
 Type: Package
3 3
 Title: Functions to conduct quality control analysis in methylation data
4
-Version: 0.99.28
4
+Version: 0.99.29
5 5
 Author: Divy Kangeyan <[email protected]>
6 6
 Maintainer: Divy Kangeyan <[email protected]>
7 7
 Depends: R (>= 3.5.0)
... ...
@@ -17,7 +17,6 @@ import(DT)
17 17
 import(GenomicRanges)
18 18
 import(SummarizedExperiment)
19 19
 import(knitr)
20
-import(magrittr)
21 20
 importFrom(Biostrings,DNAString)
22 21
 importFrom(Biostrings,vmatchPattern)
23 22
 importFrom(DelayedArray,colSums)
... ...
@@ -30,9 +29,8 @@ importFrom(annotatr,builtin_genomes)
30 29
 importFrom(annotatr,summarize_annotations)
31 30
 importFrom(bsseq,getCoverage)
32 31
 importFrom(ggthemes,theme_tufte)
33
-importFrom(plyr,ddply)
34
-importFrom(plyr,summarise)
35 32
 importFrom(scales,comma)
33
+importFrom(stats,aggregate)
36 34
 importFrom(stats,dbinom)
37 35
 importFrom(stats,relevel)
38 36
 importFrom(stats,sd)
... ...
@@ -14,9 +14,7 @@
14 14
 #'@importFrom utils read.table
15 15
 #'@importFrom utils read.csv
16 16
 #'@importFrom stats sd
17
-#'@importFrom plyr summarise
18
-#'@importFrom plyr ddply
19
-#'@import magrittr
17
+#'@importFrom stats aggregate
20 18
 #'@export
21 19
 
22 20
 mbiasplot <- function(dir=NULL,mbiasFiles=NULL){
... ...
@@ -59,9 +57,16 @@ mbiasplot <- function(dir=NULL,mbiasFiles=NULL){
59 57
                         id.vars=c('position', 'X..methylation', 'read'))
60 58
     mt$read_rep <- paste(mt$read, mt$L1, sep="_")
61 59
 
62
-    sum_mt <- plyr::ddply(mt, c("position", "read"), plyr::summarise,
63
-                    meth = mean(X..methylation), sdMeth = sd(X..methylation),
64
-                    seMeth = sd(X..methylation)/sqrt(length(X..methylation)))
60
+    meanTable <- stats::aggregate( X..methylation ~ position+read, data=mt, FUN=mean)
61
+    sdTable <- stats::aggregate( X..methylation ~ position+read, data=mt, FUN=sd)
62
+    seTable <- stats::aggregate( X..methylation ~ position+read, data=mt, FUN=function(x){sd(x)/sqrt(length(x))})
63
+
64
+    sum_mt<-data.frame('position'=meanTable$position,'read'=meanTable$read,
65
+                       'meth'=meanTable$X..methylation, 'sdMeth'=sdTable$X..methylation,
66
+                       'seMeth'=seTable$X..methylation)
67
+    #sum_mt <- plyr::ddply(mt, .(position, read), plyr::summarise,
68
+                    #meth = mean(X..methylation), sdMeth = sd(X..methylation),
69
+                    #seMeth = sd(X..methylation)/sqrt(length(X..methylation)))
65 70
     #sum_mt <- mt %>% dplyr::group_by(position,read) %>%
66 71
                         #dplyr::summarise(meth = mean(X..methylation),
67 72
                            #     sdMeth=stats::sd(X..methylation))