Commit abf8242c authored by Midoux Cedric's avatar Midoux Cedric
Browse files

metrics

parent 4a18f66e
......@@ -64,11 +64,11 @@ rule tree:
"&& "
"tree.py "
"--nb-cpus {threads} "
"--input-otu {input.fasta} "
"--biomfile {input.biom} "
"--input-sequences {input.fasta} "
"--biom-file {input.biom} "
"--out-tree {output.nwk} "
"--html {output.html} "
"--log-file {output.log}"
"--log-file {output.log} "
"&& "
"conda deactivate"
......
......@@ -20,3 +20,12 @@ rule makeSequenceTable:
config["THREADS"]
script:
"makeSequenceTable.R"
rule metrics:
input:
rds = "work/dada/seqtab.rds",
fastqc = expand("work/fastqc/{sample}_fastqc.zip", sample=SAMPLES)
output:
tsv = "work/dada/metrics.tsv"
script:
"metrics.R"
......@@ -11,12 +11,13 @@ rule all:
expand("work/dada/{sample}.rds", sample=SAMPLES),
"work/dada/seqtab.fasta",
"work/dada/seqtab.tsv",
"work/dada/metrics.tsv",
"work/FROGS/affiliation.biom",
"report/clusters_metrics.html",
"report/affiliations_metrics.html",
"report/abundance.biom",
"report/abundance.tsv",
"report/tree.nwk"
# "report/tree.nwk"
include: "quality.smk"
include: "preprocess.smk"
......
library(dplyr)
library(tibble)
reads_input <- sapply(snakemake@config$SAMPLES, function(x) {
as.numeric(system(
sprintf(
"unzip -p work/fastqc/%s_fastqc.zip %s_fastqc/fastqc_data.txt | grep 'Total Sequences' | cut -f2",
x, x),
intern = TRUE
))
}) %>% as.data.frame() %>% rownames_to_column("Sample")
seqtab.nochim <- readRDS(snakemake@input$rds)
reads_output <- rowSums(seqtab.nochim) %>% as.data.frame() %>% rownames_to_column("Sample")
nb_asv <- rowSums(seqtab.nochim > 0) %>% as.data.frame() %>% rownames_to_column("Sample")
metrics <- dplyr::full_join(x = reads_input, y = reads_output, by = "Sample") %>%
dplyr::full_join(y = nb_asv, by = "Sample")
colnames(metrics) <- c('Sample', 'Input reads', 'Post-process reads', 'Nb ASV')
write.table(metrics, snakemake@output$tsv, sep = "\t", quote = FALSE, row.names = FALSE)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment