# HG changeset patch
# User iuc
# Date 1754469504 0
# Node ID bd267e082f86e99931aaae50791932cc9e5b532a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/micro_decon/ commit bb37578aa61bf4a47af262e02baf0a1c1d9d02c6
diff -r 000000000000 -r bd267e082f86 decon.R
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/decon.R	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,79 @@
+suppressPackageStartupMessages(library(microDecon))
+suppressPackageStartupMessages(library(optparse))
+
+# Define command-line options
+option_list <- list(
+    make_option(c("-m", "--mode"), type = "character", help = "Mode of operation: decon, remove.cont, remove.thresh, decon.diff", metavar = "MODE"),
+    make_option(c("-d", "--data_file"), type = "character", help = "Path to the data file (CSV format expected)", metavar = "FILE"),
+    make_option(c("-o", "--output"), type = "character", default = NULL, help = "Output file from remove.cont or remove.thresh (used in decon.diff)", metavar = "FILE"),
+    make_option(c("-b", "--numb_blanks"), type = "integer", default = NULL, help = "Number of blank samples"),
+    make_option(c("-n", "--numb_ind"), type = "character", default = NULL, help = "Number of individuals (eval-parsed)"),
+    make_option(c("-t", "--taxa"), type = "logical", default = FALSE, help = "Taxa flag (TRUE or FALSE)"),
+    make_option(c("-r", "--runs"), type = "integer", default = NULL, help = "Number of runs"),
+    make_option(c("-T", "--thresh"), type = "double", default = NULL, help = "Threshold value"),
+    make_option(c("-p", "--prop_thresh"), type = "double", default = NULL, help = "Proportional threshold value"),
+    make_option(c("-g", "--regression"), type = "double", default = NULL, help = "Regression value"),
+    make_option(c("-l", "--low_threshold"), type = "double", default = 40, help = "Low threshold [default: %default]"),
+    make_option(c("-u", "--up_threshold"), type = "double", default = 400, help = "Upper threshold [default: %default]")
+)
+
+# Parse arguments
+opt <- parse_args(OptionParser(option_list = option_list))
+
+# Read main input data
+microbe_data <- read.csv(opt$data_file, header = TRUE, stringsAsFactors = FALSE, check.names = FALSE)
+
+if (opt$mode == "decon") {
+    result <- decon(
+        data = microbe_data,
+        numb.blanks = opt$numb_blanks,
+        numb.ind = eval(parse(text = opt$numb_ind)),
+        taxa = opt$taxa,
+        runs = opt$runs,
+        thresh = opt$thresh,
+        prop.thresh = opt$prop_thresh,
+        regression = opt$regression,
+        low.threshold = opt$low_threshold,
+        up.threshold = opt$up_threshold
+    )
+    write.csv(result$decon.table, "decon_table.csv", row.names = FALSE)
+    write.csv(result$reads.removed, "reads_removed.csv", row.names = FALSE)
+    write.csv(result$sum.per.group, "difference_sum.csv", row.names = FALSE)
+    write.csv(result$mean.per.group, "difference_mean.csv", row.names = FALSE)
+    write.csv(result$OTUs.removed, "OTUs_removed.csv", row.names = FALSE)
+} else if (opt$mode == "remove_cont") {
+    result <- remove.cont(
+        data = microbe_data,
+        numb.blanks = opt$numb_blanks,
+        taxa = opt$taxa,
+        runs = opt$runs,
+        regression = opt$regression,
+        low.threshold = opt$low_threshold,
+        up.threshold = opt$up_threshold
+    )
+    write.csv(result, "decon_table.csv", row.names = FALSE)
+} else if (opt$mode == "remove_thresh") {
+    result <- remove.thresh(
+        data = microbe_data,
+        numb.ind = eval(parse(text = opt$numb_ind)),
+        taxa = opt$taxa,
+        thresh = opt$thresh,
+        prop.thresh = opt$prop_thresh
+    )
+    write.csv(result, "decon_table.csv", row.names = FALSE)
+} else if (opt$mode == "decon_diff") {
+    if (is.null(opt$output)) stop("Error: --output must be provided for decon.diff mode")
+    output_data <- read.csv(opt$output, header = TRUE, stringsAsFactors = FALSE, check.names = FALSE)
+    result <- decon.diff(
+        data = microbe_data,
+        output = output_data,
+        numb.blanks = opt$numb_blanks,
+        numb.ind = eval(parse(text = opt$numb_ind)),
+        taxa = opt$taxa
+    )
+    write.csv(result$decon.table, "decon_table.csv", row.names = FALSE)
+    write.csv(result$reads.removed, "reads_removed.csv", row.names = FALSE)
+    write.csv(result$sum.per.group, "difference_sum.csv", row.names = FALSE)
+    write.csv(result$mean.per.group, "difference_mean.csv", row.names = FALSE)
+    write.csv(result$OTUs.removed, "OTUs_removed.csv", row.names = FALSE)
+}
diff -r 000000000000 -r bd267e082f86 macros.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,38 @@
+
+    1.0.2
+    0
+    GPL-2.0-or-later
+    
+        
+            sebimer/samba-v4-qiime2:2024.2
+        
+    
+    
+        
+    
+    
+        
+            ^\d+(,\d+)*$
+        
+    
+    
+        
+        
+        
+        
+    
+    
+        
+        
+    
+    
+        
+            10.1002/edn3.11
+        
+    
+    
+        
+            
+        
+    
+
diff -r 000000000000 -r bd267e082f86 micro_decon.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/micro_decon.xml	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,164 @@
+
+    removing contamination from metabarcoding
+    
+        macros.xml
+    
+    
+    
+    
+    
+        
+        
+        
+            
+                
+                
+                
+                
+            
+            
+                
+                
+                
+                
+            
+            
+                
+                
+            
+            
+                
+                
+            
+            
+                
+                
+                
+            
+        
+    
+    
+        
+        
+            function_cond['function_selector'] != "remove_cont" and function_cond['function_selector'] != "remove_thresh"
+        
+        
+            function_cond['function_selector'] != "remove_cont" and function_cond['function_selector'] != "remove_thresh"
+        
+        
+            function_cond['function_selector'] != "remove_cont" and function_cond['function_selector'] != "remove_thresh"
+        
+        
+            function_cond['function_selector'] != "remove_cont" and function_cond['function_selector'] != "remove_thresh"
+        
+    
+    
+        
+            
+            
+            
+                
+                
+            
+            
+            
+            
+            
+            
+        
+        
+            
+            
+            
+                
+            
+            
+        
+        
+            
+            
+            
+                
+                
+            
+            
+        
+        
+            
+            
+            
+                
+                
+                
+            
+            
+            
+            
+            
+            
+        
+    
+    `_
+
+]]>
+    
+
\ No newline at end of file
diff -r 000000000000 -r bd267e082f86 test-data/decon_table.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/decon_table.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,6 @@
+"OTU_ID","Blank1","Blank2","Blank3","Pop1_Sample1","Pop1_Sample2","Pop2_Sample3","Taxa"
+"OTU1",0,0,0,60,64,40,"K_Bacteria; P_Actinobacteria"
+"OTU2",200,100,0,380,328,340,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,200,80,40,40,0,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,0,9,0,0,0,"K_Bacteria; P_Bacteroidetes"
+"OTU5",0,0,0,2400,1900,2100,"K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/difference_mean.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/difference_mean.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,5 @@
+"OTU_ID","Blank1","All.groups","Group1","Group2","Taxa"
+"OTU2",200,182.4,193.333333333333,166,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,976,1073.33333333333,830,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,48.8,53.6666666666667,41.5,"K_Bacteria; P_Bacteroidetes"
+"OTU6",25,21,23.3333333333333,17.5,"K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/difference_sum.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/difference_sum.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,5 @@
+"OTU_ID","Blank1","All.groups","Group1","Group2","Taxa"
+"OTU2",200,912,580,332,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,4880,3220,1660,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,244,161,83,"K_Bacteria; P_Bacteroidetes"
+"OTU6",25,105,70,35,"K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/input.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,7 @@
+"OTU_ID","Blank1","Blank2","Blank3","Pop1_Sample1","Pop1_Sample2","Pop2_Sample3","Taxa"
+"OTU1",0,0,0,60,64,40,"K_Bacteria; P_Actinobacteria"
+"OTU2",200,220,180,660,520,480,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,800,1300,1440,1000,700,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,30,70,70,48,35,"K_Bacteria; P_Bacteroidetes"
+"OTU5",0,0,0,2400,1900,2100,"K_Bacteria"
+"OTU6",25,10,30,30,20,15,"K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/otus_removed.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/otus_removed.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,3 @@
+"OTU_ID","Blank1","All.groups","Group1","Group2","Taxa"
+"OTU4",50,"-","-","Totally.removed","K_Bacteria; P_Bacteroidetes"
+"OTU6",25,"Totally.removed","Totally.removed","Totally.removed","K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/reads_removed.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/reads_removed.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,5 @@
+"OTU_ID","Blank1","Blank2","Blank3","Pop1_Sample1","Pop1_Sample2","Pop2_Sample3","Taxa"
+"OTU2",200,120,180,280,192,140,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,600,1220,1400,960,700,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,30,61,70,48,35,"K_Bacteria; P_Bacteroidetes"
+"OTU6",25,10,30,30,20,15,"K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/remove_cont_decon_table.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/remove_cont_decon_table.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,7 @@
+"OTU_ID","Blank1","Blank2","Blank3","Pop1_Sample1","Pop1_Sample2","Pop2_Sample3","Taxa"
+"OTU1",0,0,0,60,64,40,"K_Bacteria; P_Actinobacteria"
+"OTU2",200,100,0,380,328,340,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,200,80,40,40,0,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,0,9,0,0,0,"K_Bacteria; P_Bacteroidetes"
+"OTU5",0,0,0,2400,1900,2100,"K_Bacteria"
+"OTU6",25,0,0,0,0,0,"K_Bacteria"
diff -r 000000000000 -r bd267e082f86 test-data/remove_thresh_decon_table.csv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/remove_thresh_decon_table.csv	Wed Aug 06 08:38:24 2025 +0000
@@ -0,0 +1,7 @@
+"OTU_ID","Blank1","Blank2","Blank3","Pop1_Sample1","Pop1_Sample2","Pop2_Sample3","Taxa"
+"OTU1",0,0,0,60,64,40,"K_Bacteria; P_Actinobacteria"
+"OTU2",200,100,0,380,328,340,"K_Bacteria; P_Proteobacteria"
+"OTU3",1000,200,80,40,40,0,"K_Bacteria; P_Proteobacteria"
+"OTU4",50,0,9,0,0,0,"K_Bacteria; P_Bacteroidetes"
+"OTU5",0,0,0,2400,1900,2100,"K_Bacteria"
+"OTU6",25,0,0,0,0,0,"K_Bacteria"