miga-base 1.2.17.1 → 1.2.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/miga/version.rb +2 -2
  3. data/utils/enveomics/Manifest/Tasks/mapping.json +39 -11
  4. data/utils/enveomics/Manifest/Tasks/remote.json +2 -1
  5. data/utils/enveomics/Scripts/BedGraph.tad.rb +98 -53
  6. data/utils/enveomics/Scripts/SRA.download.bash +14 -2
  7. data/utils/enveomics/Tests/low-cov.bg.gz +0 -0
  8. data/utils/enveomics/enveomics.R/DESCRIPTION +5 -5
  9. data/utils/enveomics/enveomics.R/R/autoprune.R +99 -87
  10. data/utils/enveomics/enveomics.R/R/barplot.R +116 -97
  11. data/utils/enveomics/enveomics.R/R/cliopts.R +65 -59
  12. data/utils/enveomics/enveomics.R/R/df2dist.R +96 -58
  13. data/utils/enveomics/enveomics.R/R/growthcurve.R +166 -148
  14. data/utils/enveomics/enveomics.R/R/recplot.R +201 -136
  15. data/utils/enveomics/enveomics.R/R/recplot2.R +371 -304
  16. data/utils/enveomics/enveomics.R/R/tribs.R +318 -263
  17. data/utils/enveomics/enveomics.R/R/utils.R +30 -20
  18. data/utils/enveomics/enveomics.R/man/enve.TRIBS-class.Rd +4 -3
  19. data/utils/enveomics/enveomics.R/man/enve.TRIBS.merge.Rd +2 -2
  20. data/utils/enveomics/enveomics.R/man/enve.TRIBStest-class.Rd +3 -3
  21. data/utils/enveomics/enveomics.R/man/enve.__prune.iter.Rd +7 -4
  22. data/utils/enveomics/enveomics.R/man/enve.__prune.reduce.Rd +7 -4
  23. data/utils/enveomics/enveomics.R/man/enve.__tribs.Rd +4 -0
  24. data/utils/enveomics/enveomics.R/man/enve.barplot.Rd +25 -17
  25. data/utils/enveomics/enveomics.R/man/enve.col.alpha.Rd +10 -0
  26. data/utils/enveomics/enveomics.R/man/enve.col2alpha.Rd +8 -2
  27. data/utils/enveomics/enveomics.R/man/enve.df2dist.Rd +14 -0
  28. data/utils/enveomics/enveomics.R/man/enve.df2dist.group.Rd +20 -1
  29. data/utils/enveomics/enveomics.R/man/enve.df2dist.list.Rd +2 -3
  30. data/utils/enveomics/enveomics.R/man/enve.growthcurve.Rd +5 -2
  31. data/utils/enveomics/enveomics.R/man/enve.recplot.Rd +50 -42
  32. data/utils/enveomics/enveomics.R/man/enve.recplot2.ANIr.Rd +5 -2
  33. data/utils/enveomics/enveomics.R/man/enve.recplot2.__counts.Rd +3 -0
  34. data/utils/enveomics/enveomics.R/man/enve.recplot2.__peakHist.Rd +3 -0
  35. data/utils/enveomics/enveomics.R/man/enve.recplot2.__whichClosestPeak.Rd +3 -0
  36. data/utils/enveomics/enveomics.R/man/enve.recplot2.changeCutoff.Rd +3 -0
  37. data/utils/enveomics/enveomics.R/man/enve.recplot2.compareIdentities.Rd +9 -4
  38. data/utils/enveomics/enveomics.R/man/enve.recplot2.corePeak.Rd +3 -0
  39. data/utils/enveomics/enveomics.R/man/enve.recplot2.extractWindows.Rd +3 -3
  40. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.Rd +0 -2
  41. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__em_e.Rd +4 -0
  42. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__em_m.Rd +5 -0
  43. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__emauto_one.Rd +11 -7
  44. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__mow_one.Rd +5 -1
  45. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__mower.Rd +3 -0
  46. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.mower.Rd +2 -2
  47. data/utils/enveomics/enveomics.R/man/enve.recplot2.windowDepthThreshold.Rd +3 -3
  48. data/utils/enveomics/enveomics.R/man/enve.tribs.Rd +2 -2
  49. data/utils/enveomics/enveomics.R/man/plot.enve.GrowthCurve.Rd +3 -0
  50. data/utils/enveomics/enveomics.R/man/plot.enve.TRIBS.Rd +3 -0
  51. data/utils/enveomics/enveomics.R/man/plot.enve.TRIBStest.Rd +6 -3
  52. data/utils/enveomics/enveomics.R/man/plot.enve.recplot2.Rd +2 -2
  53. data/utils/enveomics/enveomics.R/man/summary.enve.GrowthCurve.Rd +3 -0
  54. data/utils/enveomics/enveomics.R/man/summary.enve.TRIBS.Rd +3 -0
  55. data/utils/enveomics/enveomics.R/man/summary.enve.TRIBStest.Rd +3 -0
  56. metadata +3 -37
  57. data/utils/enveomics/Pipelines/assembly.pbs/CONFIG.mock.bash +0 -69
  58. data/utils/enveomics/Pipelines/assembly.pbs/FastA.N50.pl +0 -1
  59. data/utils/enveomics/Pipelines/assembly.pbs/FastA.filterN.pl +0 -1
  60. data/utils/enveomics/Pipelines/assembly.pbs/FastA.length.pl +0 -1
  61. data/utils/enveomics/Pipelines/assembly.pbs/README.md +0 -189
  62. data/utils/enveomics/Pipelines/assembly.pbs/RUNME-2.bash +0 -112
  63. data/utils/enveomics/Pipelines/assembly.pbs/RUNME-3.bash +0 -23
  64. data/utils/enveomics/Pipelines/assembly.pbs/RUNME-4.bash +0 -44
  65. data/utils/enveomics/Pipelines/assembly.pbs/RUNME.bash +0 -50
  66. data/utils/enveomics/Pipelines/assembly.pbs/kSelector.R +0 -37
  67. data/utils/enveomics/Pipelines/assembly.pbs/newbler.pbs +0 -68
  68. data/utils/enveomics/Pipelines/assembly.pbs/newbler_preparator.pl +0 -49
  69. data/utils/enveomics/Pipelines/assembly.pbs/soap.pbs +0 -80
  70. data/utils/enveomics/Pipelines/assembly.pbs/stats.pbs +0 -57
  71. data/utils/enveomics/Pipelines/assembly.pbs/velvet.pbs +0 -63
  72. data/utils/enveomics/Pipelines/blast.pbs/01.pbs.bash +0 -38
  73. data/utils/enveomics/Pipelines/blast.pbs/02.pbs.bash +0 -73
  74. data/utils/enveomics/Pipelines/blast.pbs/03.pbs.bash +0 -21
  75. data/utils/enveomics/Pipelines/blast.pbs/BlastTab.recover_job.pl +0 -72
  76. data/utils/enveomics/Pipelines/blast.pbs/CONFIG.mock.bash +0 -98
  77. data/utils/enveomics/Pipelines/blast.pbs/FastA.split.pl +0 -1
  78. data/utils/enveomics/Pipelines/blast.pbs/README.md +0 -127
  79. data/utils/enveomics/Pipelines/blast.pbs/RUNME.bash +0 -109
  80. data/utils/enveomics/Pipelines/blast.pbs/TASK.check.bash +0 -128
  81. data/utils/enveomics/Pipelines/blast.pbs/TASK.dry.bash +0 -16
  82. data/utils/enveomics/Pipelines/blast.pbs/TASK.eo.bash +0 -22
  83. data/utils/enveomics/Pipelines/blast.pbs/TASK.pause.bash +0 -26
  84. data/utils/enveomics/Pipelines/blast.pbs/TASK.run.bash +0 -89
  85. data/utils/enveomics/Pipelines/blast.pbs/sentinel.pbs.bash +0 -29
  86. data/utils/enveomics/Pipelines/idba.pbs/README.md +0 -49
  87. data/utils/enveomics/Pipelines/idba.pbs/RUNME.bash +0 -95
  88. data/utils/enveomics/Pipelines/idba.pbs/run.pbs +0 -56
  89. data/utils/enveomics/Pipelines/trim.pbs/README.md +0 -54
  90. data/utils/enveomics/Pipelines/trim.pbs/RUNME.bash +0 -70
  91. data/utils/enveomics/Pipelines/trim.pbs/run.pbs +0 -130
