Repository 'snp_mapping_using_wgs'
hg clone https://toolshed.g2.bx.psu.edu/repos/gregory-minevich/snp_mapping_using_wgs

Changeset 2:2f85060670a5 (2012-03-20)
Previous changeset 1:619b943864a9 (2012-03-20) Next changeset 3:9cec8343aa5f (2012-03-20)
Commit message:
Deleted selected files
removed:
._SNP_Mapping.py
._SNP_Mapping.xml
SNP_Mapping.py
SNP_Mapping.xml
b
diff -r 619b943864a9 -r 2f85060670a5 ._SNP_Mapping.py
b
Binary file ._SNP_Mapping.py has changed
b
diff -r 619b943864a9 -r 2f85060670a5 ._SNP_Mapping.xml
b
Binary file ._SNP_Mapping.xml has changed
b
diff -r 619b943864a9 -r 2f85060670a5 SNP_Mapping.py
--- a/SNP_Mapping.py Tue Mar 20 10:40:15 2012 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
b'@@ -1,341 +0,0 @@\n-#!/usr/bin/python\n-\n-import re\n-import sys\n-import optparse\n-import csv\n-import re\n-from decimal import *\n-from rpy import *\n-\n-def main():\n-\tcsv.field_size_limit(1000000000)\n-\n-\tparser = optparse.OptionParser()\n-\tparser.add_option(\'-p\', \'--sample_pileup\', dest = \'sample_pileup\', action = \'store\', type = \'string\', default = None, help = "Sample pileup from mpileup")\n-\tparser.add_option(\'-v\', \'--haw_vcf\', dest = \'haw_vcf\', action = \'store\', type = \'string\', default = None, help = "vcf file of Hawaiian SNPs")\n-\tparser.add_option(\'-l\', \'--loess_span\', dest = \'loess_span\', action = \'store\', type = \'float\', default = .01, help = "Loess span")\n-\tparser.add_option(\'-d\', \'--d_yaxis\', dest = \'d_yaxis\', action = \'store\', type = \'float\', default = .7, help = "y-axis upper limit for dot plot")  \n-\tparser.add_option(\'-y\', \'--h_yaxis\', dest = \'h_yaxis\', action = \'store\', type = \'int\', default = 500, help = "y-axis upper limit for dot plot")   \n-\tparser.add_option(\'-c\', \'--points_color\', dest = \'points_color\', action = \'store\', type = \'string\', default = "gray27", help = "Color for data points") \n-\tparser.add_option(\'-k\', \'--loess_color\', dest = \'loess_color\', action = \'store\', type = \'string\', default = "red", help = "Color for loess regression line")        \n-\tparser.add_option(\'-z\', \'--standardize\', dest = \'standardize\', default= \'false\', help = "Standardize X-axis")\n-\n-\tparser.add_option(\'-o\', \'--output\', dest = \'output\', action = \'store\', type = \'string\', default = None, help = "Output file name")\n-\tparser.add_option(\'-s\', \'--location_plot_output\', dest = \'location_plot_output\', action = \'store\', type = \'string\', default = "SNP_Mapping_Plot.pdf", help = "Output file name of SNP plots by chromosomal location")\n-\n-\t#For plotting with map units on the X-axis instead of physical distance\n-\t#parser.add_option(\'-u\', \'--mpu_plot_output\', dest = \'mpu_plot_output\', action = \'store\', type = \'string\', default = None, help = "Output file name of SNP plots by map unit location")\n-\t(options, args) = parser.parse_args()\n-\n-\thaw_snps = build_haw_snp_dictionary(haw_vcf = options.haw_vcf)\t\n-\tpileup_info = parse_pileup(sample_pileup = options.sample_pileup, haw_snps = haw_snps)\n-\toutput_pileup_info(output = options.output, pileup_info = pileup_info)\n-\n-\t#output plot with all ratios\n-\toutput_scatter_plots_by_location(location_plot_output = options.location_plot_output, pileup_info = pileup_info, loess_span=options.loess_span, d_yaxis=options.d_yaxis, h_yaxis=options.h_yaxis, points_color=options.points_color, loess_color=options.loess_color, standardize =options.standardize)\n-\n-\t#For plotting with map units on the X-axis instead of physical distance)\n-\t#output_scatter_plots_by_mapping_units(mpu_plot_output = options.mpu_plot_output, pileup_info = pileup_info)\n-\n-def skip_headers(reader = None, i_file = None):\n-\t# count headers\n-\tcomment = 0\n-\twhile reader.next()[0].startswith(\'#\'):\n-\t\tcomment = comment + 1\n-\t\n-\t# skip headers\n-\ti_file.seek(0)\n-\tfor i in range(0, comment):\n-\t\treader.next()\n-\n-def location_comparer(location_1, location_2):\n-\tchr_loc_1 = location_1.split(\':\')[0]\n-\tpos_loc_1 = int(location_1.split(\':\')[1])\n-\n-\tchr_loc_2 = location_2.split(\':\')[0]\n-\tpos_loc_2 = int(location_2.split(\':\')[1])\n-\n-\tif chr_loc_1 == chr_loc_2:\n-\t\tif pos_loc_1 < pos_loc_2:\n-\t\t\treturn -1\n-\t\telif pos_loc_1 == pos_loc_1:\n-\t\t\treturn 0\n-\t\telif pos_loc_1 > pos_loc_2:\n-\t\t\treturn 1\n-\telif chr_loc_1 < chr_loc_2:\n-\t\treturn -1\n-\telif chr_loc_1 > chr_loc_2:\n-\t\treturn 1\n-\n-def output_pileup_info(output = None, pileup_info = None):\n-\to_file = open(output, \'wb\')\n-\twriter = csv.writer(o_file, delimiter = \'\\t\')\n-\n-\twriter.writerow(["#Chr\\t", "Pos\\t", "ID\\t", "Alt Count\\t", "Ref Count\\t", "Read Depth\\t", "Ratio\\t", "Mapping Unit"])\n-\n-\tlocation_sorted_pileup_info_keys = sorted(pileup_info.keys(), cmp=location_comparer)\n-\n-\tfor location in location_sorted_pileup_info_keys:\n-\t\talt_allele_count, ref_allele_count, read_depth, ratio, haw_snp_id, mapping_unit = pileup_inf'..b'), by=0.5), labels=FALSE, tcl=-0.25)")\t\n-\t\tr("axis(2, at=seq(floor(min(y)), 1, by=0.1), labels=FALSE, tcl=-0.2)")\n-\n-\t\t\n-\tif draw_secondary_grid_lines:\n-\t\tr("abline(h = seq(floor(min(y)), 1, by=0.1), v = seq(floor(min(x)), length(x), by= 1), col=\'gray\')")\n-\telse:\n-\t\tr("grid(lty = 1, col = \'gray\')")\n-\n-\tif (standardize==\'true\'):\n-\t\tr("hist(xz, col=\'darkgray\', xlim=c(0,21), xlab=\'Location (Mb)\', ylab=\'Frequency SNP Positions Where HA Ratio=0 \', ylim=c(0, %f " %h_yaxis + "), breaks = seq(0, as.integer( \' " + str(breaks) + " \'), by=1), main=\'LG " + chr + "\')")\n-\t\tr("hist(xz, add=TRUE, col=rgb(1, 0, 0, 1), xlim=c(0,21), xlab=\'Location (Mb)\', ylab=\'Frequency SNP Positions Where HA Ratio=0 \', ylim=c(0, %f " %h_yaxis + "), breaks = seq(0, as.integer( \' " + str(breaks) + " \'), by=.5), main=\'Chr " + chr + "\')")\n-\t\tr("axis(1, at=seq(0, 21, by=1), labels=FALSE, tcl=-0.5)")\n-\t\tr("axis(1, at=seq(0, 21, by=0.5), labels=FALSE, tcl=-0.25)")\n-\telif (standardize==\'false\'):\n-\t\tr("hist(xz, col=\'darkgray\', xlab=\'Location (Mb)\', ylab=\'Frequency SNP Positions Where HA Ratio=0 \', ylim=c(0, %f " %h_yaxis + "), breaks = seq(0, as.integer( \' " + str(breaks) + " \'), by=1), main=\'LG " + chr + "\')")\n-\t\tr("hist(xz, add=TRUE, col=rgb(1, 0, 0, 1), xlab=\'Location (Mb)\', ylab=\'Frequency SNP Positions Where HA Ratio=0 \', ylim=c(0, %f " %h_yaxis + "), breaks = seq(0, as.integer( \' " + str(breaks) + " \'), by=.5), main=\'Chr " + chr + "\')")\t\n-\t\tr("axis(1, at=seq(0, as.integer( \' " + str(breaks) + " \'), by=1), labels=FALSE, tcl=-0.5)")\n-\t\tr("axis(1, at=seq(0, as.integer( \' " + str(breaks) + " \'), by=0.5), labels=FALSE, tcl=-0.25)")\n-\n-\n-def build_haw_snp_dictionary(haw_vcf = None):\n-\thaw_snps = {}\n-\t\n-\ti_file = open(haw_vcf, \'rU\')\n-\treader = csv.reader(i_file, delimiter = \'\\t\')\n-\n-\tskip_headers(reader = reader, i_file = i_file)\n-\t\n-\tfor row in reader:\n-\t\t#print row\n-\t\tchromosome = row[0].upper()\n-\t\tchromosome = re.sub("chr", "", chromosome, flags = re.IGNORECASE)\n-\t\tchromosome = re.sub("CHROMOSOME_", "", chromosome, flags = re.IGNORECASE)\n-\n-\t\tposition = row[1]\n-\t\thaw_snp_id = row[2]\n-\t\tref_allele = row[3]\n-\t\talt_allele = row[4]\n-        \tinfo = row[7]\n-            \n-        \tmapping_unit = info.replace("MPU=", "")\n-\n-\t\tlocation = chromosome + ":" + position\n-\t\thaw_snps[location] = (alt_allele, haw_snp_id, mapping_unit)\n-\n-\ti_file.close()\n-\n-\treturn haw_snps\n-\n-def parse_pileup(sample_pileup = None, haw_snps = None):\n-\ti_file = open(sample_pileup, \'rU\')\n-\treader = csv.reader(i_file, delimiter = \'\\t\', quoting = csv.QUOTE_NONE)\t\n-\n-\tpileup_info = {}\n-\n-\tfor row in reader:\n-\t\tchromosome = row[0].upper()\n-\t\tchromosome = re.sub("chr", "", chromosome, flags = re.IGNORECASE)\n-\t\tchromosome = re.sub("CHROMOSOME_", "", chromosome, flags = re.IGNORECASE)\n-\n-\t\tposition = row[1]\n-\t\tref_allele = row[2]\n-\t\tread_depth = row[3]\n-\t\tread_bases = row[4]\n-\n-\t\tlocation = chromosome + ":" + position\n-\t\tif location in haw_snps:\n-\t\t\talt_allele, haw_snp_id, mapping_unit = haw_snps[location]\n-\t\t\tref_allele_count, alt_allele_count = parse_read_bases(read_bases = read_bases, alt_allele = alt_allele)\n-\t\t\n-\t\t\tgetcontext().prec = 6\t\n-\t\t\tratio = Decimal(alt_allele_count) / Decimal(read_depth)\n-\t\t\n-\t\t\tpileup_info[location] = (alt_allele_count, ref_allele_count, read_depth, ratio, haw_snp_id, mapping_unit)\n-\t\t\n-\t\t\t#debug line\n-\t\t\t#print chromosome, position, read_depth, ref_allele_count, alt_allele_count, ratio, id\n-\n-\ti_file.close()\n-\n-\treturn pileup_info\n-\n-def parse_read_bases(read_bases = None, alt_allele = None):\n-\tread_bases = re.sub(\'\\$\', \'\', read_bases)\n-\tread_bases = re.sub(\'\\^[^\\s]\', \'\', read_bases)\n-\n-\tref_allele_matches = re.findall("\\.|\\,", read_bases)\n-\tref_allele_count = len(ref_allele_matches)\n-\n-\talt_allele_matches = re.findall(alt_allele, read_bases, flags = re.IGNORECASE)\n-\talt_allele_count = len(alt_allele_matches)\n-\n-\t#debug line\n-\t#print read_bases, alt_allele, alt_allele_count, ref_allele_count\n-\n-\treturn ref_allele_count, alt_allele_count\n-\n-if __name__ == "__main__":\n-\tmain()\n'
b
diff -r 619b943864a9 -r 2f85060670a5 SNP_Mapping.xml
--- a/SNP_Mapping.xml Tue Mar 20 10:40:15 2012 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
b
@@ -1,109 +0,0 @@
-<tool id="SNP_Mapping" name="SNP Mapping">
-    <description>Map a mutation by plotting recombination frequencies resulting from crossing to a highly polymorphic strain</description>
-    <command interpreter="python">SNP_Mapping.py --sample_pileup $sample_pileup --haw_vcf $haw_vcf --loess_span $loess_span --d_yaxis $d_yaxis --h_yaxis $h_yaxis --points_color $points_color --loess_color $loess_color --output $output --location_plot_output $location_plot_output --standardize $standardize</command>
-    <inputs>
-        <param name="sample_pileup" size = "125" type="data" format="pileup" label="WGS Mutant Pileup File" help="WGS pileup file from pooled F2 mutants that have been crossed to a mapping strain. The pileup should contain data from only mapping strain (e.g. Hawaiian) SNP positions" />
- <param name="haw_vcf" size = "125" type="data" format="vcf" label="VCF of mapping strain (e.g. Hawaiian) SNPs" help="A VCF reference file that contains mapping strain SNP positions and reference base pairs at each position"/>
- <param name="loess_span" size = "15" type="float" value=".01" label="Loess span" help="Parameter that controls the degree of data smoothing."/>    
- <param name="d_yaxis" size = "15" type="float" value=".7" label="Y-axis upper limit for dot plot" />
- <param name="h_yaxis" size = "15" type="integer" value="500" label="Y-axis upper limit for histogram plot" />
- <param name="points_color" size = "15" type="text" value="gray27" label="Color for data points" help="See below for list of supported colors"/> 
- <param name="loess_color" size = "15" type="text" value="red" label="Color for loess regression line" help="See below for list of supported colors"/>
- <param name="standardize" type="boolean" truevalue="true" falsevalue="false" checked="true"  label="Standardize X-axis" help="Dot plots and histogram plots from separate chromosomes will have uniform X-axis spacing for comparison"/>          
-    </inputs>
-    <outputs>
-        <data name="output" type="text" format="tabular" />
- <data name="location_plot_output" format="pdf" />
-    </outputs>
-    <requirements>
-        <requirement type="python-module">sys</requirement>
-        <requirement type="python-module">optparse</requirement>
-        <requirement type="python-module">csv</requirement>
-        <requirement type="python-module">re</requirement>
- <requirement type="python-module">decimal</requirement>
-        <requirement type="python-module">rpy</requirement>
-    </requirements>
-    <tests>
- <param name="sample_pileup" value="" />
- <param name="haw_vcf" value="" />
- <output name="output" file="" />
- <output name="plot_output" file="" />
-    </tests>
-    <help>
-**What it does:** 
-
-This tool improves upon the method described in Doitsidou et al., PLoS One 2010 for mapping causal mutations using whole genome sequencing data. Sample output for a linked chromosome:
-
-.. image:: http://biochemistry.hs.columbia.edu/labs/hobert/CloudMap/SNP_Mapping_Linked_LG.pdf
-
-
-
-The polymorphic Hawaiian strain CB4856 is used as a mapping strain in most cases but in principle any sequenced nematode strain that is significantly different from the mutant strain can be used for mapping. The tool plots the ratio of mutant strain (N2)/mapping strain (Hawaiian) nucleotides, reflecting the number of recombinants in the sequenced pool of animals. Chromosomes which contain regions of linkage to the causal mutation will have regions where the ratio of mapping strain (Hawaiian)/total reads will be equal to 0. The scatter plots for such linked regions will have a high number of data points lying exactly on the X axis. A loess regression line is plotted through all the points on a given chromosome giving further accuracy to the linked region. 
-
-Each scatter plot has a corresponding frequency plot that displays regions of linked chromosome where 0 ratio SNP positions are concentrated. 1Mb bins for the 0 ratio SNP positions are colored gray by default and .5Mb bins are colored in red.
-
-
-The experimental design required to generate data for the plots is described in Doisidou et al., PLoS One 2010 Figure 1:
-
-.. image:: http://biochemistry.hs.columbia.edu/labs/hobert/CloudMap/Doitsidou_2010_PLoS_Fig1.pdf
-
-
-------
-
-**Input:** 
-
-
-The input pileup files are generated by the SAMTools mpileup tool. Default SAMTools mpileup (and Samtools filter pileup) parameters for mapping quality, base quality and coverage at each SNP position typically yield good results, though users may experiment with filtering SNP data according to these parameters. In our testing, low threshold filtering on base pair quality has been useful in improving accuracy of plots while high threshold filtering on coverage has skewed plot accuracy.  
-
-This tool requires a pileup that has been created at each SNP position using SAMTools mpileup and a BED file of all Hawaiian SNP positions. Download Hawaiian SNP positions BED file here:
-http://biochemistry.hs.columbia.edu/labs/hobert/protocols.html
-
-The required VCF of mapping strain (e.g. Hawaiian) SNPs is a reference file that contains mapping strain SNP positions and reference base pairs at each position.
-(download Hawaiian SNPs VCF from: http://biochemistry.hs.columbia.edu/labs/hobert/protocols.html). You may also make your own VCF of SNP positions following the steps described in the CloudMAP paper.
-
-
-**Output:**
-
-The tool also provides a tabular output file that contains a count of the number of reference and alternate SNPs at each mapping strain SNP position as well as the ratio of reference/alternate SNPs. The position of each mapping strain SNP in map units and physical coordinates is also provided in the output file.  
-
-
-------
-
-**Settings:**
-
-.. class:: infomark
-
-Information on loess regression and the loess span parameter:
-http://en.wikipedia.org/wiki/Local_regression
-
-.. class:: infomark
-
-Based on our testing, we've settled on .01 as a loess span default. Larger values result in smoothing of the line to reflect trends at a more macro level. Smaller values result in loess lines that more closely reflect local data fluctuations. Users looking at chromosome subregions will want to increase the loess span.
-
-.. class:: infomark
-
-Supported colors for data points and loess regression line:
-
-http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf
-
-http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf
-
-
-
-.. class:: warningmark
-
-This tool requires that R has been installed on your system (http://www.r-project.org/).
-
-
-------
-
-**Citation:**
-
-This tool is part of the CloudMap package from the Hobert Lab. If you use this tool, please cite `Gregory Minevich, Danny Park, Richard J. Poole and Oliver Hobert CloudMap: A Cloud-based Pipeline for Analysis of Mutant Genome Sequences. (2012 In Preparation)`__
-
-    .. __: http://biochemistry.hs.columbia.edu/labs/hobert/literature.html
-
-
-
-    </help>
-</tool>