Mercurial > repos > melissacline > ucsc_cancer_utilities
changeset 54:59dbe857f5d4
introduce normal_CNV parameter
author | jingchunzhu |
---|---|
date | Thu, 17 Sep 2015 22:03:04 -0700 |
parents | 7de3db823f90 |
children | 1093078e7976 |
files | seg2matrix/CGData/CsegToMatrix.cc seg2matrix/CGData/SegToMatrix.py seg2matrix/mapSegToGeneMatrix.py seg2matrix/segToMatrixGalaxy.py segToGeneMatrix.xml segToMatrix.xml |
diffstat | 6 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/seg2matrix/CGData/CsegToMatrix.cc Thu Sep 17 15:38:53 2015 -0700 +++ b/seg2matrix/CGData/CsegToMatrix.cc Thu Sep 17 22:03:04 2015 -0700 @@ -77,7 +77,7 @@ -void print_matrix(segmap *data, set<string> *targetSet, void (*print)(const char *)) { +void print_matrix(segmap *data, set<string> *targetSet, void (*print)(const char *), char* NORMAL_CNV) { //create a break map breakmap breaks; @@ -176,7 +176,7 @@ float val = gm[i][j]; print("\t"); if ( val == MISSING_VAL ) - print("NA"); + print(NORMAL_CNV); else { char str[20] = ""; sprintf(str, "%f", val);
--- a/seg2matrix/CGData/SegToMatrix.py Thu Sep 17 15:38:53 2015 -0700 +++ b/seg2matrix/CGData/SegToMatrix.py Thu Sep 17 22:03:04 2015 -0700 @@ -10,8 +10,7 @@ if os.path.exists(libFile): segLib = ctypes.cdll.LoadLibrary(libFile) - -def seg_to_matrix(seg_handle, out_handle): +def seg_to_matrix(seg_handle, out_handle, NORMAL_CNV): """ Turn a segment file into a segmented matrix. @@ -29,4 +28,4 @@ return 0 printbackTYPE = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_char_p) - segLib.print_matrix(s, t, printbackTYPE(printback)) + segLib.print_matrix(s, t, printbackTYPE(printback), NORMAL_CNV)
--- a/seg2matrix/mapSegToGeneMatrix.py Thu Sep 17 15:38:53 2015 -0700 +++ b/seg2matrix/mapSegToGeneMatrix.py Thu Sep 17 22:03:04 2015 -0700 @@ -7,12 +7,14 @@ if __name__ == "__main__": - if len(sys.argv[:])!=4: - print "python mapSegToGeneMatrix.py genomicsSegmentIn refGene GeneLevelMatrixOut\n" + if len(sys.argv[:])!=5: + print "python mapSegToGeneMatrix.py genomicsSegmentIn refGene GeneLevelMatrixOut NORMAL_CNV\n" sys.exit() refgene = CGData.RefGene.RefGene() refgene.load( sys.argv[2] ) + NORMAL_CNV=sys.argv[4] + #* b for cnv probeMapper = CGData.GeneMap.ProbeMapper('b') @@ -74,7 +76,7 @@ for sample in sample_list: list = matrix[samples[sample]][genes[gene]] if len(list)==0: - average =0 + average = NORMAL_CNV elif len(list)==1: average = list[0] average =round(average,3)
--- a/seg2matrix/segToMatrixGalaxy.py Thu Sep 17 15:38:53 2015 -0700 +++ b/seg2matrix/segToMatrixGalaxy.py Thu Sep 17 22:03:04 2015 -0700 @@ -33,24 +33,25 @@ if __name__ == "__main__": - if len(sys.argv[:])!= 5: - print "python segToMatrixGalaxy.py inputSegmentFile refGeneFile outputMatrix outputProbeMap\n" + if len(sys.argv[:])!= 6: + print "python segToMatrixGalaxy.py inputSegmentFile refGeneFile outputMatrix outputProbeMap NORMAL_CNV\n" sys.exit() seg = CGData.GenomicSegment.GenomicSegment() seg.load(sys.argv[1]) refgene = CGData.RefGene.RefGene() - refgene.load(sys.argv[2]) -# refgene.load(os.path.dirname(sys.argv[0])+"/"+sys.argv[2]) + refgene.load(os.path.dirname(sys.argv[0])+"/"+os.path.basename(sys.argv[2])) + + NORMAL_CNV = sys.argv[5] handle = open(sys.argv[3], "w") m = matrix_write(handle) - CGData.SegToMatrix.seg_to_matrix(seg, m) + CGData.SegToMatrix.seg_to_matrix(seg, m, NORMAL_CNV) handle.close() handle = open(sys.argv[4], "w") probeMapper = CGData.GeneMap.ProbeMapper('b') - handle.write("%s\t%s\t%s\t%s\t%s\t%s\n" % ("#id", "gene","chrom","chromStart","chromEnd","strand")) + handle.write("%s\t%s\t%s\t%s\t%s\t%s\n" % ("id", "gene","chrom","chromStart","chromEnd","strand")) for probe in m.probes: hits = [] for hit in probeMapper.find_overlap( probe, refgene ):
--- a/segToGeneMatrix.xml Thu Sep 17 15:38:53 2015 -0700 +++ b/segToGeneMatrix.xml Thu Sep 17 22:03:04 2015 -0700 @@ -3,7 +3,7 @@ Convert segmented copy number data to gene-level matrix data </description> <command interpreter="python"> - seg2matrix/mapSegToGeneMatrix.py $input $__tool_directory__/seg2matrix/$refGene.assembly $outputMatrix + seg2matrix/mapSegToGeneMatrix.py $input $__tool_directory__/seg2matrix/$refGene.assembly $outputMatrix $normal_CNV_value </command> <inputs> <param name="input" format="tabular" type="data" multiple="false" label="Input segmented copy number data" help="See input data format section for required input format" /> @@ -18,7 +18,8 @@ <when value="hg18"> <param name="assembly" type="hidden" value="refGene_hg18" /> </when> - </conditional> + </conditional> + <param name="normal_CNV_value" type="text" value="0" lable="what is the value to represent normal copy number" /> </inputs> <outputs> <data name="outputMatrix" format="tabular" label="gene-level copy number matrix" />
--- a/segToMatrix.xml Thu Sep 17 15:38:53 2015 -0700 +++ b/segToMatrix.xml Thu Sep 17 22:03:04 2015 -0700 @@ -3,7 +3,7 @@ Prepare segmented copy number data for Xena </description> <command interpreter="python"> - seg2matrix/segToMatrixGalaxy.py $input $__tool_directory__/seg2matrix/$refGene.assembly $outputMatrix $outputProbeMap + seg2matrix/segToMatrixGalaxy.py $input $__tool_directory__/seg2matrix/$refGene.assembly $outputMatrix $outputProbeMap $normal_CNV_value </command> <inputs> <param name="input" format="tabular" type="data" multiple="false" label="Input segmented copy number data" /> @@ -18,7 +18,8 @@ <when value="hg18"> <param name="assembly" type="hidden" value="refGene_hg18" /> </when> - </conditional> + </conditional> + <param name="normal_CNV_value" type="text" value="0" lable="what is the value to represent normal copy number" /> </inputs> <outputs> <data name="outputMatrix" format="tabular" label="xena copy number matrix" />