-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export TreeSummarizedExperiment R object #807
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e24f4f5
add --phyloseq and --treesummarizedexperiment
d4straub cf4eeba
fix import to TREESUMMARIZEDEXPERIMENT
d4straub bd7a1ff
export phyloseq and tse by default
d4straub cf1424e
container to lower case
d4straub 826d7b7
fix container address
d4straub e982b0c
fix docker container address
d4straub 565f940
fix reading a tree
d4straub 945c946
add referenceSeq
d4straub 1a2e039
add nwk tree
d4straub c7a322d
update docs
d4straub f442540
add TreeSE to report
d4straub 59582a6
fix report section
d4straub d9c0cc9
add citation
d4straub ef6c984
update tests
d4straub 5af4545
omitting QIMME2 tree when QIIME2 isnt executed
d4straub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,6 @@ params { | |
|
||
// Prevent default taxonomic classification | ||
skip_dada_taxonomy = true | ||
|
||
skip_phyloseq = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,6 @@ params { | |
|
||
// Skip downstream analysis with QIIME2 | ||
skip_qiime_downstream = true | ||
|
||
skip_tse = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
process TREESUMMARIZEDEXPERIMENT { | ||
tag "$prefix" | ||
label 'process_low' | ||
|
||
conda "bioconda::bioconductor-treesummarizedexperiment=2.10.0" | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
d4straub marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'https://depot.galaxyproject.org/singularity/bioconductor-treesummarizedexperiment:2.10.0--r43hdfd78af_0' : | ||
'biocontainers/bioconductor-treesummarizedexperiment:2.10.0--r43hdfd78af_0' }" | ||
|
||
input: | ||
tuple val(prefix), path(tax_tsv), path(otu_tsv) | ||
path sam_tsv | ||
path tree | ||
|
||
output: | ||
tuple val(prefix), path("*TreeSummarizedExperiment.rds"), emit: rds | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def sam_tsv = "\"${sam_tsv}\"" | ||
def otu_tsv = "\"${otu_tsv}\"" | ||
def tax_tsv = "\"${tax_tsv}\"" | ||
def tree = "\"${tree}\"" | ||
def prefix = "\"${prefix}\"" | ||
""" | ||
#!/usr/bin/env Rscript | ||
|
||
suppressPackageStartupMessages(library(TreeSummarizedExperiment)) | ||
|
||
# Read otu table. It must be in a SimpleList as a matrix where rows | ||
# represent taxa and columns samples. | ||
otu_mat <- read.table($otu_tsv, sep="\\t", header=TRUE, row.names=1) | ||
otu_mat <- as.matrix(otu_mat) | ||
assays <- SimpleList(counts = otu_mat) | ||
# Read taxonomy table. Correct format for it is DataFrame. | ||
taxonomy_table <- read.table($tax_tsv, sep="\\t", header=TRUE, row.names=1) | ||
taxonomy_table <- DataFrame(taxonomy_table) | ||
|
||
# Match rownames between taxonomy table and abundance matrix. | ||
taxonomy_table <- taxonomy_table[match(rownames(otu_mat), rownames(taxonomy_table)), ] | ||
|
||
# Create TreeSE object. | ||
tse <- TreeSummarizedExperiment( | ||
assays = assays, | ||
rowData = taxonomy_table | ||
) | ||
|
||
# If taxonomy table contains sequences, move them to referenceSeq slot | ||
if (!is.null(rowData(tse)[["sequence"]])) { | ||
referenceSeq(tse) <- DNAStringSet( rowData(tse)[["sequence"]] ) | ||
rowData(tse)[["sequence"]] <- NULL | ||
} | ||
|
||
# If provided, we add sample metadata as DataFrame object. rownames of | ||
# sample metadata must match with colnames of abundance matrix. | ||
if (file.exists($sam_tsv)) { | ||
sample_meta <- read.table($sam_tsv, sep="\\t", header=TRUE, row.names=1) | ||
sample_meta <- sample_meta[match(colnames(tse), rownames(sample_meta)), ] | ||
sample_meta <- DataFrame(sample_meta) | ||
colData(tse) <- sample_meta | ||
d4straub marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
# If provided, we add phylogeny. The rownames in abundance matrix must match | ||
# with node labels in phylogeny. | ||
if (file.exists($tree)) { | ||
phylogeny <- ape::read.tree($tree) | ||
rowTree(tse) <- phylogeny | ||
} | ||
|
||
saveRDS(tse, file = paste0($prefix, "_TreeSummarizedExperiment.rds")) | ||
|
||
# Version information | ||
writeLines(c("\\"${task.process}\\":", | ||
paste0(" R: ", paste0(R.Version()[c("major","minor")], collapse = ".")), | ||
paste0(" TreeSummarizedExperiment: ", packageVersion("TreeSummarizedExperiment"))), | ||
"versions.yml" | ||
) | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Create phyloseq objects | ||
*/ | ||
|
||
include { PHYLOSEQ } from '../../modules/local/phyloseq' | ||
include { PHYLOSEQ_INASV } from '../../modules/local/phyloseq_inasv' | ||
include { TREESUMMARIZEDEXPERIMENT } from '../../modules/local/treesummarizedexperiment' | ||
|
||
workflow ROBJECT_WORKFLOW { | ||
take: | ||
ch_tax | ||
ch_tsv | ||
ch_meta | ||
ch_robject_intree | ||
run_qiime2 | ||
|
||
main: | ||
ch_versions_robject_workflow = Channel.empty() | ||
|
||
if ( params.metadata ) { | ||
ch_robject_inmeta = ch_meta.first() // The .first() is to make sure it's a value channel | ||
} else { | ||
ch_robject_inmeta = [] | ||
} | ||
|
||
if ( run_qiime2 ) { | ||
if ( params.exclude_taxa != "none" || params.min_frequency != 1 || params.min_samples != 1 ) { | ||
ch_robject_inasv = PHYLOSEQ_INASV ( ch_tsv ).tsv | ||
} else { | ||
ch_robject_inasv = ch_tsv | ||
} | ||
} else { | ||
ch_robject_inasv = ch_tsv | ||
} | ||
|
||
if ( !params.skip_phyloseq ) { | ||
PHYLOSEQ ( ch_tax.combine(ch_robject_inasv), ch_robject_inmeta, ch_robject_intree ) | ||
ch_versions_robject_workflow = ch_versions_robject_workflow.mix(PHYLOSEQ.out.versions) | ||
} | ||
|
||
if ( !params.skip_tse ) { | ||
TREESUMMARIZEDEXPERIMENT ( ch_tax.combine(ch_robject_inasv), ch_robject_inmeta, ch_robject_intree ) | ||
ch_versions_robject_workflow = ch_versions_robject_workflow.mix(TREESUMMARIZEDEXPERIMENT.out.versions) | ||
} | ||
|
||
emit: | ||
phyloseq = !params.skip_phyloseq ? PHYLOSEQ.out.rds : [] | ||
tse = !params.skip_tse ? TREESUMMARIZEDEXPERIMENT.out.rds : [] | ||
versions = ch_versions_robject_workflow | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks pretty straight forward, any reason why this is not an official nf-core module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First we needed to find a usable implementation, this is now done, now it seems just laziness on my part, but we can call it time efficiency or priorities are on other stuff or just 24h/day instead of 240h/day.