Mercurial > repos > iuc > crosscontamination_barcode_filter
view scripts/crosscontamination_filter.R @ 2:e20001675838 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 82a0fd493f5866b3ef65019709ae5c865998f802
author | iuc |
---|---|
date | Wed, 12 Jun 2019 04:57:52 -0400 |
parents | 78341ccbad0a |
children |
line wrap: on
line source
#!/usr/bin/env R VERSION = "0.3" args = commandArgs(trailingOnly = T) if (length(args) != 1){ message(paste("VERSION:", VERSION)) stop("Please provide the config file") } source(args[1]) ## debug in debug dir source(file.path(script.dir, "config_assertions.R")) source(file.path(script.dir, "batch_plotting_functions.R")) source(file.path(script.dir, "reorder_matrix_headers.R")) source(file.path(script.dir, "contamination_plot.R")) colnames(input_matrix) <- convertHeadersToSensible( regex.extract, regex.display, colnames(input_matrix) ) sc <- sanityCheck(spec, colnames(input_matrix)) barcodes <- sc$barc num.barcodes <- sc$barc.n num.batches <- sc$batch.n num.plates <- sc$plates.n barcode.data <- calculateBarcodePositions(spec$format, num.barcodes) plate.data <- calculatePlatePositions(spec$plates, num.barcodes, barcode.data) ordering <- reorderMatrixHeaders(barcodes, input_matrix, spec$format, spec$plates, sort.cells) ## Unfiltered, but sorted matrix nmatrix <- input_matrix[,ordering$all] plot.prefilter <- contaminationPlot("Pre-Filter", colSums(nmatrix), barcode.data, plate.data, RAW=TRUE) ## Filtered, but sorted matrix cmatrix <- input_matrix[,ordering$filtered] plot.postfilter <- contaminationPlot("Post-Filter", colSums(cmatrix), barcode.data, plate.data, RAW=FALSE) plot.histogram.pre <- log10histoPlot("Histogram of Pre-Filter Matrix Counts", colSums(nmatrix)) plot.histogram.post <- log10histoPlot("Histogram of Post-Filter Matrix Counts", colSums(cmatrix)) pdf(out.pdf) plot.prefilter plot.postfilter plot.histogram.pre plot.histogram.post dev.off() write.table(cmatrix, file=out.table, quote=FALSE, na="0", sep="\t")