# HG changeset patch # User azomics # Date 1594900852 14400 # Node ID 413f3e610295138175465e23a4df34f4ab88fffb # Parent 164cd5384f1d085c5e45c219f288d3cb7e4daeba "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_scatterplot commit 82365bd2b90a783f84f497afbb29b435cd25cf9d" diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/getDensityPlots.R --- a/fcs_scatterplot/getDensityPlots.R Mon Feb 27 12:52:20 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -# Density Plot Module for Galaxy -# FlowDensity -###################################################################### -# Copyright (c) 2016 Northrop Grumman. -# All rights reserved. -###################################################################### -# -# Version 1 -# Cristel Thomas -# -# - -library(flowCore) -library(flowDensity) - -generateGraph <- function(input, channels, output, plot_default, flag_pdf, pdf_out) { - fcs <- read.FCS(input, transformation=F) - ## marker names - markers <- colnames(fcs) - print_markers <- as.vector(pData(parameters(fcs))$desc) - # Update print_markers if the $P?S not in the FCS file - for (i in 1:length(print_markers)) { - if (is.na(print_markers[i])) { - print_markers[i] <- markers[i] - } - } - - if (plot_default) { - channels <- c(grep(colnames(fcs), pattern="Forward scatter", ignore.case=TRUE), - grep(colnames(fcs), pattern="Side scatter", ignore.case=TRUE)) - if (length(channels) == 0){ - channels <- c(grep(colnames(fcs), pattern="FSC"), - grep(colnames(fcs), pattern="SSC")) - if (length(channels) > 2) { - #get first FSC and corresponding SSC - channels <- c(grep(colnames(fcs), pattern="FSC-A"), - grep(colnames(fcs), pattern="SSC-A")) - if (length(channels) == 0) { - channels <- c(grep(colnames(fcs), pattern="FSC-H"), - grep(colnames(fcs), pattern="SSC-H")) - if (length(channels) == 0) { - channels <- c(grep(colnames(fcs), pattern="FSC-W"), - grep(colnames(fcs), pattern="SSC-W")) - } - } - } - } - if (length(channels) == 0) { - warning('No forward/side scatter channels found, no plots will be generated.') - quit(save = "no", status = 10, runLast = FALSE) - } - } - - nb_markers <- length(channels) - for (j in nb_markers) { - if (channels[j] > length(markers)){ - warning('Please indicate markers between 1 and ', length(markers)) - quit(save = "no", status = 10, runLast = FALSE) - } - } - png(output, type="cairo", height=600, width=600) - par(mfrow=c(2,2)) - for (m in 1:(nb_markers - 1)) { - for (n in (m+1):nb_markers) { - plotDens(fcs, c(channels[m],channels[n]), xlab = print_markers[channels[m]], ylab = print_markers[channels[n]]) - } - } - dev.off() - - if (flag_pdf) { - pdf(pdf_out, useDingbats=FALSE, onefile=TRUE) - par(mfrow=c(2,2)) - for (m in 1:(nb_markers - 1)) { - for (n in (m+1):nb_markers) { - plotDens(fcs, c(channels[m],channels[n]), xlab = print_markers[channels[m]], ylab = print_markers[channels[n]]) - } - } - dev.off() - } -} - -checkFCS <- function(input_file, channels, output_file, plot_default, flag_pdf, pdf_out) { - isValid <- F - # Check file beginning matches FCS standard - tryCatch({ - isValid = isFCSfile(input_file) - }, error = function(ex) { - print (paste(" ! Error in isFCSfile", ex)) - }) - - if (isValid) { - generateGraph(input_file, channels, output_file, plot_default, flag_pdf, pdf_out) - } else { - print (paste(input_file, "does not meet FCS standard")) - } -} - -args <- commandArgs(trailingOnly = TRUE) -channels <- "" -flag_default <- FALSE -flag_pdf <- FALSE -pdf_output <- "" - -if (args[3]=="None") { - flag_default <- TRUE -} else { - if (args[3] == "i.e.:1,3,4"){ - flag_default <- TRUE - } else { - channels <- as.numeric(strsplit(args[3], ",")[[1]]) - for (channel in channels){ - if (is.na(channel)){ - quit(save = "no", status = 11, runLast = FALSE) - } - } - if (length(channels) == 1){ - warning('Please indicate more than one marker to plot.') - quit(save = "no", status = 10, runLast = FALSE) - } - } -} - -if (args[5] == "TRUE"){ - pdf_output <- args[6] - flag_pdf <- TRUE -} - -checkFCS(args[2], channels, args[4], flag_default, flag_pdf, pdf_output) diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/getDensityPlots.xml --- a/fcs_scatterplot/getDensityPlots.xml Mon Feb 27 12:52:20 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ - - for any given markers in FCS file. - - r - bioconductor-flowcore - bioconductor-flowdensity - - - - - - - - - - - - - - - - - - outformat=="TRUE" - - - - - - - - - - - - - - - - - - - - - - 10.1093/bioinformatics/btu677 - 10.1186/1471-2105-10-106 - - diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/static/images/flowtools/densityplots.png Binary file fcs_scatterplot/static/images/flowtools/densityplots.png has changed diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/test-data/graph.pdf Binary file fcs_scatterplot/test-data/graph.pdf has changed diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/test-data/graph.png Binary file fcs_scatterplot/test-data/graph.png has changed diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/test-data/graph2.png Binary file fcs_scatterplot/test-data/graph2.png has changed diff -r 164cd5384f1d -r 413f3e610295 fcs_scatterplot/test-data/testfcs1.fcs Binary file fcs_scatterplot/test-data/testfcs1.fcs has changed diff -r 164cd5384f1d -r 413f3e610295 getDensityPlots.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getDensityPlots.R Thu Jul 16 08:00:52 2020 -0400 @@ -0,0 +1,130 @@ +#!/usr/bin/Rscript --vanilla +# Density Plot Module for Galaxy +# FlowDensity +###################################################################### +# Copyright (c) 2016 Northrop Grumman. +# All rights reserved. +###################################################################### +# +# Version 1 +# Cristel Thomas +# +# + +library(flowCore) +library(flowDensity) + +generateGraph <- function(input, channels, output, plot_default=TRUE, + flag_pdf=FALSE) { + fcs <- read.FCS(input, transformation=F) + ## marker names + markers <- colnames(fcs) + print_markers <- as.vector(pData(parameters(fcs))$desc) + # Update print_markers if the $P?S not in the FCS file + for (i in 1:length(print_markers)) { + if (is.na(print_markers[i])) { + print_markers[i] <- markers[i] + } + } + + if (plot_default) { + channels <- c(grep(colnames(fcs), pattern="Forward scatter", ignore.case=TRUE), + grep(colnames(fcs), pattern="Side scatter", ignore.case=TRUE)) + if (length(channels) == 0){ + channels <- c(grep(colnames(fcs), pattern="FSC"), + grep(colnames(fcs), pattern="SSC")) + if (length(channels) > 2) { + #get first FSC and corresponding SSC + channels <- c(grep(colnames(fcs), pattern="FSC-A"), + grep(colnames(fcs), pattern="SSC-A")) + if (length(channels) == 0) { + channels <- c(grep(colnames(fcs), pattern="FSC-H"), + grep(colnames(fcs), pattern="SSC-H")) + if (length(channels) == 0) { + channels <- c(grep(colnames(fcs), pattern="FSC-W"), + grep(colnames(fcs), pattern="SSC-W")) + } + } + } + } + if (length(channels) == 0) { + warning('No forward/side scatter channels found, no plots will be generated.') + quit(save = "no", status = 10, runLast = FALSE) + } + } + + nb_markers <- length(channels) + if (nb_markers == 1) { + warning('There is only one marker selected to plot.') + quit(save = "no", status = 12, runLast = FALSE) + } + for (j in nb_markers) { + if (channels[j] > length(markers)){ + warning('Please indicate markers between 1 and ', length(markers)) + quit(save = "no", status = 10, runLast = FALSE) + } + } + nb_rows <- ceiling(((nb_markers-1)*nb_markers)/4) + h <- 400 * nb_rows + if (flag_pdf) { + pdf(output, useDingbats=FALSE, onefile=TRUE) + par(mfrow=c(2,2)) + for (m in 1:(nb_markers - 1)) { + for (n in (m+1):nb_markers) { + plotDens(fcs, c(channels[m],channels[n]), xlab = print_markers[channels[m]], ylab = print_markers[channels[n]]) + } + } + dev.off() + } else { + png(output, type="cairo", height=h, width=800) + par(mfrow=c(nb_rows,2)) + for (m in 1:(nb_markers - 1)) { + for (n in (m+1):nb_markers) { + plotDens(fcs, c(channels[m],channels[n]), xlab = print_markers[channels[m]], ylab = print_markers[channels[n]]) + } + } + dev.off() + } +} + +checkFCS <- function(input_file, channels, output_file, plot_default=TRUE, + flag_pdf=FALSE){ + isValid <- F + # Check file beginning matches FCS standard + tryCatch({ + isValid <- isFCSfile(input_file) + }, error = function(ex) { + print (paste(" ! Error in isFCSfile", ex)) + }) + + if (isValid) { + generateGraph(input_file, channels, output_file, plot_default, flag_pdf) + } else { + print (paste(input_file, "does not meet FCS standard")) + } +} + +args <- commandArgs(trailingOnly = TRUE) +channels <- list() +flag_default <- FALSE +flag_pdf <- FALSE + +if (args[2]=="None" || args[2]== "" || args[2] == "i.e.:1,3,4") { + flag_default <- TRUE +} else { + channels <- as.numeric(strsplit(args[2], ",")[[1]]) + for (channel in channels){ + if (is.na(channel)){ + quit(save = "no", status = 11, runLast = FALSE) + } + } + if (length(channels) == 1){ + warning('Please indicate more than one marker to plot.') + quit(save = "no", status = 10, runLast = FALSE) + } +} + +if (args[4] == "PDF"){ + flag_pdf <- TRUE +} +checkFCS(args[1], channels, args[3], flag_default, flag_pdf) diff -r 164cd5384f1d -r 413f3e610295 getDensityPlots.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getDensityPlots.xml Thu Jul 16 08:00:52 2020 -0400 @@ -0,0 +1,76 @@ + + for any given markers in FCS file + + bioconductor-flowdensity + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.1093/bioinformatics/btu677 + 10.1186/1471-2105-10-106 + + diff -r 164cd5384f1d -r 413f3e610295 static/images/flowtools/densityplots.png Binary file static/images/flowtools/densityplots.png has changed diff -r 164cd5384f1d -r 413f3e610295 test-data/graph.pdf Binary file test-data/graph.pdf has changed diff -r 164cd5384f1d -r 413f3e610295 test-data/graph2.png Binary file test-data/graph2.png has changed diff -r 164cd5384f1d -r 413f3e610295 test-data/testfcs1.fcs Binary file test-data/testfcs1.fcs has changed