Mercurial > repos > chmaramis > testirprofiler
changeset 10:5339fb9d8aee draft
Deleted selected files
| author | chmaramis |
|---|---|
| date | Sun, 18 Mar 2018 07:07:34 -0400 |
| parents | f4edb9437b95 |
| children | 14896ea6e180 |
| files | cmpb2016/pub_clono_JCDR3.py cmpb2016/pub_clono_JCDR3.xml cmpb2016/pub_clono_VCDR3.py cmpb2016/pub_clono_VCDR3.xml |
| diffstat | 4 files changed, 0 insertions(+), 230 deletions(-) [+] |
line wrap: on
line diff
--- a/cmpb2016/pub_clono_JCDR3.py Sun Mar 18 07:06:56 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Fri Feb 26 19:08:28 2016 - -@author: chmaramis -""" - -from __future__ import division -import numpy as np -from pandas import * -from numpy import nan as NA -import sys -import time - - - -def publicJGeneClonoFunc(inputs,thres): - - clono=DataFrame() - - for x in range(0,len(inputs),2): - cl = DataFrame() - cl = read_csv(inputs[x] , sep = '\t' , index_col = 0) - #tp = read_csv(inp_name, iterator=True, chunksize=5000,sep='\t', index_col=0 ) - #cl = concat([chunk for chunk in tp]) - - if (thres != 'null'): - cl = cl[cl['Reads'] > int(thres)] - - x1 = inputs[x+1].split('_') - - del cl['Reads'] - cl.columns = [cl.columns[0], cl.columns[1], x1[0]+' '+cl.columns[2], x1[0]+' Relative '+cl.columns[3]] - - if clono.empty: - clono = cl - else: - clono = clono.merge(cl, how='outer', on=['J-GENE','AA JUNCTION']) - - - col = clono.columns - freqs = col.map(lambda x: 'Frequency' in x) - reads = col.map(lambda x: 'Reads/Total' in x) - - clono[col[freqs]] = clono[col[freqs]].fillna(0) - clono[col[reads]] = clono[col[reads]].fillna('0/*') - - clono['Num of Patients']= clono[col[freqs]].apply(lambda x: np.sum(x != 0), axis=1) - - clono = clono[clono['Num of Patients'] > 1] - - clono.index = range(1,len(clono)+1) - - return clono - - -if __name__ == '__main__': - - start=time.time() - - # Parse input arguments - arg = sys.argv[3:] - output = sys.argv[1] - thres = sys.argv[2] - - - # Execute basic function - mer = publicJGeneClonoFunc(arg,thres) - - # Save output to CSV files - if not mer.empty: - mer.to_csv(output , sep = '\t') - - # Print execution time - stop=time.time() - print('Runtime:' + str(stop-start))
--- a/cmpb2016/pub_clono_JCDR3.xml Sun Mar 18 07:06:56 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -<tool id="pubClonoJCDR3" name="Public J+CDR3 Clonotypes Computation" version="0.9"> -<description>Compute Public J+CDR3 Clonotypes</description> -<command interpreter="python"> -pub_clono_JCDR3.py "$output1" "$Th.thres" -#for x in $clono_files - "$x.clfile" - "$x.clfile.name" -#end for -</command> -<inputs> - <conditional name="Th"> - - <param name="thres_select" type="select" label="Remove Clonotypes With Reads Fewer Than Threshold?"> - <option value="y">Yes</option> - <option value="n" selected="true">No</option> - </param> - - <when value="y"> - <param name="thres" type="integer" size="4" value="1" min="1" label="Keep Clonotypes with Number of Reads more than"/> - </when> - - <when value="n"> - <param name="thres" type="hidden" value="null" /> - </when> - - </conditional> - <repeat name="clono_files" title="Files to be append" min="2"> - <param name="clfile" type="data" label="Clonotype_File" format="tabular"/> - </repeat> - -</inputs> - -<outputs> - <data format="tabular" name="output1" label="Public_Clonotype"/> -</outputs> -<help> - This tool computes the public (J-gene, CDR3) Clonotypes among a number of patients along with their frequencies for each patient. -</help> -</tool>
--- a/cmpb2016/pub_clono_VCDR3.py Sun Mar 18 07:06:56 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Fri Feb 26 18:49:15 2016 - -@author: chmaramis -""" - -from __future__ import division -import numpy as np -from pandas import * -from numpy import nan as NA -import sys -import time - - - -def publicVGeneClonoFunc(inputs,thres): - - clono=DataFrame() - - for x in range(0,len(inputs),2): - cl = DataFrame() - cl = read_csv(inputs[x] , sep = '\t' , index_col = 0) - #tp = read_csv(inp_name, iterator=True, chunksize=5000,sep='\t', index_col=0 ) - #cl = concat([chunk for chunk in tp]) - - if (thres != 'null'): - cl = cl[cl['Reads'] > int(thres)] - - x1 = inputs[x+1].split('_') - - del cl['Reads'] - cl.columns = [cl.columns[0], cl.columns[1], x1[0]+' '+cl.columns[2], x1[0]+' Relative '+cl.columns[3]] - - if clono.empty: - clono = cl - else: - clono = clono.merge(cl, how='outer', on=['V-GENE','AA JUNCTION']) - - - col = clono.columns - freqs = col.map(lambda x: 'Frequency' in x) - reads = col.map(lambda x: 'Reads/Total' in x) - - clono[col[freqs]] = clono[col[freqs]].fillna(0) - clono[col[reads]] = clono[col[reads]].fillna('0/*') - - clono['Num of Patients']= clono[col[freqs]].apply(lambda x: np.sum(x != 0), axis=1) - - clono = clono[clono['Num of Patients'] > 1] - - clono.index = range(1,len(clono)+1) - - return clono - - -if __name__ == '__main__': - - start=time.time() - - # Parse input arguments - arg = sys.argv[3:] - output = sys.argv[1] - thres = sys.argv[2] - - - # Execute basic function - mer = publicVGeneClonoFunc(arg,thres) - - # Save output to CSV files - if not mer.empty: - mer.to_csv(output , sep = '\t') - - # Print execution time - stop=time.time() - print('Runtime:' + str(stop-start))
--- a/cmpb2016/pub_clono_VCDR3.xml Sun Mar 18 07:06:56 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -<tool id="pubClonoVCDR3" name="Public V+CDR3 Clonotypes Computation" version="0.9"> -<description>Compute Public V+CDR3 Clonotypes</description> -<command interpreter="python"> -pub_clono_VCDR3.py "$output1" "$Th.thres" -#for x in $clono_files - "$x.clfile" - "$x.clfile.name" -#end for -</command> -<inputs> - <conditional name="Th"> - - <param name="thres_select" type="select" label="Remove Clonotypes With Reads Fewer Than Threshold?"> - <option value="y">Yes</option> - <option value="n" selected="true">No</option> - </param> - - <when value="y"> - <param name="thres" type="integer" size="4" value="1" min="1" label="Keep Clonotypes with Number of Reads more than"/> - </when> - - <when value="n"> - <param name="thres" type="hidden" value="null" /> - </when> - - </conditional> - <repeat name="clono_files" title="Files to be append" min="2"> - <param name="clfile" type="data" label="Clonotype_File" format="tabular"/> - </repeat> - -</inputs> - -<outputs> - <data format="tabular" name="output1" label="Public_Clonotype"/> -</outputs> -<help> - This tool computes the public (V-gene, CDR3) Clonotypes among a number of patients along with their frequencies for each patient. -</help> -</tool>