@@ -16,29 +16,31 @@
16
16
  #' Size of the identity bins (vertical histograms). By default, 0.1 for
17
17
  #' identity metrics and 5 for bit score.
18
18
  #' @param id.splines
19
- #' Smoothing parameter for the splines in the identity histogram. Zero (0) for no
20
- #' splines. A generally good value is 1/2. If non-zero, requires the \pkg{stats} package.
19
+ #' Smoothing parameter for the splines in the identity histogram. Zero (0) for
20
+ #' no splines. A generally good value is 1/2. If non-zero, requires the
21
+ #' \pkg{stats} package.
21
22
  #' @param id.metric
22
- #' Metric of identity to be used (Y-axis).
23
- #' It can be any unambiguous prefix of:
23
+ #' Metric of identity to be used (Y-axis). It can be any unambiguous prefix of:
24
24
  #' \itemize{
25
- #' \item "identity"
26
- #' \item "corrected identity"
27
- #' \item "bit score"}
25
+ #' \item "identity"
26
+ #' \item "corrected identity"
27
+ #' \item "bit score"
28
+ #' }
28
29
  #' @param id.summary
29
- #' Method used to build the identity histogram (Horizontal axis of the right panel).
30
- #' It can be any unambiguous prefix of:
30
+ #' Method used to build the identity histogram (Horizontal axis of the right
31
+ #' panel). It can be any unambiguous prefix of:
31
32
  #' \itemize{
