Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### `Fixed`

- [#927](https://github.com/nf-core/mag/pull/927) - MetaBinner now succeeds when no contigs are too short or all are binned (by @d4straub)
- [#929](https://github.com/nf-core/mag/pull/929) - Allow the domain_classification.R script to run with any assembler, not just Megahit or Spades (reported by @MicroSeq, fix by @prototaxites)

### `Dependencies`

Expand Down
31 changes: 10 additions & 21 deletions bin/domain_classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ parser <- add_option(parser, c("-j", "--join_prokaryotes"),
default = TRUE,
metavar = "logical",
help = "Use an general prokaryote classification instead of separating Archaea and Bacteria.")
parser <- add_option(parser, c("-a", "--assembler"),
action = "store",
type = "character",
metavar = "character",
help = "Assembler used to assemble the contigs. 'MEGAHIT' or 'SPAdes' only.")
parser <- add_option(parser, c("-o", "--output_prefix"),
action = "store",
type = "character",
Expand All @@ -42,12 +37,6 @@ if(is.null(args$classification_file)) {
if(is.null(args$contig_to_bin)) {
stop("Contig to bin file not provided.")
}
if(is.null(args$assembler)) {
stop("Assembler not provided.")
}
if(!(args$assembler %in% c("MEGAHIT", "SPAdes"))) {
stop("Invalid assembler provided.")
}

find_classification <- function(probabilities, join_prokaryotes = TRUE) {
if(join_prokaryotes) {
Expand All @@ -58,14 +47,13 @@ find_classification <- function(probabilities, join_prokaryotes = TRUE) {
return(classifications[which.max(probabilities)])
}

classify_bins <- function(tiara, contig2bin, join_prokaryotes, assembler){
## MEGAHIT produces contigs with spaces in the name
classify_bins <- function(tiara, contig2bin, join_prokaryotes){
## Some assemblers produce contigs with spaces in the name
## Depending on the binner, everything after the first space is sometimes dropped
## Make sure that we drop everything after a possible space before doing anything else to allow merging
if(assembler == "MEGAHIT"){
tiara$sequence_id <- word(tiara$sequence_id)
contig2bin$sequence_id <- word(contig2bin$sequence_id)
}
tiara$sequence_id <- word(tiara$sequence_id)
contig2bin$sequence_id <- word(contig2bin$sequence_id)

if(join_prokaryotes) {
n_classifications <- 4
} else {
Expand Down Expand Up @@ -140,10 +128,11 @@ classify_bins <- function(tiara, contig2bin, join_prokaryotes, assembler){
classifications <- read_tsv(args$classification_file, na = c("NA", "n/a"))
contig_to_bin <- read_tsv(args$contig_to_bin, col_names = c("sequence_id", "BinID"))

results <- classify_bins(tiara = classifications,
contig2bin = contig_to_bin,
join_prokaryotes = args$join_prokaryotes,
assembler = args$assembler)
results <- classify_bins(
tiara = classifications,
contig2bin = contig_to_bin,
join_prokaryotes = args$join_prokaryotes
)

## Keep just the classifications so we can loop over more easily
results_basic <- select(results, BinID, classification)
Expand Down
2 changes: 1 addition & 1 deletion conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ process {
}

withName: TIARA_CLASSIFY {
ext.args = { "--join_prokaryotes --assembler ${meta.assembler}" }
ext.args = { "--join_prokaryotes" }
ext.prefix = { "${meta.assembler}-${meta.binner}-${meta.bin}-${meta.id}" }
}

Expand Down
2 changes: 1 addition & 1 deletion nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config {
profile "test"

// list of filenames or patterns that should be trigger a full test run
triggers 'nextflow.config', 'nf-test.config', 'conf/test.config', 'tests/nextflow.config', 'tests/.nftignore'
triggers 'nextflow.config', 'nf-test.config', 'conf/test.config', 'tests/nextflow.config', 'tests/.nftignore', 'bin/*'

// load the necessary plugins
plugins {
Expand Down
Loading