Comparison of observed sequences to expected#1021
Conversation
erikrikarddaniel
left a comment
There was a problem hiding this comment.
Looks fine, and I see the point.
It strikes me, however, that this might be better implemented as a separate pipeline that reads ampliseq output files. If a user always uses --outdir results the parameters could even be reused between calls, except maybe for the path to the mock/expected data. I believe this would be easier in terms of maintenance, particularly for new features of this type. (I can imagine building some sort of test on ecological distances between observed and expected mock structure.) Maybe this could one day be turned into a more general tool also applicable for e.g. metagenome and metatranscriptome mock data.
With metapipelines coming one day, calling the two pipelines would be easier too.
Happy to have in Ampliseq, and happy to discuss more.
d4straub
left a comment
There was a problem hiding this comment.
Thanks @erikrikarddaniel for the review and discussion! I found a few more points, I would be happy to hear your thoughts on them, if you have the time.
It strikes me, however, that this might be better implemented as a separate pipeline that reads ampliseq output files. If a user always uses --outdir results the parameters could even be reused between calls, except maybe for the path to the mock/expected data. I believe this would be easier in terms of maintenance, particularly for new features of this type.
Yes, that would be possibly a good idea.
| if( !all(exp$ID %in% blast6out$target) ) { | ||
| print(paste("WARN - Some expected sequences of",expabundFILE,"are not in the alignment results. The following are missing:",paste( unique(exp$ID[!exp$ID %in% blast6out$target]),collapse=","))) | ||
| } | ||
| blast6out <- merge(blast6out,exp, by.x='target', by.y='ID', all.x=TRUE, all.y=TRUE) |
There was a problem hiding this comment.
This is dangerous in case column names overlap. This can be if at least one sample name is identical to a column name of the VSEARCH output. The likelihood can be reduced by minimizing VSEARCH output columns and adding a test whether column names and samples overlap. Do you agree?
There was a problem hiding this comment.
When samples are column names this is of course a risk one should look for. Personally, I only work with "long" tables, i.e. tables with, typically, three or four columns: sample, asv_id, count (and relab if I've calculated relative abundance). This avoids the problem you see here, and makes data smaller since one can remove zeroes.
There was a problem hiding this comment.
Thats a great point. I didnt consider that. I'll think about it.
There was a problem hiding this comment.
While a long format would have been a great solution, it would need some adaptions. So I omitted merging tables that could have identical column names. This way it works as well, no conflicts possible whatsoever.
|
Thanks a lot for your advice!! |
I think it would be a good idea to have a comparison of observed versus expected results for sequences, abundances, and taxonomic assignments for mock samples and the like.
This PR adds a first step, comparing observed ASV sequences against expected reference sequence(s) and report sequence mismatches/match rates.
Included steps:
--expected_sequences(fasta file) withVSEARCH --usearchglobal--expected_abundanceswill filter for each sample the expected sequences (without it, it is assumed that all samples have all sequences in--expected_sequences)Example barplot:

Also added a CI test, data via nf-core/test-datasets#2117
Further PRs might add in tentative priority
(1) FN/FP/TP, F1 score of (perfect) matching sequences and
(2) evaluate how abundances compare to expected
(3) compare taxonomic classification to expected
PR checklist
nf-core pipelines lint).nextflow run . -profile test,docker --outdir <OUTDIR>).nextflow run . -profile debug,test,docker --outdir <OUTDIR>).docs/usage.mdis updated.docs/output.mdis updated.CHANGELOG.mdis updated.README.mdis updated (including new tool citations and authors/contributors).