changeset 8:0ccb8c91be19 draft

planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit fdaf9fc69c205ed76ef7cd82f4fa1624cf40419b-dirty
author tomnl
date Wed, 09 May 2018 09:28:12 -0400
parents 168bff1f0b54
children 2cba35789adf
files flag-remove-peaks.R flag-remove-peaks.xml test-data/MERGED_multi_blank.rdata test-data/blank_check_b3.rdata test-data/multilist.tabular test-data/sampleList_choose_blank_xset.rdata
diffstat 6 files changed, 91 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flag-remove-peaks.R	Fri May 04 10:21:13 2018 -0400
+++ b/flag-remove-peaks.R	Wed May 09 09:28:12 2018 -0400
@@ -71,13 +71,20 @@
               help="Assign True if files for each step saved (for testing purposes) [default = %default]"
   ),
 
+  make_option("--samplelist",  type="character", help="Sample list to determine the blank class"),
+
   make_option("--xset_name",  default="xset",
               help="Name of the xcmsSet object within the RData file [default = %default]"
   )
 
 
+
 )
 
+  #make_option("--multilist", action="store_true"
+  #            help="NOT CURRENTLY IMPLEMENTED: If paired blank removal is to be performed a - multilist -  sample list file has to be provided"
+  #),
+
 # store options
 opt<- parse_args(OptionParser(option_list=option_list))
 
@@ -104,14 +111,31 @@
 
 xset<-loadRData(opt$xset_path, opt$xset_name)
 print(xset)
-ffrm_out <- XCMSwrapper::flag_remove(xset,
+if (is.null(opt$samplelist)){
+    blank_class <- opt$blank_class
+}else{
+    samplelist <- read.table(opt$samplelist, sep='\t', header=TRUE)
+    samplelist_blank <- unique(samplelist$sample_class[samplelist$blank=='yes'])
+
+    chosen_blank <- samplelist_blank[samplelist_blank %in% xset@phenoData$class]
+    if (length(chosen_blank)>1){
+        print('ERROR: only 1 blank is currently allowed to be used with this tool')
+        exit()
+    }
+    blank_class <- as.character(chosen_blank)
+    print(blank_class)
+}
+
+
+if (is.null(opt$multilist)){
+    ffrm_out <- XCMSwrapper::flag_remove(xset,
                         pol=opt$polarity,
                         rsd_i_blank=opt$rsd_i_blank,
                         minfrac_blank=opt$minfrac_blank,
                         rsd_rt_blank=opt$rsd_rt_blank,
                         ithres_blank=opt$ithres_blank,
                         s2b=opt$s2b,
-                        ref.class=opt$blank_class,
+                        ref.class=blank_class,
                         egauss_thr=opt$egauss_thr,
                         rsd_i_sample=opt$rsd_i_sample,
                         minfrac_sample=opt$minfrac_sample,
@@ -125,16 +149,36 @@
                         remove_spectra=remove_spectra,
                         grp_rm_ids=unlist(strsplit(as.character(opt$grp_rm_ids), split=", "))[[1]])
 
-xset <- ffrm_out[[1]]
-grp_peaklist <- ffrm_out[[2]]
-removed_peaks <- ffrm_out[[3]]
+    xset <- ffrm_out[[1]]
+    grp_peaklist <- ffrm_out[[2]]
+    removed_peaks <- ffrm_out[[3]]
+
+    save.image(file=file.path(opt$out_dir, 'xset_filtered.RData'))
 
-save.image(file=file.path(opt$out_dir, 'xset_filtered.RData'))
+    # grpid needed for mspurity ID needed for deconrank... (will clean up at some up)
+    write.table(data.frame('grpid'=rownames(grp_peaklist), 'ID'=rownames(grp_peaklist), grp_peaklist),
+                file.path(opt$out_dir, 'peaklist_filtered.txt'), row.names=FALSE, sep='\t')
+
+    removed_peaks <- data.frame(removed_peaks)
+    write.table(data.frame('ID'=rownames(removed_peaks),removed_peaks),
+        file.path(opt$out_dir, 'removed_peaks.txt'), row.names=FALSE, sep='\t')
+
+}else{
 
-# grpid needed for mspurity ID needed for deconrank... (will clean up at some up)
-write.table(data.frame('grpid'=rownames(grp_peaklist), 'ID'=rownames(grp_peaklist), grp_peaklist),
-        file.path(opt$out_dir, 'peaklist_filtered.txt'), row.names=FALSE, sep='\t')
+   
+   # TODO
+   #xsets <- split(xset, multilist_df$multlist)
+   #
+   #mult_grps <- unique(multilist_df$multlist)
+   #
+   #for (mgrp in mult_grps){
+   #   xset_i <- xsets[mgrp]
+   #   xcms::group(xset_i, 
+   #
+   # }
 
-removed_peaks <- data.frame(removed_peaks)
-write.table(data.frame('ID'=rownames(removed_peaks),removed_peaks),
-        file.path(opt$out_dir, 'removed_peaks.txt'), row.names=FALSE, sep='\t')
+
+
+}
+
+
--- a/flag-remove-peaks.xml	Fri May 04 10:21:13 2018 -0400
+++ b/flag-remove-peaks.xml	Wed May 09 09:28:12 2018 -0400
@@ -1,7 +1,8 @@
-<tool id="flag_remove_peaks" name="flag_remove_peaks" version="0.1.3">
+<tool id="flag_remove_peaks" name="flag_remove_peaks" version="0.1.4">
     <requirements>
         <requirement type="package" >r</requirement>
 	    <requirement type="package" >r-optparse</requirement>
+    <requirement type="package" version="1.5.4" >bioconductor-mspurity</requirement>
         <requirement type="package" version="0.0.3" >r-xcmswrapper</requirement>
     </requirements>
     <description>Tool to flag and remove XCMS grouped peaks from the xcmsSet object based on various thresholds
@@ -43,6 +44,9 @@
                     $advanced.temp_save.value
 
                 #end if
+                #if $choose_samp.choose_samp=='yes'
+                        --samplelist=$choose_samp.samplelist
+                #end if
     ]]></command>
     <inputs>
         <param type="data" name="xset_path"
