# HG changeset patch # User iuc # Date 1559140301 14400 # Node ID 0921444c832d45f4e3f8df2ae38e8e19983d7ede # Parent c9c6427edfe9b3ce7289d17f3b7734e4053c2a5b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/limma_voom commit 0cc16fe170b5c8d3b9441177bf2749aa7bddca7b diff -r c9c6427edfe9 -r 0921444c832d limma_voom.R --- a/limma_voom.R Tue May 28 10:04:10 2019 -0400 +++ b/limma_voom.R Wed May 29 10:31:41 2019 -0400 @@ -79,6 +79,14 @@ return(string) } +# Function to make contrast contain valid R names +sanitiseContrast <- function(string) { + string <- strsplit(string, split="-") + string <- lapply(string, make.names) + string <- lapply(string, paste, collapse="-") + return(string) +} + # Function to change periods to whitespace in a string unmake.names <- function(string) { string <- gsub(".", " ", string, fixed=TRUE) @@ -353,16 +361,29 @@ # Split up contrasts seperated by comma into a vector then sanitise contrastData <- unlist(strsplit(opt$contrastInput, split=",")) } - -# in case input groups start with numbers this will make the names valid R names, required for makeContrasts contrastData <- sanitiseEquation(contrastData) contrastData <- gsub(" ", ".", contrastData, fixed=TRUE) + +# in case input groups start with numbers make the names valid R names, required for makeContrasts cons <- NULL +cons_d <- NULL for (i in contrastData) { - i <- strsplit(i, split="-") - i <- lapply(i, make.names) - i <- lapply(i, paste, collapse="-") - cons <- append(cons, unlist(i)) + + # if the contrast is a difference of differences e.g. (A-B)-(X-Y) + if (grepl("\\)-\\(", i)) { + i <- unlist(strsplit(i, split="\\)-\\(")) + i <- gsub("\\(|\\)","", i) + for (j in i) { + j <- sanitiseContrast(j) + j <- paste0("(", j, ")") + cons_d <- append(cons_d, unlist(j)) + } + cons_d <- paste(cons_d, collapse = '-') + cons <- append(cons, unlist(cons_d)) + } else { + i <- sanitiseContrast(i) + cons <- append(cons, unlist(i)) + } } plots <- character() @@ -852,6 +873,7 @@ sumStatus <- summary(status) for (i in 1:length(cons)) { + con_name <- cons[i] con <- cons[i] con <- gsub("\\(|\\)", "", con) # Collect counts for differential expression @@ -957,7 +979,7 @@ imgName <- paste0("MDVolPlot_", con) imgAddr <- paste0("mdvolplot_", con, ".png") imageData <- rbind(imageData, c(imgName, imgAddr)) - title(paste0("Contrast: ", unmake.names(con)), outer=TRUE, cex.main=1.5) + title(paste0("Contrast: ", con_name), outer=TRUE, cex.main=1.5) invisible(dev.off()) if ("h" %in% plots) { @@ -1076,7 +1098,7 @@ cata("

Plots:

\n") #PDFs for (i in 1:nrow(linkData)) { - if (grepl("density|cpm|boxplot|mds|mdplots|voom|saplot", linkData$Link[i])) { + if (grepl(".pdf", linkData$Link[i]) & grepl("density|cpm|boxplot|mds|mdplots|voom|saplot", linkData$Link[i])) { HtmlLink(linkData$Link[i], linkData$Label[i]) } } diff -r c9c6427edfe9 -r 0921444c832d limma_voom.xml --- a/limma_voom.xml Tue May 28 10:04:10 2019 -0400 +++ b/limma_voom.xml Wed May 29 10:31:41 2019 -0400 @@ -721,7 +721,7 @@ - + @@ -734,6 +734,12 @@ + + + + + + diff -r c9c6427edfe9 -r 0921444c832d test-data/contrasts.txt --- a/test-data/contrasts.txt Tue May 28 10:04:10 2019 -0400 +++ b/test-data/contrasts.txt Wed May 29 10:31:41 2019 -0400 @@ -1,3 +1,4 @@ Contrast Mut-WT -WT-Mut \ No newline at end of file +WT-Mut +(Mut-WT)-(WT-Mut)