diff --git a/src/bin/kmerclust.R b/src/bin/kmerclust.R index 786f1dd9f26590d8d584435eaeec4bc0adf98d82..582d80d72658960a7d1739f622f23d98efa8876f 100644 --- a/src/bin/kmerclust.R +++ b/src/bin/kmerclust.R @@ -8,15 +8,8 @@ data <- readr::read_tsv(args[2], show_col_types = FALSE) format(object.size(data), units = "Mb") annotation <- parse_annotation(args[1]) count <- annotate_counts(annotation, data, args[3]) -save(count, file = paste0(args[3], ".Rdata")) res <- compare_models(count %>% dplyr::ungroup(), nboot = 100, bootsize = 0.1, core = as.numeric(args[4])) + +save(count, file = paste0(args[3], ".Rdata")) save(res, file = paste0(args[3], "_boot.Rdata")) -res %>% - ggplot(aes(x = name, y = BIC)) + - geom_violin() -ggsave(paste0(args[3], "_BIC.pdf")) -res %>% - ggplot(aes(x = name, y = WSS_f / BSS)) + - geom_violin() -ggsave(paste0(args[3], "_WSS_BSS.pdf")) diff --git a/src/main.nf b/src/main.nf index bbafd2eb618b221832820cfb941b24fd0ff67738..d747c7a750d8231be39fda38bbe167789b7fe26a 100644 --- a/src/main.nf +++ b/src/main.nf @@ -8,8 +8,9 @@ params.kmer_size = 12 include { SPLIT } from "./modules/split" include { FASTKMERS } from "./modules/fastkmers" include { MERGEKMER } from "./modules/mergekmer" -include { COLLATEKMER} from "./modules/mergekmer" -include { KMERCLUST} from "./modules/kmerclust" +include { COLLATEKMER } from "./modules/mergekmer" +include { KMERCLUST } from "./modules/kmerclust" +include { KMERCLUST_PLOT } from "./modules/kmerclust" Channel.fromPath( file(params.csv) ) @@ -30,4 +31,5 @@ workflow { MERGEKMER(FASTKMERS.out.csv.groupTuple()) COLLATEKMER(MERGEKMER.out.csv.map{it -> [it[0].specie, it[1]] }.groupTuple()) KMERCLUST(COLLATEKMER.out.csv, params_csv.collect()) + KMERCLUST_PLOT(KMERCLUST.out.rdata) } diff --git a/src/modules/kmerclust.nf b/src/modules/kmerclust.nf index 31e0fa5b1408ed6d3b72a345186e6d2540862ffa..7a7090fde5a1ee8a70bca0d8e1cb96c1e992c6dc 100644 --- a/src/modules/kmerclust.nf +++ b/src/modules/kmerclust.nf @@ -10,7 +10,6 @@ process KMERCLUST { path params_csv output: - tuple val(specie), path("*.pdf"), emit: pdf tuple val(specie), path("*.Rdata"), emit: rdata path "versions.yml" , emit: versions @@ -25,3 +24,29 @@ process KMERCLUST { END_VERSIONS """ } + +process KMERCLUST_PLOT { + tag "$specie" + label 'big_mem_mono_cpus' + + container "lbmc/kmerclust:0.0.2" + publishDir "results/${params.kmer_size}/${specie}/", mode: 'copy' + + input: + tuple val(specie), path(rdata) + + output: + tuple val(specie), path("*.pdf"), emit: pdf + path "versions.yml" , emit: versions + + script: + def args = task.ext.args ?: '' + """ + Rscript ${projectDir}/bin/kmerclust_plot.R ${specie} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + Rkmerclust: 0.0.1 + END_VERSIONS + """ +}