Mercurial > repos > matthias > dada2_makesequencetable
changeset 5:ec4a183cc713 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:37:14 -0400 |
| parents | 383501d6aeb0 |
| children | 55ca9eb3410f |
| files | README.md dada2_makeSequenceTable.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, 2693 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Sun May 05 12:37:14 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_makeSequenceTable.xml Mon Apr 29 09:52:30 2019 -0400 +++ b/dada2_makeSequenceTable.xml Sun May 05 12:37:14 2019 -0400 @@ -11,6 +11,7 @@ <configfiles> <configfile name="dada2_script"><![CDATA[ @READ_FOO@ +@WRITE_FOO@ library(dada2, quietly=T) #if $plot == "yes" @@ -19,16 +20,11 @@ samples <- list() #for $s in $samples: - #if $len($samples) == 1 - samples <- readRDS('$s') - #else samples[["$s.element_identifier"]] <- readRDS('$s') - #end if #end for -## make sequence table + seqtab <- makeSequenceTable(samples, orderBy = "$orderBy") - reads.per.seqlen <- tapply(colSums(seqtab), factor(nchar(getSequences(seqtab))), sum) df <- data.frame(length=as.numeric(names(reads.per.seqlen)), count=reads.per.seqlen) @@ -45,14 +41,13 @@ ## filter by seqlengths #if $filter_cond.filter_select != "no" - seqtab <- seqtab[, nchar(colnames(seqtab)) %in% seq($filter_cond.min, $filter_cond.max)] + seqtab <- seqtab[, nchar(colnames(seqtab)) %in% seq($filter_cond.min, $filter_cond.max), drop=F] #end if - -write.table(seqtab, "$stable", quote=F, sep="\t", row.names = T, col.names = NA) +write.data( seqtab, '$stable', "dada2_sequencetable" ) ]]></configfile> </configfiles> <inputs> - <param name="samples" type="data" multiple="true" format="@DADA_UNIQUES@" label="samples" /> + <param argument="samples" type="data" multiple="true" format="@DADA_UNIQUES@" label="samples" /> <param argument="orderBy" type="select" label="Column order"> <option value="abundance">abundance</option> <option value="nsamples">nsamples</option> @@ -77,9 +72,18 @@ </data> </outputs> <tests> - <test> + <test expect_num_outputs="2"> <param name="samples" ftype="dada2_mergepairs" value="mergePairs_F3D0.Rdata"/> <output name="stable" value="makeSequenceTable_F3D0.tab" ftype="dada2_sequencetable" /> + <output name="plot_output" value="makeSequenceTable_F3D0.pdf" ftype="pdf" /> + </test> + <test expect_num_outputs="1"> + <param name="samples" ftype="dada2_mergepairs" value="mergePairs_F3D0.Rdata"/> + <param name="filter_cond|filter_select" value="minmax"/> + <param name="filter_cond|min" value="200"/> + <param name="filter_cond|max" value="300"/> + <param name="plot" value="no" /> + <output name="stable" value="makeSequenceTable_F3D0.tab" ftype="dada2_sequencetable" /> </test> </tests> <help><![CDATA[
--- a/macros.xml Mon Apr 29 09:52:30 2019 -0400 +++ b/macros.xml Sun May 05 12:37:14 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@"><