Skip to content

Commit

Permalink
Merge pull request #4 from paulzierep/mmuphin_wrapper
Browse files Browse the repository at this point in the history
Mmuphin wrapper
  • Loading branch information
renu-pal authored Nov 29, 2024
2 parents 7fafc59 + d86e487 commit 47d426d
Show file tree
Hide file tree
Showing 5 changed files with 1,088 additions and 911 deletions.
202 changes: 0 additions & 202 deletions tools/mmuphin/adjust_batch.R

This file was deleted.

9 changes: 2 additions & 7 deletions tools/mmuphin/macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<macros>
<token name="@TOOL_VERSION@">1.18.1</token>
<token name="@TOOL_VERSION@">1.16.0</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@PROFILE@">23.2</token>

Expand All @@ -13,12 +13,7 @@
</xml>
<xml name="requirements">
<requirements>
<requirement type="package" version="@TOOL_VERSION@">bioconductor-mmuphin</requirement>
<requirement type="package" version="2.0.3">r-magrittr</requirement>
<requirement type="package" version="1.1.4">r-dplyr</requirement>
<requirement type="package" version="0.33">r-dt</requirement>
<requirement type="package" version="3.5.1">r-ggplot2</requirement>
<requirement type="package" version="2.1.5">r-readr</requirement>
<requirement type="package" version="@TOOL_VERSION@">bioconductor-mmuphin</requirement>
</requirements>
</xml>
<xml name="citations">
Expand Down
77 changes: 49 additions & 28 deletions tools/mmuphin/mmuphin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,69 @@
<expand macro="xrefs"/>
<expand macro="requirements"/>
<command detect_errors="exit_code"><![CDATA[
Rscript '$rscript'
## get the batch name
export batch=`awk -v idx='$batch_input' -F"\t" 'NR == 1 { print \$idx }' '$input_metadata'` &&
## get covariates names
#if $covariates_input
#set idx = []
#for $i in $covariates_input:
#silent idx.append(f'${i}')
#end for
#set idx_for_awk = ','.join(idx)
export covariates=`awk -v OFS=',' -F"\t" 'NR == 1 { print $idx_for_awk}' '$input_metadata'` &&
#end if
echo 'Assigned batch columns:' \$batch &&
echo 'Assigned covariates:' \$covariates &&
Rscript '$rscript' &&
cp 'adjust_batch_diagnostic.pdf' '$diagnostic_plot_output'
]]></command>

<configfiles>
<configfile name="rscript"><![CDATA[
library(MMUPHin)
library(magrittr)
library(dplyr)
library(ggplot2)
library(readr)
source(adjust_batch.R)
#input files
print(" Read input files")
abd_data <- read_tsv("$input_data")
meta_data <- read_tsv("$input_metadata")
## input files
print("Read input files")
data <- read.csv("$input_data", sep = "\t", row.names=1, check.names = FALSE)
meta_data <- read.csv("$input_metadata", sep = "\t", row.names=1, check.names = FALSE)
# Define control list
controls <- list("$zero_inflation",
"$pseudo_count",
"$conv",
"$maxit",
"$verbose",
"$diagnostic_plot")
controls <- list("$additional_options.zero_inflation",
"$additional_options.pseudo_count",
"$additional_options.conv",
"$additional_options.maxit",
"$additional_options.verbose",
"$additional_options.diagnostic_plot")
#Perform batch adjustment
source(adjust_batch.R)
result <- adjust_batch(feature_abd = abd_data,
batch = "$batch_input",
covariates = "$covariates_input",
## get var names from env
batch <- Sys.getenv("batch")
covariates <- Sys.getenv("covariates")
covariates_vector <- unlist(strsplit(covariates, split = ","))
result <- adjust_batch(feature_abd = data,
batch = batch,
covariates = covariates_vector,
data = meta_data,
control=controls
)
# Save results into output files
print(result)
write.table(result$feature_abd_adj,file="$output",quote = FALSE)
write.table(result$control,file="$control_output",quote = FALSE)
#save adjust_batch_diagnostic.pdf into diagnostic_plot_output file too
write.table(result\$feature_abd_adj,file="$output",quote = FALSE, sep="\t")
## write.table(result\$control,file="$control_output",quote = FALSE)
]]></configfile>
</configfiles>

Expand All @@ -56,7 +78,7 @@
<param name="input_data" type="data" format="tabular" label="Data (or features) file"/>
<param name="input_metadata" type="data" format="tabular" label="Metadata file"/>
<param argument="batch_input" type="data_column" data_ref="input_metadata" use_header_names="true" label="batch" />
<param argument="covariates_input" type="data_column" data_ref="input_metadata" use_header_names="true" optional="true" label="covariates" />
<param argument="covariates_input" type="data_column" data_ref="input_metadata" use_header_names="true" multiple="true" optional="true" label="covariates" />
<section name="additional_options" title="Additional Options" expanded="true">
<param argument="zero_inflation" type="boolean" truevalue="zero_inflation TRUE" falsevalue="zero_inflation FALSE" checked="true" label=" Run zero-inflated model"/>
<param argument="pseudo_count" type="float" optional="true" label="Pseudo_count" help="Pseudo count to add feature_abd before the methods' log transformation.Default to NULL, in which case will be set to half of minimal non-zero values in feature_abd"/>
Expand All @@ -71,7 +93,6 @@
<outputs>
<data name="output" format="tabular" label="Adjusted abundance table"/>
<data name="diagnostic_plot_output" format="pdf" label="diagnostic figure file"/>
<data name="control_output" format="tabular" label="control list used in batch adjustment"/>
</outputs>
<tests>
<test expect_num_outputs="3">
Expand Down
607 changes: 485 additions & 122 deletions tools/mmuphin/test-data/CRC_abd.tsv

Large diffs are not rendered by default.

Loading

0 comments on commit 47d426d

Please sign in to comment.