32
- #' \item "sum"
33
- #' \item "average"
34
- #' \item "median"
35
- #' \item "90\% lower bound"
36
- #' \item "90\% upper bound"
37
- #' \item "95\% lower bound"
38
- #' \item "95\% upper bound" }
33
+ #' \item "sum"
34
+ #' \item "average"
35
+ #' \item "median"
36
+ #' \item "90\% lower bound"
37
+ #' \item "90\% upper bound"
38
+ #' \item "95\% lower bound"
39
+ #' \item "95\% upper bound"
40
+ #' }
39
41
  #' The last four options
40
- #' correspond to the upper and lower boundaries of the 90\% and 95\% empirical confidence
41
- #' intervals.
42
+ #' correspond to the upper and lower boundaries of the 90\% and 95\% empirical
43
+ #' confidence intervals.
42
44
  #' @param pos.min
43
45
  #' Minimum (leftmost) position in the reference (concatenated) genome (in bp).
44
46
  #' @param pos.max
@@ -47,8 +49,8 @@
47
49
  #' @param pos.binsize
48
50
  #' Size of the position bins (horizontal histograms) in bp.
49
51
  #' @param pos.splines
50
- #' Smoothing parameter for the splines in the position histogram. Zero (0) for no splines.
51
- #' If non-zero, requires the stats package.
52
+ #' Smoothing parameter for the splines in the position histogram. Zero (0) for
53
+ #' no splines. If non-zero, requires the stats package.
52
54
  #' @param rec.col1
53
55
  #' Lightest color in the recruitment plot.
54
56
  #' @param rec.col2
@@ -65,13 +67,14 @@
65
67
  #' Indicates if the mode of the identity is to be computed. It requires the
66
68
  #' \pkg{modeest} package.
67
69
  #' @param id.cutoff
68
- #' Minimum identity to consider an alignment as "top". By default, it is 0.95 for the
69
- #' identity metrics and 95\% of the best scoring alignment for bit score.
70
+ #' Minimum identity to consider an alignment as "top". By default, it is 0.95
71
+ #' for the identity metrics and 95\% of the best scoring alignment for bit
72
+ #' score.
70
73
  #' @param verbose
71
74
  #' Indicates if the function should report the advance.
72
75
  #' @param ...
73
- #' Any additional graphic parameters to be passed to plot for all panels except the
74
- #' recruitment plot (lower-left).
76
+ #' Any additional graphic parameters to be passed to plot for all panels except
77
+ #' the recruitment plot (lower-left).
75
78
  #'
76
79
  #' @return
77
80
  #'
@@ -81,83 +84,92 @@
81
84
  #' \item{\code{pos.marks}}{Midpoints of the position histogram.}
82
85
  #' \item{\code{id.matrix}}{Midpoints of the identity histogram.}
83
86
  #' \item{\code{recplot}}{Matrix containing the recruitment plot values
84
- #' (if \code{ret.recplot=TRUE}).}
87
+ #' (if \code{ret.recplot=TRUE}).}
85
88
  #' \item{\code{id.mean}}{Mean identity.}
86
89
  #' \item{\code{id.median}}{Median identity.}
87
- #' \item{\code{id.mode}}{Mode of the identity (if \code{ret.mode=TRUE}). Deprecated.}
88
- #' \item{\code{id.hist}}{Values of the identity histogram (if \code{ret.hist=TRUE}).}
89
- #' \item{\code{pos.hist.low}}{Values of the position histogram (depth) with "low"
90
- #' identity (i.e., below id.cutoff) (if \code{ret.hist=TRUE}).}
91
- #' \item{\code{pos.hist.top}}{Values of the position histogram (depth) with "top"
92
- #' identity (i.e., above id.cutoff) (if \code{ret.hist=TRUE}).}
90
+ #' \item{\code{id.mode}}{Mode of the identity (if \code{ret.mode=TRUE}).
91
+ #' Deprecated.}
92
+ #' \item{\code{id.hist}}{Values of the identity histogram
93
+ #' (if \code{ret.hist=TRUE}).}
94
+ #' \item{\code{pos.hist.low}}{Values of the position histogram (depth) with
95
+ #' "low" identity (i.e., below id.cutoff) (if \code{ret.hist=TRUE}).}
96
+ #' \item{\code{pos.hist.top}}{Values of the position histogram (depth) with
97
+ #' "top" identity (i.e., above id.cutoff) (if \code{ret.hist=TRUE}).}
93
98
  #' \item{\code{id.max}}{Value of \code{id.max}. This is returned because
