[hg] galaxy 3573: added a grey option for manhattan plot chromos...
details: http://www.bx.psu.edu/hg/galaxy/rev/b5757fb7ab13 changeset: 3573:b5757fb7ab13 user: fubar: ross Lazarus at gmail period com date: Fri Mar 26 22:40:46 2010 -0400 description: added a grey option for manhattan plot chromosome colours diffstat: tools/rgenetics/rgCaCo.py | 15 +++++++-------- tools/rgenetics/rgManQQ.py | 16 ++++++++++------ tools/rgenetics/rgManQQ.xml | 4 +++- tools/rgenetics/rgQC.xml | 4 ++-- 4 files changed, 22 insertions(+), 17 deletions(-) diffs (138 lines): diff -r b8689cf28fa7 -r b5757fb7ab13 tools/rgenetics/rgCaCo.py --- a/tools/rgenetics/rgCaCo.py Fri Mar 26 16:46:44 2010 -0400 +++ b/tools/rgenetics/rgCaCo.py Fri Mar 26 22:40:46 2010 -0400 @@ -112,14 +112,13 @@ if p <> 'NA': # eesh logp = '%9.9f' % -math.log10(p) else: - logp = '1' + logp = 'NA' try: orat = ll[8] - if orat == 'NA': - orat = '1' except: - orat = '1' + orat = 'NA' orat2 = orat + # invert large negative odds ratios if float(orat) < 1 and float(orat) > 0.0: orat2 = '%9.9f' % (1.0/float(orat)) outl = [ll[1],logp, orat2, orat] @@ -207,16 +206,16 @@ flog.write('### offending line #%d in %s = %s' % (lnum,l)) except: pass - width = max(3,1+int(abs(lp))) # get desired precision for output - w = '%d' % width - fps = '%%%s.%sf' % (w,w) # eg '%9.9f' if snp <> lastsnp: if len(outl.keys()) > 3: sl = [outl.get(x,'?') for x in ('snp','chrom','offset','GENO','TREND','ALLELIC','DOM')] res.append('\t'.join(sl)) # last snp line outl = {'snp':snp,'chrom':chrom,'offset':offset} # first 3 cols for gg line lastsnp = snp # reset for next marker - outl[test] = '\t'.join([(fps % fp).strip(),('%6.6f' % lp).strip()]) + #if p == 'NA': + # p = 1.0 + # let's pass downstream for handling R is fine? + outl[test] = '%s\t%f' % (p,lp) if len(outl.keys()) > 3: l = [outl.get(x,'?') for x in ('snp','chrom','offset','GENO','TREND','ALLELIC','DOM')] res.append('\t'.join(l)) # last snp line diff -r b8689cf28fa7 -r b5757fb7ab13 tools/rgenetics/rgManQQ.py --- a/tools/rgenetics/rgManQQ.py Fri Mar 26 16:46:44 2010 -0400 +++ b/tools/rgenetics/rgManQQ.py Fri Mar 26 22:40:46 2010 -0400 @@ -31,7 +31,7 @@ manhattan = function(chrom=NULL,offset=NULL,pvals=NULL, title=NULL, max.y="max", - suggestiveline=0, genomewide=T, size.x.labels=9, size.y.labels=10, annotate=F, SNPlist=NULL,grey=F) { + suggestiveline=0, genomewide=T, size.x.labels=9, size.y.labels=10, annotate=F, SNPlist=NULL,grey=0) { if (annotate & is.null(SNPlist)) stop("You requested annotation but provided no SNPlist!") genomewideline=NULL # was genomewideline=-log10(5e-8) @@ -120,7 +120,7 @@ # instantiate rcode2 string with infile,chromcol,offsetcol,pvalscols,title before saving and running rcode2 = """rgqqMan = function(infile="%s",chromcolumn=%d, offsetcolumn=%d, pvalscolumns=%s, - title="%s") { + title="%s",grey=%d) { d = read.table(infile,head=T,sep='\t') print(paste('###',length(d[,1]),'values read from',infile,'read - now running plots',sep=' ')) for (pvalscolumn in pvalscolumns) { @@ -133,7 +133,7 @@ print(paste('## qqplot on',cname,'done')) if ((chromcolumn > 0) & (offsetcolumn > 0)) { print(paste('## manhattan on',cname,'starting',chromcolumn,offsetcolumn,pvalscolumn)) - mymanplot= manhattan(chrom=d[,chromcolumn],offset=d[,offsetcolumn],pvals=d[,pvalscolumn],title=mytitle) + mymanplot= manhattan(chrom=d[,chromcolumn],offset=d[,offsetcolumn],pvals=d[,pvalscolumn],title=mytitle,grey=grey) print(paste('## manhattan plot on',cname,'done')) ggsave(file=paste(myfname,"manhattan.png",sep='_'),mymanplot,width=11,height=8,dpi=100) } @@ -141,7 +141,7 @@ print(paste('chrom column =',chromcolumn,'offset column = ',offsetcolumn, 'so no Manhattan plot - supply both chromosome and offset as numerics for Manhattan plots if required')) } - ggsave(file=paste(myfname,"qqplot.png",sep='_'),myqqplot,w=5,h=5,dpi=100) + ggsave(file=paste(myfname,"qqplot.png",sep='_'),myqqplot,width=8,height=11,dpi=100) } else { print(paste('pvalue column =',pvalscolumn,'Cannot parse it so no plots possible')) @@ -160,7 +160,7 @@ </command> """ print >> sys.stdout,'## rgManQQ.py. cl=',sys.argv - npar = 7 + npar = 8 if len(sys.argv) < npar: print >> sys.stdout, '## error - too few command line parameters - wanting %d' % npar print >> sys.stdout, u @@ -189,7 +189,11 @@ if chrom_col == 1 or offset_col == 1: # was passed as zero - do not do manhattan plots chrom_col = 0 offset_col = 0 - rcmd = '%s%s' % (rcode,rcode2 % (input_fname,chrom_col,offset_col,pval_cols,title)) + if sys.argv[8].lower() in ['1','true']: + grey = 1 + else: + grey = 0 + rcmd = '%s%s' % (rcode,rcode2 % (input_fname,chrom_col,offset_col,pval_cols,title,grey)) rlog,flist = RRun(rcmd=rcmd,title=ctitle,outdir=outdir) flist.sort() html = [galhtmlprefix % progname,] diff -r b8689cf28fa7 -r b5757fb7ab13 tools/rgenetics/rgManQQ.xml --- a/tools/rgenetics/rgManQQ.xml Fri Mar 26 16:46:44 2010 -0400 +++ b/tools/rgenetics/rgManQQ.xml Fri Mar 26 22:40:46 2010 -0400 @@ -4,7 +4,7 @@ <description>Plots for WGA P values</description> <command interpreter="python"> - rgManQQ.py '$i' "$name" '$out_html' '$out_html.files_path' '$chrom_col' '$offset_col' '$pval_col' + rgManQQ.py '$i' "$name" '$out_html' '$out_html.files_path' '$chrom_col' '$offset_col' '$pval_col' '$grey' </command> <inputs> @@ -23,6 +23,8 @@ <param name="offset_col" type='select' label = 'Base pair offset column in input file' help='Select "None" if offset not available or no Manhattan plot required' dynamic_options="get_phecols(i,True,'offs')" /> + <param name="grey" type="boolean" checked="false" truevalue="true" falsevalue="false" + label="Grey scale for Manhatten plot (default is colour"/> </page> </inputs> diff -r b8689cf28fa7 -r b5757fb7ab13 tools/rgenetics/rgQC.xml --- a/tools/rgenetics/rgQC.xml Fri Mar 26 16:46:44 2010 -0400 +++ b/tools/rgenetics/rgQC.xml Fri Mar 26 22:40:46 2010 -0400 @@ -27,8 +27,8 @@ <composite_data value='tinywga.fam' /> </param> <param name='out_prefix' value='rgQCtest1' /> - <output name='html_file' file='rgtestouts/rgQC/rgQCtest1.html' ftype='html' lines_diff='437'> - <extra_files type="file" name='tinywga_All_Paged.pdf' value="rgtestouts/rgQC/tinywga_All_Paged.pdf" compare="diff" lines_diff="1190"/> + <output name='html_file' file='rgtestouts/rgQC/rgQCtest1.html' ftype='html' lines_diff='250'> + <extra_files type="file" name='tinywga_All_Paged.pdf' value="rgtestouts/rgQC/tinywga_All_Paged.pdf" compare="diff" lines_diff="2600"/> <extra_files type="file" name='tinywga.log' value="rgtestouts/rgQC/tinywga.log" compare="diff" lines_diff="10"/> <extra_files type="file" name='tinywga.frq' value="rgtestouts/rgQC/tinywga.frq" compare="diff" /> <extra_files type="file" name='tinywga.het' value="rgtestouts/rgQC/tinywga.het" compare="diff" />
participants (1)
-
Greg Von Kuster