Mercurial > repos > matthias > dada2_removebimeradenovo
changeset 5:b4802fe2e460 draft
planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/tree/topic/dada2/tools/dada2 commit 990192685955e9cda0282e348c28ef6462d88a38
| author | matthias |
|---|---|
| date | Sun, 05 May 2019 12:30:19 -0400 |
| parents | 92e7321fcb1e |
| children | 3ae8753d8945 |
| files | README.md dada2_removeBimeraDenovo.xml macros.xml test-data/.reference.fa.swp test-data/.reference_species.fa.swp test-data/assignTaxonomyAddspecies_F3D0_boot.tab test-data/filterAndTrim_F3D0.tab test-data/makeSequenceTable_F3D0.pdf test-data/makeSequenceTable_F3D0.tab test-data/mergePairs_F3D0_nondefault.Rdata test-data/qualityProfile.pdf test-data/removeBimeraDenovo_F3D0.tab test-data/removeBimeraDenovo_F3D0_dada_uniques.tab test-data/removeBimeraDenovo_F3D0_derep_uniques.tab test-data/removeBimeraDenovo_F3D0_mergepairs.Rdata test-data/seqCounts_F3D0_dadaF.tab test-data/seqCounts_F3D0_derepF.tab test-data/seqCounts_F3D0_filter.tab test-data/seqCounts_F3D0_merge.tab test-data/seqCounts_F3D0_nochim.tab test-data/seqCounts_F3D0_seqtab.tab todo.txt |
| diffstat | 22 files changed, 2711 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Sun May 05 12:30:19 2019 -0400 @@ -0,0 +1,39 @@ +Wrappers for the core functionality of the dada2 package https://benjjneb.github.io/dada2/index.html. + +- filterAndTrim +- derep +- learnErrors +- dada +- mergePairs +- makeSequenceTable +- removeBimeraDenovo + +Datatypes +========= + +The dada2 Galaxy wrappers use a few extra data types to ensure that only inputs of the correct type can be used. + +For the outputs of derep, dada, learnErrors, and mergePairs the following datatypes are used that derive from Rdata (which contains the named list that is returned from the corresponding dada function): + +- dada2_derep (Rdata: named list see docs for derep-class) +- dada2_dada (Rdata: named list, see docs for dada-class) +- dada2_errorrates (Rdata: named list, see docs for learnErrors) +- dada2_mergepairs (Rdata: named list, see docs for mergePairs) + +For the outputs of makeSequenceTable and removeBimeraDenovo the following data types are used which derive from tabular: + +- dada2_uniques +-- in R a named integer vector (names are the unique sequences) +-- in Galaxy written as a table (each row corresponding to a unique sequence, column 1: the sequence, column 2: the count) +- dada2_sequencetable +-- in R a named integer matrix (rows = samples, columns = unique sequences) +-- in Galaxy written as a table (rows = unique sequences, columns = samples) + +Note the difference between the R and Galaxy representations! The main motivation is that the dada2_sequencetable is analogous to OTU tables as produced for instance by qiime (and it seemed natural to extend this to the uniques which are essentially a sequencetables of single samples). + + +TODOs +===== + +- implememt getUniques tool to view intermediate results? +- implement tests for cached reference data
--- a/dada2_removeBimeraDenovo.xml Mon Apr 29 09:50:41 2019 -0400 +++ b/dada2_removeBimeraDenovo.xml Sun May 05 12:30:19 2019 -0400 @@ -6,44 +6,39 @@ <expand macro="requirements"/> <expand macro="version_command"/> <command detect_errors="exit_code"><![CDATA[ - #if $unqs.is_of_type('dada.derep') or $unqs.is_of_type('dada2_dada') - mkdir '$stable_uniques.extra_files_path' && - #end if - Rscript '$dada2_script' +Rscript '$dada2_script' ]]></command> <configfiles> <configfile name="dada2_script"><![CDATA[ library(dada2, quietly=T) -#if $unqs.is_of_type('dada2_derep') or $unqs.is_of_type('dada2_dada') or $unqs.is_of_type('dada2_mergepairs') - unqs <- readRDS(file.path('$unqs.extra_files_path', 'Rdata')) -#else if $unqs.is_of_type('dada2_sequencetable') - unqs <- as.matrix( read.table('$unqs', header=T, sep="\t", row.names=1) ) -#else - write("error: unknown input type", stderr()) - quit(1) -#end if +@READ_FOO@ +@WRITE_FOO@ -nonchim <- removeBimeraDenovo(unqs, method = "$method") +unqs <- $read_data($unqs) + +seqtab.nochim <- removeBimeraDenovo(unqs, method = "$method") ## - output is data.frame (mergepairs) or sequencetable (if this was the input) -## - otherwise uniques-vector +## in the former case the (multi item) list is stored as RDS +## in the latter case the named int matrix is stored as tabular (rows=samples, columns=ASVs) +## - otherwise uniques-vector, i.e. a named integer vector -#if $unqs.is_of_type('dada.derep') or $unqs.is_of_type('dada2_dada') -# write.table(nonchim, file = '$stable_uniques', quote = F, sep = "\t", row.names = T, col.names = F) - saveRDS(nonchim, file='$stable_uniques) +#if $unqs.is_of_type('dada2_derep') or $unqs.is_of_type('dada2_dada') + write.data( seqtab.nochim, '$stable_uniques', "dada2_uniques" ) #else if $unqs.is_of_type('dada2_sequencetable') - write.table(nonchim, "$stable_sequencetable", quote=F, sep="\t", row.names = T, col.names = NA) + write.data( seqtab.nochim, '$stable_sequencetable', "dada2_sequencetable" ) #else if $unqs.is_of_type('dada2_mergepairs') - write.table(nonchim, "$stable_mergepairs", quote=F, sep="\t") + write.data( seqtab.nochim, '$stable_mergepairs', "dada2_mergepairs" ) #end if ## dada input if(class(unqs)=="list"){ unqssum<-lapply(lapply(unqs, getUniques),sum) - nonchimsum<-lapply(nonchim,sum) + outsum<-lapply(seqtab.nochim,sum) mapply(function(X,Y) { 100*X/Y }, X=nonchimsum, Y=unqssum) + cat("remaining nonchimeric: ", mapply(function(X,Y) { 100*X/Y }, X=nonchimsum, Y=unqssum), "%") }else{ - cat("remaining nonchimeric: ", 100*sum(getUniques(nonchim))/sum(getUniques(unqs)), "%") + cat("remaining nonchimeric: ", 100*sum(getUniques(seqtab.nochim))/sum(getUniques(unqs)), "%") } ]]></configfile> </configfiles> @@ -72,6 +67,22 @@ <param name="unqs" ftype="dada2_sequencetable" value="makeSequenceTable_F3D0.tab"/> <output name="stable_sequencetable" value="removeBimeraDenovo_F3D0.tab" ftype="dada2_sequencetable" /> </test> + <!-- derep input --> + <test> + <param name="unqs" ftype="dada2_derep" value="derepFastq_F3D0_R1.Rdata"/> + <output name="stable_uniques" value="removeBimeraDenovo_F3D0_derep_uniques.tab" ftype="dada2_uniques" /> + </test> + <!-- dada input --> + <test> + <param name="unqs" ftype="dada2_dada" value="dada_F3D0_R1.Rdata"/> + <output name="stable_uniques" value="removeBimeraDenovo_F3D0_dada_uniques.tab" ftype="dada2_uniques" /> + </test> + <!-- mergepairs input + non default--> + <test> + <param name="unqs" ftype="dada2_mergepairs" value="mergePairs_F3D0.Rdata"/> + <output name="stable_mergepairs" value="removeBimeraDenovo_F3D0_mergepairs.Rdata" ftype="dada2_mergepairs" /> + <param name="method" value="pooled"/> + </test> </tests> <help><![CDATA[ Description @@ -80,9 +91,7 @@ This tool can be used to remove chimeric sequences, i.e. sequences that can be constructed by combining a left-segment and a right-segment from two more abundant “parent” sequences.. Two methods to identify chimeras are supported: Identification from pooled sequences and identification by consensus across samples. - from **pooled** sequences: Each sequence is evaluated against a set of "parents" drawn from the sequence collection that are sufficiently more abundant than the sequence being evaluated. Sequences that are bimera are removed, i.e. a two-parent chimera, in which the left side is made up of one parent sequence, and the right-side made up of a second parent sequence. -- by **consensus** In short, bimeric sequences are flagged on a sample-by-sample basis. Then, a vote is performed for each sequence across all samples in which it appeared. If the sequence is flagged in a sufficiently high fraction of samples, it is identified as a bimera. A logical vector is returned, with an entry for each sequence in -the table indicating whether it was identified as bimeric by this consensus procedure. - +- by **consensus**: In short, bimeric sequences are flagged on a sample-by-sample basis. Then, a vote is performed for each sequence across all samples in which it appeared. If the sequence is flagged in a sufficiently high fraction of samples, it is identified as a bimera. A logical vector is returned, with an entry for each sequence in the table indicating whether it was identified as bimeric by this consensus procedure. Usage .....
--- a/macros.xml Mon Apr 29 09:50:41 2019 -0400 +++ b/macros.xml Sun May 05 12:30:19 2019 -0400 @@ -25,23 +25,44 @@ <token name="@DADA_UNIQUES@">dada2_derep,dada2_dada,dada2_mergepairs</token> + <!-- function to read dada2 data types + - derep, dada, and mergepairs are simply read as RDS + - sequence_table is a named integer matrix (rows=samples, columns=ASVs) + - uniques is a named integer vector (columns=ASVs, only one rows)--> <token name="@READ_FOO@"><![CDATA[ + read.uniques <- function ( fname ) { + p <- read.table(fname, header=F, sep="\t") + n <-x[,2] + names(n)<-x[,1] + } #def read_data($dataset) - #if $dataset.is_of_type('dada2_derep') - readRDS('$dataset) - #else if $dataset.is_of_type('dada2_dada') + #if $dataset.is_of_type('dada2_sequencetable') + t(as.matrix( read.table('$dataset', header=T, sep="\t", row.names=1) )) + #else if $dataset.is_of_type('dada2_uniques') + read.uniques('$dataset') + #else if $dataset.is_of_type('tabular') + read.table('$dataset', header=T, sep="\t", row.names=1) + #else readRDS('$dataset') - #else if $dataset.is_of_type('dada2_sequencetable') - as.matrix( read.table('$dataset', header=T, sep="\t", row.names=1) ) - #else if $dataset.is_of_type('dada2_mergepairs') - readRDS('$dataset') - #else if $dataset.is_of_type('tabular') - read.table('$dataset', header=T, sep="\t", row.names=1 ) - #else - #raise Exception("error: unknown input type") #end if #end def ]]></token> + <!-- function to write dada2 data types (the content or the R variable 'out' is written) + - derep, dada, and mergepairs are written as RDS + - sequence_table is a named integer matrix (rows=samples, columns=ASVs) + - uniques is a named integer vector (columns=ASVs, only one rows)--> + <token name="@WRITE_FOO@"><![CDATA[ +write.data <- function( data, fname, type ){ + if( type == 'dada2_uniques'){ + write.table(data, file = fname, quote = F, sep = "\t", row.names = T, col.names = F) + }else if( type== 'dada2_sequencetable'){ + write.table(t(data), file=fname, quote=F, sep="\t", row.names = T, col.names = NA) + }else{ + saveRDS(data, file=fname) + } +} + ]]></token> + <!-- for filterAndTrim --> <xml name="trimmers"> <section name="trim" title="Trimming parameters"> @@ -63,9 +84,9 @@ <xml name="errorEstimationFunction"> <param name="errfoo" argument="errorEstimationFunction" type="select" label="Error function"> - <option value="loessErrfun">loess</option> - <option value="noqualErrfun">noqual</option> - <option value="PacBioErrfun">PacBio</option> + <option value="loessErrfun">loess: Use a loess fit to estimate error rates from transition counts</option> + <option value="noqualErrfun">noqual: Estimate error rates for each type of transition while ignoring quality scores.</option> + <option value="PacBioErrfun">PacBio: Estimate error rates from transition counts in PacBio CCS data.</option> </param> </xml> <token name="@HELP_OVERVIEW@"><