miga-base 1.2.17.0 → 1.2.17.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/lib/miga/version.rb +2 -2
  3. data/utils/FastAAI/00.Libraries/01.SCG_HMMs/Archaea_SCG.hmm +41964 -0
  4. data/utils/FastAAI/00.Libraries/01.SCG_HMMs/Bacteria_SCG.hmm +32439 -0
  5. data/utils/FastAAI/00.Libraries/01.SCG_HMMs/Complete_SCG_DB.hmm +62056 -0
  6. data/utils/FastAAI/FastAAI +3659 -0
  7. data/utils/FastAAI/FastAAI-legacy/FastAAI +1336 -0
  8. data/utils/FastAAI/FastAAI-legacy/kAAI_v1.0_virus.py +1296 -0
  9. data/utils/FastAAI/README.md +84 -0
  10. data/utils/enveomics/Docs/recplot2.md +244 -0
  11. data/utils/enveomics/Examples/aai-matrix.bash +66 -0
  12. data/utils/enveomics/Examples/ani-matrix.bash +66 -0
  13. data/utils/enveomics/Examples/essential-phylogeny.bash +105 -0
  14. data/utils/enveomics/Examples/unus-genome-phylogeny.bash +100 -0
  15. data/utils/enveomics/LICENSE.txt +73 -0
  16. data/utils/enveomics/Makefile +52 -0
  17. data/utils/enveomics/Manifest/Tasks/aasubs.json +103 -0
  18. data/utils/enveomics/Manifest/Tasks/blasttab.json +790 -0
  19. data/utils/enveomics/Manifest/Tasks/distances.json +161 -0
  20. data/utils/enveomics/Manifest/Tasks/fasta.json +802 -0
  21. data/utils/enveomics/Manifest/Tasks/fastq.json +291 -0
  22. data/utils/enveomics/Manifest/Tasks/graphics.json +126 -0
  23. data/utils/enveomics/Manifest/Tasks/mapping.json +165 -0
  24. data/utils/enveomics/Manifest/Tasks/ogs.json +382 -0
  25. data/utils/enveomics/Manifest/Tasks/other.json +906 -0
  26. data/utils/enveomics/Manifest/Tasks/remote.json +356 -0
  27. data/utils/enveomics/Manifest/Tasks/sequence-identity.json +650 -0
  28. data/utils/enveomics/Manifest/Tasks/tables.json +308 -0
  29. data/utils/enveomics/Manifest/Tasks/trees.json +68 -0
  30. data/utils/enveomics/Manifest/Tasks/variants.json +111 -0
  31. data/utils/enveomics/Manifest/categories.json +165 -0
  32. data/utils/enveomics/Manifest/examples.json +162 -0
  33. data/utils/enveomics/Manifest/tasks.json +4 -0
  34. data/utils/enveomics/README.md +42 -0
  35. data/utils/enveomics/Scripts/AAsubs.log2ratio.rb +171 -0
  36. data/utils/enveomics/Scripts/Aln.cat.rb +221 -0
  37. data/utils/enveomics/Scripts/Aln.convert.pl +35 -0
  38. data/utils/enveomics/Scripts/AlphaDiversity.pl +152 -0
  39. data/utils/enveomics/Scripts/BedGraph.tad.rb +138 -0
  40. data/utils/enveomics/Scripts/BedGraph.window.rb +71 -0
  41. data/utils/enveomics/Scripts/BlastPairwise.AAsubs.pl +102 -0
  42. data/utils/enveomics/Scripts/BlastTab.addlen.rb +63 -0
  43. data/utils/enveomics/Scripts/BlastTab.advance.bash +48 -0
  44. data/utils/enveomics/Scripts/BlastTab.best_hit_sorted.pl +55 -0
  45. data/utils/enveomics/Scripts/BlastTab.catsbj.pl +104 -0
  46. data/utils/enveomics/Scripts/BlastTab.cogCat.rb +76 -0
  47. data/utils/enveomics/Scripts/BlastTab.filter.pl +47 -0
  48. data/utils/enveomics/Scripts/BlastTab.kegg_pep2path_rest.pl +194 -0
  49. data/utils/enveomics/Scripts/BlastTab.metaxaPrep.pl +104 -0
  50. data/utils/enveomics/Scripts/BlastTab.pairedHits.rb +157 -0
  51. data/utils/enveomics/Scripts/BlastTab.recplot2.R +48 -0
  52. data/utils/enveomics/Scripts/BlastTab.seqdepth.pl +86 -0
  53. data/utils/enveomics/Scripts/BlastTab.seqdepth_ZIP.pl +119 -0
  54. data/utils/enveomics/Scripts/BlastTab.seqdepth_nomedian.pl +86 -0
  55. data/utils/enveomics/Scripts/BlastTab.subsample.pl +47 -0
  56. data/utils/enveomics/Scripts/BlastTab.sumPerHit.pl +114 -0
  57. data/utils/enveomics/Scripts/BlastTab.taxid2taxrank.pl +90 -0
  58. data/utils/enveomics/Scripts/BlastTab.topHits_sorted.rb +123 -0
  59. data/utils/enveomics/Scripts/Chao1.pl +97 -0
  60. data/utils/enveomics/Scripts/CharTable.classify.rb +234 -0
  61. data/utils/enveomics/Scripts/EBIseq2tax.rb +83 -0
  62. data/utils/enveomics/Scripts/FastA.N50.pl +60 -0
  63. data/utils/enveomics/Scripts/FastA.extract.rb +152 -0
  64. data/utils/enveomics/Scripts/FastA.filter.pl +52 -0
  65. data/utils/enveomics/Scripts/FastA.filterLen.pl +28 -0
  66. data/utils/enveomics/Scripts/FastA.filterN.pl +60 -0
  67. data/utils/enveomics/Scripts/FastA.fragment.rb +100 -0
  68. data/utils/enveomics/Scripts/FastA.gc.pl +42 -0
  69. data/utils/enveomics/Scripts/FastA.interpose.pl +93 -0
  70. data/utils/enveomics/Scripts/FastA.length.pl +38 -0
  71. data/utils/enveomics/Scripts/FastA.mask.rb +89 -0
  72. data/utils/enveomics/Scripts/FastA.per_file.pl +36 -0
  73. data/utils/enveomics/Scripts/FastA.qlen.pl +57 -0
  74. data/utils/enveomics/Scripts/FastA.rename.pl +65 -0
  75. data/utils/enveomics/Scripts/FastA.revcom.pl +23 -0
  76. data/utils/enveomics/Scripts/FastA.sample.rb +98 -0
  77. data/utils/enveomics/Scripts/FastA.slider.pl +85 -0
  78. data/utils/enveomics/Scripts/FastA.split.pl +55 -0
  79. data/utils/enveomics/Scripts/FastA.split.rb +79 -0
  80. data/utils/enveomics/Scripts/FastA.subsample.pl +131 -0
  81. data/utils/enveomics/Scripts/FastA.tag.rb +65 -0
  82. data/utils/enveomics/Scripts/FastA.toFastQ.rb +69 -0
  83. data/utils/enveomics/Scripts/FastA.wrap.rb +48 -0
  84. data/utils/enveomics/Scripts/FastQ.filter.pl +54 -0
  85. data/utils/enveomics/Scripts/FastQ.interpose.pl +90 -0
  86. data/utils/enveomics/Scripts/FastQ.maskQual.rb +89 -0
  87. data/utils/enveomics/Scripts/FastQ.offset.pl +90 -0
  88. data/utils/enveomics/Scripts/FastQ.split.pl +53 -0
  89. data/utils/enveomics/Scripts/FastQ.tag.rb +70 -0
  90. data/utils/enveomics/Scripts/FastQ.test-error.rb +81 -0
  91. data/utils/enveomics/Scripts/FastQ.toFastA.awk +24 -0
  92. data/utils/enveomics/Scripts/GFF.catsbj.pl +127 -0
  93. data/utils/enveomics/Scripts/GenBank.add_fields.rb +84 -0
  94. data/utils/enveomics/Scripts/HMM.essential.rb +351 -0
  95. data/utils/enveomics/Scripts/HMM.haai.rb +168 -0
  96. data/utils/enveomics/Scripts/HMMsearch.extractIds.rb +83 -0
  97. data/utils/enveomics/Scripts/JPlace.distances.rb +88 -0
  98. data/utils/enveomics/Scripts/JPlace.to_iToL.rb +320 -0
  99. data/utils/enveomics/Scripts/M5nr.getSequences.rb +81 -0
  100. data/utils/enveomics/Scripts/MeTaxa.distribution.pl +198 -0
  101. data/utils/enveomics/Scripts/MyTaxa.fragsByTax.pl +35 -0
  102. data/utils/enveomics/Scripts/MyTaxa.seq-taxrank.rb +49 -0
  103. data/utils/enveomics/Scripts/NCBIacc2tax.rb +92 -0
  104. data/utils/enveomics/Scripts/Newick.autoprune.R +27 -0
  105. data/utils/enveomics/Scripts/RAxML-EPA.to_iToL.pl +228 -0
  106. data/utils/enveomics/Scripts/RecPlot2.compareIdentities.R +32 -0
  107. data/utils/enveomics/Scripts/RefSeq.download.bash +48 -0
  108. data/utils/enveomics/Scripts/SRA.download.bash +67 -0
  109. data/utils/enveomics/Scripts/TRIBS.plot-test.R +36 -0
  110. data/utils/enveomics/Scripts/TRIBS.test.R +39 -0
  111. data/utils/enveomics/Scripts/Table.barplot.R +31 -0
  112. data/utils/enveomics/Scripts/Table.df2dist.R +30 -0
  113. data/utils/enveomics/Scripts/Table.filter.pl +61 -0
  114. data/utils/enveomics/Scripts/Table.merge.pl +77 -0
  115. data/utils/enveomics/Scripts/Table.prefScore.R +60 -0
  116. data/utils/enveomics/Scripts/Table.replace.rb +69 -0
  117. data/utils/enveomics/Scripts/Table.round.rb +63 -0
  118. data/utils/enveomics/Scripts/Table.split.pl +57 -0
  119. data/utils/enveomics/Scripts/Taxonomy.silva2ncbi.rb +227 -0
  120. data/utils/enveomics/Scripts/VCF.KaKs.rb +147 -0
  121. data/utils/enveomics/Scripts/VCF.SNPs.rb +88 -0
  122. data/utils/enveomics/Scripts/aai.rb +421 -0
  123. data/utils/enveomics/Scripts/ani.rb +362 -0
  124. data/utils/enveomics/Scripts/anir.rb +137 -0
  125. data/utils/enveomics/Scripts/clust.rand.rb +102 -0
  126. data/utils/enveomics/Scripts/gi2tax.rb +103 -0
  127. data/utils/enveomics/Scripts/in_silico_GA_GI.pl +96 -0
  128. data/utils/enveomics/Scripts/lib/data/dupont_2012_essential.hmm.gz +0 -0
  129. data/utils/enveomics/Scripts/lib/data/lee_2019_essential.hmm.gz +0 -0
  130. data/utils/enveomics/Scripts/lib/enveomics.R +1 -0
  131. data/utils/enveomics/Scripts/lib/enveomics_rb/anir.rb +293 -0
  132. data/utils/enveomics/Scripts/lib/enveomics_rb/bm_set.rb +175 -0
  133. data/utils/enveomics/Scripts/lib/enveomics_rb/enveomics.rb +24 -0
  134. data/utils/enveomics/Scripts/lib/enveomics_rb/errors.rb +17 -0
  135. data/utils/enveomics/Scripts/lib/enveomics_rb/gmm_em.rb +30 -0
  136. data/utils/enveomics/Scripts/lib/enveomics_rb/jplace.rb +253 -0
  137. data/utils/enveomics/Scripts/lib/enveomics_rb/match.rb +88 -0
  138. data/utils/enveomics/Scripts/lib/enveomics_rb/og.rb +182 -0
  139. data/utils/enveomics/Scripts/lib/enveomics_rb/rbm.rb +49 -0
  140. data/utils/enveomics/Scripts/lib/enveomics_rb/remote_data.rb +74 -0
  141. data/utils/enveomics/Scripts/lib/enveomics_rb/seq_range.rb +237 -0
  142. data/utils/enveomics/Scripts/lib/enveomics_rb/stats/rand.rb +31 -0
  143. data/utils/enveomics/Scripts/lib/enveomics_rb/stats/sample.rb +152 -0
  144. data/utils/enveomics/Scripts/lib/enveomics_rb/stats.rb +3 -0
  145. data/utils/enveomics/Scripts/lib/enveomics_rb/utils.rb +74 -0
  146. data/utils/enveomics/Scripts/lib/enveomics_rb/vcf.rb +135 -0
  147. data/utils/enveomics/Scripts/ogs.annotate.rb +88 -0
  148. data/utils/enveomics/Scripts/ogs.core-pan.rb +160 -0
  149. data/utils/enveomics/Scripts/ogs.extract.rb +125 -0
  150. data/utils/enveomics/Scripts/ogs.mcl.rb +186 -0
  151. data/utils/enveomics/Scripts/ogs.rb +104 -0
  152. data/utils/enveomics/Scripts/ogs.stats.rb +131 -0
  153. data/utils/enveomics/Scripts/rbm-legacy.rb +172 -0
  154. data/utils/enveomics/Scripts/rbm.rb +108 -0
  155. data/utils/enveomics/Scripts/sam.filter.rb +148 -0
  156. data/utils/enveomics/Tests/Makefile +10 -0
  157. data/utils/enveomics/Tests/Mgen_M2288.faa +3189 -0
  158. data/utils/enveomics/Tests/Mgen_M2288.fna +8282 -0
  159. data/utils/enveomics/Tests/Mgen_M2321.fna +8288 -0
  160. data/utils/enveomics/Tests/Nequ_Kin4M.faa +2970 -0
  161. data/utils/enveomics/Tests/Xanthomonas_oryzae-PilA.tribs.Rdata +0 -0
  162. data/utils/enveomics/Tests/Xanthomonas_oryzae-PilA.txt +7 -0
  163. data/utils/enveomics/Tests/Xanthomonas_oryzae.aai-mat.tsv +17 -0
  164. data/utils/enveomics/Tests/Xanthomonas_oryzae.aai.tsv +137 -0
  165. data/utils/enveomics/Tests/a_mg.cds-go.blast.tsv +123 -0
  166. data/utils/enveomics/Tests/a_mg.reads-cds.blast.tsv +200 -0
  167. data/utils/enveomics/Tests/a_mg.reads-cds.counts.tsv +55 -0
  168. data/utils/enveomics/Tests/alkB.nwk +1 -0
  169. data/utils/enveomics/Tests/anthrax-cansnp-data.tsv +13 -0
  170. data/utils/enveomics/Tests/anthrax-cansnp-key.tsv +17 -0
  171. data/utils/enveomics/Tests/hiv1.faa +59 -0
  172. data/utils/enveomics/Tests/hiv1.fna +134 -0
  173. data/utils/enveomics/Tests/hiv2.faa +70 -0
  174. data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv +233 -0
  175. data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv.lim +1 -0
  176. data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv.rec +233 -0
  177. data/utils/enveomics/Tests/low-cov.bg.gz +0 -0
  178. data/utils/enveomics/Tests/phyla_counts.tsv +10 -0
  179. data/utils/enveomics/Tests/primate_lentivirus.ogs +11 -0
  180. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-hiv1.rbm +9 -0
  181. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-hiv2.rbm +8 -0
  182. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-siv.rbm +6 -0
  183. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv2-hiv2.rbm +9 -0
  184. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv2-siv.rbm +6 -0
  185. data/utils/enveomics/Tests/primate_lentivirus.rbm/siv-siv.rbm +6 -0
  186. data/utils/enveomics/build_enveomics_r.bash +45 -0
  187. data/utils/enveomics/enveomics.R/DESCRIPTION +31 -0
  188. data/utils/enveomics/enveomics.R/NAMESPACE +39 -0
  189. data/utils/enveomics/enveomics.R/R/autoprune.R +167 -0
  190. data/utils/enveomics/enveomics.R/R/barplot.R +203 -0
  191. data/utils/enveomics/enveomics.R/R/cliopts.R +141 -0
  192. data/utils/enveomics/enveomics.R/R/df2dist.R +192 -0
  193. data/utils/enveomics/enveomics.R/R/growthcurve.R +349 -0
  194. data/utils/enveomics/enveomics.R/R/prefscore.R +79 -0
  195. data/utils/enveomics/enveomics.R/R/recplot.R +419 -0
  196. data/utils/enveomics/enveomics.R/R/recplot2.R +1698 -0
  197. data/utils/enveomics/enveomics.R/R/tribs.R +638 -0
  198. data/utils/enveomics/enveomics.R/R/utils.R +90 -0
  199. data/utils/enveomics/enveomics.R/README.md +81 -0
  200. data/utils/enveomics/enveomics.R/data/growth.curves.rda +0 -0
  201. data/utils/enveomics/enveomics.R/data/phyla.counts.rda +0 -0
  202. data/utils/enveomics/enveomics.R/man/cash-enve.GrowthCurve-method.Rd +16 -0
  203. data/utils/enveomics/enveomics.R/man/cash-enve.RecPlot2-method.Rd +16 -0
  204. data/utils/enveomics/enveomics.R/man/cash-enve.RecPlot2.Peak-method.Rd +16 -0
  205. data/utils/enveomics/enveomics.R/man/enve.GrowthCurve-class.Rd +25 -0
  206. data/utils/enveomics/enveomics.R/man/enve.TRIBS-class.Rd +47 -0
  207. data/utils/enveomics/enveomics.R/man/enve.TRIBS.merge.Rd +23 -0
  208. data/utils/enveomics/enveomics.R/man/enve.TRIBStest-class.Rd +47 -0
  209. data/utils/enveomics/enveomics.R/man/enve.__prune.iter.Rd +26 -0
  210. data/utils/enveomics/enveomics.R/man/enve.__prune.reduce.Rd +26 -0
  211. data/utils/enveomics/enveomics.R/man/enve.__tribs.Rd +44 -0
  212. data/utils/enveomics/enveomics.R/man/enve.barplot.Rd +111 -0
  213. data/utils/enveomics/enveomics.R/man/enve.cliopts.Rd +67 -0
  214. data/utils/enveomics/enveomics.R/man/enve.col.alpha.Rd +34 -0
  215. data/utils/enveomics/enveomics.R/man/enve.col2alpha.Rd +25 -0
  216. data/utils/enveomics/enveomics.R/man/enve.df2dist.Rd +59 -0
  217. data/utils/enveomics/enveomics.R/man/enve.df2dist.group.Rd +63 -0
  218. data/utils/enveomics/enveomics.R/man/enve.df2dist.list.Rd +46 -0
  219. data/utils/enveomics/enveomics.R/man/enve.growthcurve.Rd +78 -0
  220. data/utils/enveomics/enveomics.R/man/enve.prefscore.Rd +50 -0
  221. data/utils/enveomics/enveomics.R/man/enve.prune.dist.Rd +44 -0
  222. data/utils/enveomics/enveomics.R/man/enve.recplot.Rd +147 -0
  223. data/utils/enveomics/enveomics.R/man/enve.recplot2-class.Rd +45 -0
  224. data/utils/enveomics/enveomics.R/man/enve.recplot2.ANIr.Rd +27 -0
  225. data/utils/enveomics/enveomics.R/man/enve.recplot2.Rd +77 -0
  226. data/utils/enveomics/enveomics.R/man/enve.recplot2.__counts.Rd +28 -0
  227. data/utils/enveomics/enveomics.R/man/enve.recplot2.__peakHist.Rd +24 -0
  228. data/utils/enveomics/enveomics.R/man/enve.recplot2.__whichClosestPeak.Rd +22 -0
  229. data/utils/enveomics/enveomics.R/man/enve.recplot2.changeCutoff.Rd +22 -0
  230. data/utils/enveomics/enveomics.R/man/enve.recplot2.compareIdentities.Rd +52 -0
  231. data/utils/enveomics/enveomics.R/man/enve.recplot2.coordinates.Rd +29 -0
  232. data/utils/enveomics/enveomics.R/man/enve.recplot2.corePeak.Rd +21 -0
  233. data/utils/enveomics/enveomics.R/man/enve.recplot2.extractWindows.Rd +45 -0
  234. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.Rd +34 -0
  235. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__em_e.Rd +23 -0
  236. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__em_m.Rd +24 -0
  237. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__emauto_one.Rd +31 -0
  238. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__mow_one.Rd +56 -0
  239. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.__mower.Rd +20 -0
  240. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.em.Rd +51 -0
  241. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.emauto.Rd +43 -0
  242. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.mower.Rd +82 -0
  243. data/utils/enveomics/enveomics.R/man/enve.recplot2.peak-class.Rd +59 -0
  244. data/utils/enveomics/enveomics.R/man/enve.recplot2.seqdepth.Rd +27 -0
  245. data/utils/enveomics/enveomics.R/man/enve.recplot2.windowDepthThreshold.Rd +36 -0
  246. data/utils/enveomics/enveomics.R/man/enve.selvector.Rd +23 -0
  247. data/utils/enveomics/enveomics.R/man/enve.tribs.Rd +68 -0
  248. data/utils/enveomics/enveomics.R/man/enve.tribs.test.Rd +28 -0
  249. data/utils/enveomics/enveomics.R/man/enve.truncate.Rd +27 -0
  250. data/utils/enveomics/enveomics.R/man/growth.curves.Rd +14 -0
  251. data/utils/enveomics/enveomics.R/man/phyla.counts.Rd +13 -0
  252. data/utils/enveomics/enveomics.R/man/plot.enve.GrowthCurve.Rd +81 -0
  253. data/utils/enveomics/enveomics.R/man/plot.enve.TRIBS.Rd +49 -0
  254. data/utils/enveomics/enveomics.R/man/plot.enve.TRIBStest.Rd +48 -0
  255. data/utils/enveomics/enveomics.R/man/plot.enve.recplot2.Rd +125 -0
  256. data/utils/enveomics/enveomics.R/man/summary.enve.GrowthCurve.Rd +22 -0
  257. data/utils/enveomics/enveomics.R/man/summary.enve.TRIBS.Rd +22 -0
  258. data/utils/enveomics/enveomics.R/man/summary.enve.TRIBStest.Rd +22 -0
  259. data/utils/enveomics/globals.mk +8 -0
  260. data/utils/enveomics/manifest.json +9 -0
  261. data/utils/multitrim/Multitrim How-To.pdf +0 -0
  262. data/utils/multitrim/README.md +67 -0
  263. data/utils/multitrim/multitrim.py +1555 -0
  264. data/utils/multitrim/multitrim.yml +13 -0
  265. metadata +268 -6
