-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #807 from d4straub/TreeSummarizedExperiment
Export TreeSummarizedExperiment R object
- Loading branch information
Showing
25 changed files
with
238 additions
and
80 deletions.
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 ? | ||
'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 | ||
} | ||
# 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.