94
- #' \code{id.max=NULL} may vary.}
99
+ #' \code{id.max=NULL} may vary.}
95
100
  #' \item{\code{id.cutoff}}{Value of \code{id.cutoff}.
96
- #' This is returned because \code{id.cutoff=NULL} may vary.}
101
+ #' This is returned because \code{id.cutoff=NULL} may vary.}
97
102
  #' \item{\code{seqdepth.mean.top}}{Average sequencing depth with identity above
98
- #' \code{id.cutoff}.}
103
+ #' \code{id.cutoff}.}
99
104
  #' \item{\code{seqdepth.mean.low}}{Average sequencing depth with identity below
100
- #' \code{id.cutoff}.}
101
- #' \item{\code{seqdepth.mean.all}}{Average sequencing depth without identity filtering.}
102
- #' \item{\code{seqdepth.median.top}}{Median sequencing depth with identity above
103
- #' \code{id.cutoff}.}
104
- #' \item{\code{seqdepth.median.low}}{Median sequencing depth with identity below
105
- #' \code{id.cutoff}.}
106
- #' \item{\code{seqdepth.median.all}}{Median sequencing depth without identity filtering.}
105
+ #' \code{id.cutoff}.}
106
+ #' \item{\code{seqdepth.mean.all}}{Average sequencing depth without identity
107
+ #' filtering.}
108
+ #' \item{\code{seqdepth.median.top}}{Median sequencing depth with identity above
109
+ #' \code{id.cutoff}.}
110
+ #' \item{\code{seqdepth.median.low}}{Median sequencing depth with identity below
111
+ #' \code{id.cutoff}.}
112
+ #' \item{\code{seqdepth.median.all}}{Median sequencing depth without identity
113
+ #' filtering.}
107
114
  #' \item{\code{id.metric}}{Full name of the used identity metric.}
108
- #' \item{\code{id.summary}}{Full name of the summary method used to build the identity plot.}}
115
+ #' \item{\code{id.summary}}{Full name of the summary method used to build the
116
+ #' identity plot.}}
109
117
  #'
110
118
  #' @author Luis M. Rodriguez-R [aut, cre]
111
119
  #'
112
120
  #' @export
113
121
 
