# HG changeset patch # User jingchunzhu # Date 1442552584 25200 # Node ID 59dbe857f5d472815e521d4a5af5e9579e864ac5 # Parent 7de3db823f903cefc583ba047e086d8f5763d992 introduce normal_CNV parameter diff -r 7de3db823f90 -r 59dbe857f5d4 seg2matrix/CGData/CsegToMatrix.cc --- 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 *targetSet, void (*print)(const char *)) { +void print_matrix(segmap *data, set *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); diff -r 7de3db823f90 -r 59dbe857f5d4 seg2matrix/CGData/SegToMatrix.py --- 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) diff -r 7de3db823f90 -r 59dbe857f5d4 seg2matrix/mapSegToGeneMatrix.py --- 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) diff -r 7de3db823f90 -r 59dbe857f5d4 seg2matrix/segToMatrixGalaxy.py --- 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 ): diff -r 7de3db823f90 -r 59dbe857f5d4 segToGeneMatrix.xml --- 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 - seg2matrix/mapSegToGeneMatrix.py $input $__tool_directory__/seg2matrix/$refGene.assembly $outputMatrix + seg2matrix/mapSegToGeneMatrix.py $input $__tool_directory__/seg2matrix/$refGene.assembly $outputMatrix $normal_CNV_value @@ -18,7 +18,8 @@ - + + diff -r 7de3db823f90 -r 59dbe857f5d4 segToMatrix.xml --- 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 - 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 @@ -18,7 +18,8 @@ - + +