@@ -132,9 +136,22 @@
                  (--grp_rm_ids)"/>
                 <param name="xset_name" type="text" label="xset_name" value="xset"
                     help="Name of the xcmsSet object within the RData file (--xset_name)"/>
+	      </when>
+	</conditional>
+	    	<conditional name="choose_samp">
+            		<param name="choose_samp" type="select" label="Samplelist">
+            		    <option value="yes" >Use samplelist</option>
+            		    <option value="" selected="true">Don't use samplelist</option>
+            		</param>
+            		<when value="">
+            		</when>
+            		<when value="yes">
+            		    <param name="samplelist" type="data" label="samplelist" format="tsv,tabular"
+            		        help="A samplelist can be provided to find an appriopiate blank class (requires a column 'blank' where 'yes' indicates
+            	              the class should be used as the blank (--samplelist)"/>
 
-            </when>
-        </conditional>
+            		</when>
+	        </conditional>
     </inputs>
     <outputs>
 	    <data name="peaklist_filtered" format="tabular" label="peaklist_filtered"
@@ -255,4 +272,4 @@
 
 The output file is an xcmsSet.RData file.
     ]]></help>
-</tool>
\ No newline at end of file
+</tool>
Binary file test-data/MERGED_multi_blank.rdata has changed
Binary file test-data/blank_check_b3.rdata has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/multilist.tabular	Wed May 09 09:28:12 2018 -0400
@@ -0,0 +1,14 @@
+prefix	sample_class	multilist	blank
+Daph_P_WAX_2_LCMS-FC_Phenyl_neg_inj5_uWSp9ok	s1	g1	no
+Daph_P_WAX_2_LCMS-FC_Phenyl_neg_inj4_yWUsdrh	s1	g1	no
+Daph_P_WAX_2_LCMS-FC_Phenyl_neg_inj3	s2	g2	no
+Daph_P_WAX_2_LCMS-FC_Phenyl_neg_inj2	s2	g2	no
+Daph_P_WAX_2_LCMS-FC_Phenyl_neg_inj1_kdoZ9S6	s3	g3	no
+Blank_P_WAX_2_LCMS-FC_Phenyl_neg_inj4	s3	g3	no
+Blank_P_WAX_2_LCMS-FC_Phenyl_neg_inj3	b1	g1	yes
+Blank_P_WAX_2_LCMS-FC_Phenyl_neg_inj2	b1	g1	yes
+Blank_P_WAX_2_LCMS-FC_Phenyl_neg_inj1_J1u7Ldf	b2	g2	yes
+Daph_P_WAX_2_LCMSMS-FC_Phenyl_neg_inj4__incl2__2_t6HMnCz	b2	g2	yes
+Daph_P_WAX_2_LCMSMS-FC_Phenyl_neg_inj3__incl2__1_UFfCSXU	b3	g3	yes
+Daph_P_WAX_2_LCMSMS-FC_Phenyl_neg_inj2__incl1__2	b3	g3	yes
+Daph_P_WAX_2_LCMSMS-FC_Phenyl_neg_inj1__incl1__1_Xci3Itv	b3	g3	yes
Binary file test-data/sampleList_choose_blank_xset.rdata has changed