114
- enve.recplot <- structure(function(
122
+ enve.recplot <- function(
115
123
  prefix,
116
-
124
+
117
125
  # Id. hist.
118
- id.min=NULL,
119
- id.max=NULL,
120
- id.binsize=NULL,
121
- id.splines=0,
122
- id.metric='id',
123
- id.summary='sum',
124
-
126
+ id.min = NULL,
127
+ id.max = NULL,
128
+ id.binsize = NULL,
129
+ id.splines = 0,
130
+ id.metric = "id",
131
+ id.summary = "sum",
132
+
125
133
  # Pos. hist.
126
- pos.min=1,
127
- pos.max=NULL,
128
- pos.binsize=1e3,
129
- pos.splines=0,
130
-
134
+ pos.min = 1,
135
+ pos.max = NULL,
136
+ pos.binsize = 1e3,
137
+ pos.splines = 0,
138
+
131
139
  # Rec. plot
132
- rec.col1='white',
133
- rec.col2='black',
134
-
140
+ rec.col1 = "white",
141
+ rec.col2 = "black",
142
+
135
143
  # General
136
- main=NULL,
137
- contig.col=grey(0.85),
138
-
144
+ main = NULL,
145
+ contig.col = grey(0.85),
146
+
139
147
  # Return
140
- ret.recplot=FALSE,
141
- ret.hist=FALSE,
142
- ret.mode=FALSE,
143
-
148
+ ret.recplot = FALSE,
149
+ ret.hist = FALSE,
150
+ ret.mode = FALSE,
151
+
144
152
  # General
145
- id.cutoff=NULL,
146
- verbose=TRUE,
153
+ id.cutoff = NULL,
154
+ verbose = TRUE,
147
155
  ...
148
- ){
149
-
156
+ ) {
150
157
  # Settings
151
- METRICS <- c('identity', 'corrected identity', 'bit score');
152
- SUMMARY <- c('sum', 'average', 'median', '');
153
- if(is.null(prefix)) stop('Parameter prefix is mandatory.');
154
- if(!requireNamespace("gplots", quietly=TRUE)) stop('Unavailable gplots library.');
158
+ METRICS <- c("identity", "corrected identity", "bit score")
159
+ SUMMARY <- c("sum", "average", "median", "")
160
+ if (is.null(prefix)) stop("Parameter prefix is mandatory.")
161
+ if (!requireNamespace("gplots", quietly = TRUE))
162
+ stop("Unavailable gplots library.")
155
163
 
156
164
  # Read files
157
165
  if(verbose) cat("Reading files.\n")
158
- rec <- read.table(paste(prefix, '.rec', sep=''), sep="\t", comment.char='', quote='');
159
- lim <- read.table(paste(prefix, '.lim', sep=''), sep="\t", comment.char='', quote='');
160
-
166
+ rec <- read.table(
167
+ paste(prefix, ".rec", sep = ""), sep = "\t", comment.char = "", quote = ""
168
+ )
169
+ lim <- read.table(
170
+ paste(prefix, ".lim", sep = ""), sep = "\t", comment.char = "", quote = ""
171
+ )
172
+
161
173
  # Configure ID summary
162
174
  id.summary <- pmatch(id.summary, SUMMARY);
163
175
  if(is.na(id.summary)) stop('Invalid identity summary.');
@@ -184,7 +196,7 @@ enve.recplot <- structure(function(
184
196
  id.summary.func <- function(x) apply(x,2,quantile,probs=0.975,names=FALSE);
185
197
  id.summary.name <- '95% UB'
186
198
  }
187
-
199
+
188
200
  # Configure metrics
189
201
  id.metric <- pmatch(id.metric, METRICS);
190
202
  if(is.na(id.metric)) stop('Invalid identity metric.');
@@ -229,32 +241,43 @@ enve.recplot <- structure(function(
229
241
  pos.marks=seq(pos.min, pos.max, length.out=pos.breaks+1)/1e6;
230
242
  id.marks=seq(id.min, id.max, length.out=id.breaks+1);
231
243
  id.topclasses <- 0;
232
- for(i in length(id.marks):1) if(id.marks[i]>id.cutoff) id.topclasses <- id.topclasses + 1;
244
+ for(i in length(id.marks):1)
245
+ if(id.marks[i]>id.cutoff)
246
+ id.topclasses <- id.topclasses + 1
233
247
 
234
248
  # Set-up image
235
- layout(matrix(c(3,4,1,2), nrow=2, byrow=TRUE), widths=c(2,1), heights=c(1,2));
236
- out <- list();
249
+ layout(matrix(c(3,4,1,2), nrow=2, byrow=TRUE), widths=c(2,1), heights=c(1,2))
250
+ out <- list()
237
251
 
238
252
  # Recruitment plot
239
253
  if(verbose) cat("Rec. plot.\n")
240
- par(mar=c(5,4,0,0)+0.1);
241
- rec.hist <- matrix(0, nrow=pos.breaks, ncol=id.breaks);
242
- for(i in 1:nrow(rec)){
243
- id.class <- ceiling((id.breaks)*((rec[i, id.reccol]-id.min)/(id.max-id.min)));
244
- if(id.class<=id.breaks & id.class>0){
245
- for(pos in rec[i, 1]:rec[i, 2]){
246
- pos.class <- ceiling((pos.breaks)*((pos-pos.min)/(pos.max-pos.min)));
247
- if(pos.class<=pos.breaks & pos.class>0) rec.hist[pos.class, id.class] <- rec.hist[pos.class, id.class]+1;
254
+ mar <- par(mar=c(5, 4, 0, 0) + 0.1)
255
+ on.exit(par(mar))
256
+ rec.hist <- matrix(0, nrow = pos.breaks, ncol = id.breaks)
257
+ for (i in 1:nrow(rec)) {
258
+ id.class <- ceiling(
259
+ id.breaks * (rec[i, id.reccol] - id.min) / (id.max-id.min)
260
+ )
261
+ if (id.class <= id.breaks & id.class > 0) {
262
+ for (pos in rec[i, 1]:rec[i, 2]){
263
+ pos.class <- ceiling(pos.breaks * (pos-pos.min) / (pos.max-pos.min))
264
+ if (pos.class <= pos.breaks & pos.class > 0)
265
+ rec.hist[pos.class, id.class] <- rec.hist[pos.class, id.class] + 1
248
266
  }
249
267
  }
250
268
  }
251
269
  id.top <- c((1-id.topclasses):0) + id.breaks;
252
270
  rec.col=gplots::colorpanel(256, rec.col1, rec.col2);
253
- image(x=pos.marks, y=id.marks, z=log10(rec.hist),
254
- breaks=seq(0, log10(max(rec.hist)), length.out=1+length(rec.col)), col=rec.col,
255
- xlim=pos.lim, ylim=id.lim, xlab='Position in genome (Mbp)',
256
- ylab=paste(id.fullname, ' (',id.units,')', sep=''), xaxs='i', yaxs='r');
257
- if(!is.na(contig.col)) abline(v=c(lim$V2, lim$V3)/1e6, lty=1, col=contig.col);
271
+ image(
272
+ x = pos.marks, y = id.marks, z = log10(rec.hist),
273
+ breaks = seq(0, log10(max(rec.hist)), length.out = 1 + length(rec.col)),
274
+ col = rec.col, xlim = pos.lim, ylim = id.lim,
275
+ xlab = "Position in genome (Mbp)",
276
+ ylab = paste(id.fullname, " (", id.units, ")", sep = ""),
277
+ xaxs = "i", yaxs = "r"
278
+ )
279
+ if (!is.na(contig.col))
280
+ abline(v=c(lim$V2, lim$V3)/1e6, lty=1, col=contig.col)
258
281
  abline(h=id.hallmarks, lty=2, col=grey(0.7));
259
282
  abline(h=id.marks[id.top[1]], lty=3, col=grey(0.5))
260
283
  legend('bottomleft', 'Rec. plot', bg=rgb(1,1,1,2/3));
@@ -262,16 +285,21 @@ enve.recplot <- structure(function(
262
285
  if(ret.recplot) out <- c(out, list(recplot=rec.hist));
263
286
 
264
287
  # Identity histogram
265
- if(verbose) cat(id.shortname, " hist.\n", sep='')
266
- par(mar=c(5,0,0,2)+0.1);
267
- id.hist <- id.summary.func(rec.hist);
268
- plot(1, t='n', xlim=c(1, max(id.hist)), ylim=id.lim, ylab='', yaxt='n', xlab=paste('Sequences (bp),', id.summary.name), log='x', ...);
288
+ if(verbose) cat(id.shortname, " hist.\n", sep = "")
289
+ par(mar=c(5,0,0,2)+0.1) # par(mar) already being watched by on.exit
290
+ id.hist <- id.summary.func(rec.hist)
291
+ plot(
292
+ 1, t = "n", xlim = c(1, max(id.hist)), ylim = id.lim, ylab = "", yaxt = "n",
293
+ xlab = paste("Sequences (bp),", id.summary.name), log = "x", ...
294
+ )
269
295
  id.x <- rep(id.marks, each=2)[2:(id.breaks*2+1)]
270
296
  id.f <- rep(id.hist, each=2)[1:(id.breaks*2)]
271
297
  if(sum(id.f)>0){
272
- lines(id.f, id.x, lwd=ifelse(id.splines>0, 1/2, 2), type='o', pch='.');
298
+ lines(id.f, id.x, lwd=ifelse(id.splines>0, 1/2, 2), type = "o", pch = ".")
273
299
  if(id.splines>0){
274
- id.spline <- smooth.spline(id.x[id.f>0], log(id.f[id.f>0]), spar=id.splines)
300
+ id.spline <- smooth.spline(
301
+ id.x[id.f > 0], log(id.f[id.f > 0]), spar = id.splines
302
+ )
275
303
  lines(exp(id.spline$y), id.spline$x, lwd=2)
276
304
  }
277
305
  }
@@ -285,27 +313,36 @@ enve.recplot <- structure(function(
285
313
 
286
314
  # Position histogram
287
315
  if(verbose) cat("Pos. hist.\n")
288
- par(mar=c(0,4,4,0)+0.1);
289
- h1<-rep(0,nrow(rec.hist)) ;
290
- h2<-rep(0,nrow(rec.hist)) ;
291
- pos.winsize <- (pos.max-pos.min+1)/pos.breaks;
292
- if(sum(rec.hist[, id.top])>0) h1 <- rowSums(matrix(rec.hist[, id.top], nrow=nrow(rec.hist)))/pos.winsize;
293
- if(sum(rec.hist[,-id.top])>0) h2 <- rowSums(matrix(rec.hist[,-id.top], nrow=nrow(rec.hist)))/pos.winsize;
316
+ par(mar = c(0, 4, 4, 0) + 0.1) # par(mar) already being watched by on.exit
317
+ h1<-rep(0,nrow(rec.hist))
318
+ h2<-rep(0,nrow(rec.hist))
319
+ pos.winsize <- (pos.max - pos.min + 1) / pos.breaks
320
+ if(sum(rec.hist[, id.top])>0)
321
+ h1 <- rowSums(matrix(rec.hist[, id.top], nrow = nrow(rec.hist))) /
322
+ pos.winsize
323
+ if(sum(rec.hist[,-id.top])>0)
324
+ h2 <- rowSums(matrix(rec.hist[,-id.top], nrow = nrow(rec.hist))) /
325
+ pos.winsize
294
326
 
295
327
  ymin <- min(1, h1[h1>0], h2[h2>0]);
296
328
  ymax <- max(10, h1, h2);
297
329
  if(is.na(ymin) || ymin<=0) ymin <- 1e-10;
298
330
  if(is.na(ymax) || ymax<=0) ymax <- 1;
299
- plot(1, t='n', xlab='', xaxt='n', ylab='Sequencing depth (X)', log='y', xlim=pos.lim,
300
- ylim=c(ymin, ymax), xaxs='i', main=main, ...);
301
- if(!is.na(contig.col)) abline(v=c(lim[,2], lim[,3])/1e6, lty=1, col=contig.col);
331
+ plot(
332
+ 1, t = "n", xlab = "", xaxt = "n", ylab = "Sequencing depth (X)", log = "y",
333
+ xlim = pos.lim, ylim = c(ymin, ymax), xaxs = "i", main = main, ...
334
+ )
335
+ if(!is.na(contig.col))
336
+ abline(v=c(lim[,2], lim[,3])/1e6, lty=1, col=contig.col)
302
337
  abline(h=10^c(0:5), lty=2, col=grey(0.7));
303
338
  if(sum(h2)>0){
304
339
  h2.x <- rep(pos.marks, each=2)[2:(pos.breaks*2+1)]
305
340
  h2.y <- rep(h2, each=2)[1:(pos.breaks*2)]
306
341
  lines(h2.x, h2.y, lwd=ifelse(pos.splines>0, 1/2, 2), col=grey(0.5));
307
342
  if(pos.splines>0){
308
- h2.spline <- smooth.spline(h2.x[h2.y>0], log(h2.y[h2.y>0]), spar=pos.splines)
343
+ h2.spline <- smooth.spline(
344
+ h2.x[h2.y > 0], log(h2.y[h2.y > 0]), spar = pos.splines
345
+ )
309
346
  lines(h2.spline$x, exp(h2.spline$y), lwd=2, col=grey(0.5))
310
347
  }
311
348
  if(ret.hist) out <- c(out, list(pos.hist.low=h2.y));
@@ -315,40 +352,68 @@ enve.recplot <- structure(function(
315
352
  h1.y <- rep(h1, each=2)[1:(pos.breaks*2)]
316
353
  lines(h1.x, h1.y, lwd=ifelse(pos.splines>0, 1/2, 2), col=grey(0));
317
354
  if(pos.splines>0){
318
- h1.spline <- smooth.spline(h1.x[h1.y>0], log(h1.y[h1.y>0]), spar=pos.splines)
355
+ h1.spline <- smooth.spline(
356
+ h1.x[h1.y > 0], log(h1.y[h1.y > 0]), spar = pos.splines
357
+ )
319
358
  lines(h1.spline$x, exp(h1.spline$y), lwd=2, col=grey(0))
320
359
  }
321
- if(ret.hist) out <- c(out, list(pos.hist.top=h1.y));
360
+ if(ret.hist) out <- c(out, list(pos.hist.top=h1.y))
322
361
  }
323
- legend('topleft', 'Pos. histogram', bg=rgb(1,1,1,2/3));
324
- out <- c(out, list(id.max=id.max, id.cutoff=id.marks[id.top[1]]));
325
- out <- c(out, list(seqdepth.mean.top=mean(h1)));
326
- out <- c(out, list(seqdepth.mean.low=mean(h2)));
327
- out <- c(out, list(seqdepth.mean=mean(h1+h2)));
328
- out <- c(out, list(seqdepth.median.top=median(h1)));
329
- out <- c(out, list(seqdepth.median.low=median(h2)));
330
- out <- c(out, list(seqdepth.median=median(h1+h2)));
331
- out <- c(out, list(id.metric=id.fullname));
332
- out <- c(out, list(id.summary=id.summary.name));
362
+ legend("topleft", "Pos. histogram", bg = rgb(1, 1, 1, 2/3))
363
+ out <- c(out, list(id.max=id.max, id.cutoff=id.marks[id.top[1]]))
364
+ out <- c(out, list(seqdepth.mean.top=mean(h1)))
365
+ out <- c(out, list(seqdepth.mean.low=mean(h2)))
366
+ out <- c(out, list(seqdepth.mean=mean(h1+h2)))
367
+ out <- c(out, list(seqdepth.median.top=median(h1)))
368
+ out <- c(out, list(seqdepth.median.low=median(h2)))
369
+ out <- c(out, list(seqdepth.median=median(h1+h2)))
370
+ out <- c(out, list(id.metric=id.fullname))
371
+ out <- c(out, list(id.summary=id.summary.name))
333
372
 
334
373
  # Legend
335
- par(mar=c(0,0,4,2)+0.1);
336
- plot(1, t='n', xlab='', xaxt='n', ylab='', yaxt='n', xlim=c(0,1), ylim=c(0,1), xaxs='r', yaxs='i', ...);
337
- text(1/2, 5/6, labels=paste('Reads per ', signif((pos.max-pos.min)/pos.breaks, 2), ' bp (rec. plot)', sep=''), pos=3);
338
- leg.col <- gplots::colorpanel(100, rec.col1, rec.col2);
339
- leg.lab <- signif(10^seq(0, log10(max(rec.hist)), length.out=10), 2);
374
+ par(mar=c(0, 0, 4, 2) + 0.1) # par(mar) already being watched by on.exit
375
+ plot(
376
+ 1, t = "n", xlab = "", xaxt = "n", ylab = "", yaxt = "n",
377
+ xlim = c(0,1), ylim = c(0,1), xaxs = "r", yaxs = "i", ...
378
+ )
379
+ text(
380
+ 1/2, 5/6, labels = paste(
381
+ "Reads per ", signif((pos.max-pos.min) / pos.breaks, 2),
382
+ " bp (rec. plot)", sep = ""
383
+ ), pos=3
384
+ )
385
+ leg.col <- gplots::colorpanel(100, rec.col1, rec.col2)
386
+ leg.lab <- signif(10^seq(0, log10(max(rec.hist)), length.out=10), 2)
340
387
  for(i in 1:10){
341
388
  for(j in 1:10){
342
389
  k <- (i-1)*10 + j;
343
- polygon(c(k-1, k, k, k-1)/100, c(2/3, 2/3, 5/6, 5/6), border=leg.col[k], col=leg.col[k]);
390
+ polygon(
391
+ c(k-1, k, k, k-1) / 100,
392
+ c(2/3, 2/3, 5/6, 5/6),
393
+ border = leg.col[k], col = leg.col[k]
394
+ )
344
395
  }
345
- text((i-0.5)/10, 2/3, labels=paste(leg.lab[i], ''), srt=90, pos=2, offset=0, cex=3/4);
396
+ text(
397
+ (i - 0.5) / 10, 2/3,
398
+ labels = paste(leg.lab[i], ""), srt = 90, pos = 2, offset = 0, cex = 3/4
399
+ )
346
400
  }
347
- legend('bottom',
348
- legend=c('Contig boundary', 'Hallmark', paste(id.fullname, 'cutoff'),
349
- paste('Pos. hist.: ',id.shortname,' > ',signif(id.marks[id.top[1]],2),id.units,sep=''),
350
- paste('Pos. hist.: ',id.shortname,' < ',signif(id.marks[id.top[1]],2),id.units,sep='')), ncol=2,
351
- col=grey(c(0.85, 0.7, 0.5, 0, 0.5)), lty=c(1,2,3,1,1), lwd=c(1,1,1,2,2), bty='n', inset=0.05, cex=5/6);
352
- return(out);
353
- });
401
+ legend(
402
+ "bottom",
403
+ legend = c(
404
+ "Contig boundary", "Hallmark", paste(id.fullname, "cutoff"),
405
+ paste(
406
+ "Pos. hist.: ", id.shortname, " > ",
407
+ signif(id.marks[id.top[1]],2), id.units, sep = ""
408
+ ),
409
+ paste(
410
+ "Pos. hist.: ", id.shortname, " < ",
411
+ signif(id.marks[id.top[1]], 2), id.units, sep = ""
412
+ )
413
+ ),
414
+ ncol=2, col = grey(c(0.85, 0.7, 0.5, 0, 0.5)), lty = c(1, 2, 3, 1, 1),
415
+ lwd = c(1, 1, 1, 2, 2), bty = "n", inset = 0.05, cex = 5/6
416
+ )
417
+ return(out)
418
+ }
354
419