@@ -0,0 +1,419 @@
1
+ #' Enveomics: Recruitment Plots
2
+ #'
3
+ #' @description
4
+ #' Produces recruitment plots provided that BlastTab.catsbj.pl has
5
+ #' been previously executed. Requires the \pkg{gplots} library.
6
+ #'
7
+ #' @param prefix
8
+ #' Path to the prefix of the BlastTab.catsbj.pl output files. At
9
+ #' least the files \strong{.rec} and \strong{.lim} must exist with this prefix.
10
+ #' @param id.min
11
+ #' Minimum identity to be considered. By default, the minimum detected
12
+ #' identity. This value is a percentage.
13
+ #' @param id.max
14
+ #' Maximum identity to be considered. By default, 100\%.
15
+ #' @param id.binsize
16
+ #' Size of the identity bins (vertical histograms). By default, 0.1 for
17
+ #' identity metrics and 5 for bit score.
18
+ #' @param id.splines
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.
22
+ #' @param id.metric
23
+ #' Metric of identity to be used (Y-axis). It can be any unambiguous prefix of:
24
+ #' \itemize{
25
+ #' \item "identity"
26
+ #' \item "corrected identity"
27
+ #' \item "bit score"
28
+ #' }
29
+ #' @param id.summary
30
+ #' Method used to build the identity histogram (Horizontal axis of the right
31
+ #' panel). It can be any unambiguous prefix of:
32
+ #' \itemize{
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
+ #' }
41
+ #' The last four options
42
+ #' correspond to the upper and lower boundaries of the 90\% and 95\% empirical
43
+ #' confidence intervals.
44
+ #' @param pos.min
45
+ #' Minimum (leftmost) position in the reference (concatenated) genome (in bp).
46
+ #' @param pos.max
47
+ #' Maximum (rightmost) position in the reference (concatenated) genome (in bp).
48
+ #' By default: Length of the genome.
49
+ #' @param pos.binsize
50
+ #' Size of the position bins (horizontal histograms) in bp.
51
+ #' @param pos.splines
52
+ #' Smoothing parameter for the splines in the position histogram. Zero (0) for
53
+ #' no splines. If non-zero, requires the stats package.
54
+ #' @param rec.col1
55
+ #' Lightest color in the recruitment plot.
56
+ #' @param rec.col2
57
+ #' Darkest color in the recruitment plot.
58
+ #' @param main
59
+ #' Title of the plot.
60
+ #' @param contig.col
61
+ #' Color of the Contig boundaries. Set to \code{NA} to ignore Contig boundaries.
62
+ #' @param ret.recplot
63
+ #' Indicates if the matrix of the recruitment plot is to be returned.
64
+ #' @param ret.hist
65
+ #' Ignored, for backwards compatibility.
66
+ #' @param ret.mode
67
+ #' Indicates if the mode of the identity is to be computed. It requires the
68
+ #' \pkg{modeest} package.
69
+ #' @param id.cutoff
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.
73
+ #' @param verbose
74
+ #' Indicates if the function should report the advance.
75
+ #' @param ...
76
+ #' Any additional graphic parameters to be passed to plot for all panels except
77
+ #' the recruitment plot (lower-left).
78
+ #'
79
+ #' @return
80
+ #'
81
+ #' Returns a list with the following elements:
82
+ #'
83
+ #' \describe{
84
+ #' \item{\code{pos.marks}}{Midpoints of the position histogram.}
85
+ #' \item{\code{id.matrix}}{Midpoints of the identity histogram.}
86
+ #' \item{\code{recplot}}{Matrix containing the recruitment plot values
87
+ #' (if \code{ret.recplot=TRUE}).}
88
+ #' \item{\code{id.mean}}{Mean identity.}
89
+ #' \item{\code{id.median}}{Median identity.}
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}).}
98
+ #' \item{\code{id.max}}{Value of \code{id.max}. This is returned because
99
+ #' \code{id.max=NULL} may vary.}
100
+ #' \item{\code{id.cutoff}}{Value of \code{id.cutoff}.
101
+ #' This is returned because \code{id.cutoff=NULL} may vary.}
102
+ #' \item{\code{seqdepth.mean.top}}{Average sequencing depth with identity above
103
+ #' \code{id.cutoff}.}
104
+ #' \item{\code{seqdepth.mean.low}}{Average sequencing depth with identity below
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.}
114
+ #' \item{\code{id.metric}}{Full name of the used identity metric.}
115
+ #' \item{\code{id.summary}}{Full name of the summary method used to build the
116
+ #' identity plot.}}
117
+ #'
118
+ #' @author Luis M. Rodriguez-R [aut, cre]
119
+ #'
120
+ #' @export
121
+
122
+ enve.recplot <- function(
123
+ prefix,
124
+
125
+ # Id. hist.
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
+
133
+ # Pos. hist.
134
+ pos.min = 1,
135
+ pos.max = NULL,
136
+ pos.binsize = 1e3,
137
+ pos.splines = 0,
138
+
139
+ # Rec. plot
140
+ rec.col1 = "white",
141
+ rec.col2 = "black",
142
+
143
+ # General
144
+ main = NULL,
145
+ contig.col = grey(0.85),
146
+
147
+ # Return
148
+ ret.recplot = FALSE,
149
+ ret.hist = FALSE,
150
+ ret.mode = FALSE,
151
+
152
+ # General
153
+ id.cutoff = NULL,
154
+ verbose = TRUE,
155
+ ...
156
+ ) {
157
+ # Settings
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.")
163
+
164
+ # Read files
165
+ if(verbose) cat("Reading files.\n")
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
+
173
+ # Configure ID summary
174
+ id.summary <- pmatch(id.summary, SUMMARY);
175
+ if(is.na(id.summary)) stop('Invalid identity summary.');
176
+ if(id.summary == -1) stop('Ambiguous identity summary.');
177
+ if(id.summary==1){
178
+ id.summary.func <- function(x) colSums(x);
179
+ id.summary.name <- 'sum'
180
+ }else if(id.summary==2){
181
+ id.summary.func <- function(x) colMeans(x);
182
+ id.summary.name <- 'mean'
183
+ }else if(id.summary==3){
184
+ id.summary.func <- function(x) apply(x,2,median);
185
+ id.summary.name <- 'median'
186
+ }else if(id.summary==4){
187
+ id.summary.func <- function(x) apply(x,2,quantile,probs=0.05,names=FALSE);
188
+ id.summary.name <- '90% LB'
189
+ }else if(id.summary==5){
190
+ id.summary.func <- function(x) apply(x,2,quantile,probs=0.95,names=FALSE);
191
+ id.summary.name <- '90% UB'
192
+ }else if(id.summary==6){
193
+ id.summary.func <- function(x) apply(x,2,quantile,probs=0.025,names=FALSE);
194
+ id.summary.name <- '95% LB'
195
+ }else if(id.summary==7){
196
+ id.summary.func <- function(x) apply(x,2,quantile,probs=0.975,names=FALSE);
197
+ id.summary.name <- '95% UB'
198
+ }
199
+
200
+ # Configure metrics
201
+ id.metric <- pmatch(id.metric, METRICS);
202
+ if(is.na(id.metric)) stop('Invalid identity metric.');
203
+ if(id.metric == -1) stop('Ambiguous identity metric.');
204
+ if(id.metric==1){
205
+ id.reccol <- 3
206
+ id.shortname <- 'Id.'
207
+ id.fullname <- 'Identity'
208
+ id.units <- '%'
209
+ id.hallmarks <- seq(0, 100, by=5)
210
+ if(is.null(id.max)) id.max <- 100
211
+ if(is.null(id.cutoff)) id.cutoff <- 95
212
+ if(is.null(id.binsize)) id.binsize <- 0.1
213
+ }else if(id.metric==2){
214
+ if(ncol(rec)<6) stop("Requesting corrected identity, but .rec file doesn't have 6th column")
215
+ id.reccol <- 6
216
+ id.shortname <- 'cId.'
217
+ id.fullname <- 'Corrected identity'
218
+ id.units <- '%'
219
+ id.hallmarks <- seq(0, 100, by=5)
220
+ if(is.null(id.max)) id.max <- 100
221
+ if(is.null(id.cutoff)) id.cutoff <- 95
222
+ if(is.null(id.binsize)) id.binsize <- 0.1
223
+ }else if(id.metric==3){
224
+ id.reccol <- 4
225
+ id.shortname <- 'BSc.'
226
+ id.fullname <- 'Bit score'
227
+ id.units <- 'bits'
228
+ max.bs <- max(rec[, id.reccol])
229
+ id.hallmarks <- seq(0, max.bs*1.2, by=50)
230
+ if(is.null(id.max)) id.max <- max.bs
231
+ if(is.null(id.cutoff)) id.cutoff <- 0.95 * max.bs
232
+ if(is.null(id.binsize)) id.binsize <- 5
233
+ }
234
+ if(is.null(id.min)) id.min <- min(rec[, id.reccol]);
235
+ if(is.null(pos.max)) pos.max <- max(lim[, 3]);
236
+ id.lim <- c(id.min, id.max);
237
+ pos.lim <- c(pos.min, pos.max)/1e6;
238
+ id.breaks <- round((id.max-id.min)/id.binsize);
239
+ pos.breaks <- round((pos.max-pos.min)/pos.binsize);
240
+ if(is.null(main)) main <- paste('Recruitment plot of ', prefix, sep='');
241
+ pos.marks=seq(pos.min, pos.max, length.out=pos.breaks+1)/1e6;
242
+ id.marks=seq(id.min, id.max, length.out=id.breaks+1);
243
+ id.topclasses <- 0;
244
+ for(i in length(id.marks):1)
245
+ if(id.marks[i]>id.cutoff)
246
+ id.topclasses <- id.topclasses + 1
247
+
248
+ # Set-up image
249
+ layout(matrix(c(3,4,1,2), nrow=2, byrow=TRUE), widths=c(2,1), heights=c(1,2))
250
+ out <- list()
251
+
252
+ # Recruitment plot
253
+ if(verbose) cat("Rec. plot.\n")
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
266
+ }
267
+ }
268
+ }
269
+ id.top <- c((1-id.topclasses):0) + id.breaks;
270
+ rec.col=gplots::colorpanel(256, rec.col1, rec.col2);
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)
281
+ abline(h=id.hallmarks, lty=2, col=grey(0.7));
282
+ abline(h=id.marks[id.top[1]], lty=3, col=grey(0.5))
283
+ legend('bottomleft', 'Rec. plot', bg=rgb(1,1,1,2/3));
284
+ out <- c(out, list(pos.marks=pos.marks, id.marks=id.marks));
285
+ if(ret.recplot) out <- c(out, list(recplot=rec.hist));
286
+
287
+ # Identity histogram
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
+ )
295
+ id.x <- rep(id.marks, each=2)[2:(id.breaks*2+1)]
296
+ id.f <- rep(id.hist, each=2)[1:(id.breaks*2)]
297
+ if(sum(id.f)>0){
298
+ lines(id.f, id.x, lwd=ifelse(id.splines>0, 1/2, 2), type = "o", pch = ".")
299
+ if(id.splines>0){
300
+ id.spline <- smooth.spline(
301
+ id.x[id.f > 0], log(id.f[id.f > 0]), spar = id.splines
302
+ )
303
+ lines(exp(id.spline$y), id.spline$x, lwd=2)
304
+ }
305
+ }
306
+
307
+ abline(h=id.hallmarks, lty=2, col=grey(0.7));
308
+ abline(h=id.marks[id.top[1]], lty=3, col=grey(0.5))
309
+ legend('bottomright', paste(id.shortname, 'histogram'), bg=rgb(1,1,1,2/3));
310
+ out <- c(out, list(id.mean=mean(rec[, id.reccol])));
311
+ out <- c(out, list(id.median=median(rec[, id.reccol])));
312
+ if(ret.hist) out <- c(out, list(id.hist=id.hist));
313
+
314
+ # Position histogram
315
+ if(verbose) cat("Pos. hist.\n")
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
326
+
327
+ ymin <- min(1, h1[h1>0], h2[h2>0]);
328
+ ymax <- max(10, h1, h2);
329
+ if(is.na(ymin) || ymin<=0) ymin <- 1e-10;
330
+ if(is.na(ymax) || ymax<=0) ymax <- 1;
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)
337
+ abline(h=10^c(0:5), lty=2, col=grey(0.7));
338
+ if(sum(h2)>0){
339
+ h2.x <- rep(pos.marks, each=2)[2:(pos.breaks*2+1)]
340
+ h2.y <- rep(h2, each=2)[1:(pos.breaks*2)]
341
+ lines(h2.x, h2.y, lwd=ifelse(pos.splines>0, 1/2, 2), col=grey(0.5));
342
+ if(pos.splines>0){
343
+ h2.spline <- smooth.spline(
344
+ h2.x[h2.y > 0], log(h2.y[h2.y > 0]), spar = pos.splines
345
+ )
346
+ lines(h2.spline$x, exp(h2.spline$y), lwd=2, col=grey(0.5))
347
+ }
348
+ if(ret.hist) out <- c(out, list(pos.hist.low=h2.y));
349
+ }
350
+ if(sum(h1)>0){
351
+ h1.x <- rep(pos.marks, each=2)[2:(pos.breaks*2+1)]
352
+ h1.y <- rep(h1, each=2)[1:(pos.breaks*2)]
353
+ lines(h1.x, h1.y, lwd=ifelse(pos.splines>0, 1/2, 2), col=grey(0));
354
+ if(pos.splines>0){
355
+ h1.spline <- smooth.spline(
356
+ h1.x[h1.y > 0], log(h1.y[h1.y > 0]), spar = pos.splines
357
+ )
358
+ lines(h1.spline$x, exp(h1.spline$y), lwd=2, col=grey(0))
359
+ }
360
+ if(ret.hist) out <- c(out, list(pos.hist.top=h1.y))
361
+ }
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))
372
+
373
+ # Legend
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)
387
+ for(i in 1:10){
388
+ for(j in 1:10){
389
+ k <- (i-1)*10 + j;
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
+ )
395
+ }
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
+ )
400
+ }
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
+ }
419
+