Skip to content

Commit

Permalink
added --overlap-thresh option and fixed issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
asntech committed May 11, 2018
1 parent ecf2c7e commit 6740905
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
3 changes: 2 additions & 1 deletion docs/modules.rst
Expand Up @@ -52,6 +52,7 @@ This will save the results in the current working directory with a folder named
"--bordercolors","Comma-separated list of matplotlib-valid colors for borders. E.g., --bordercolors=r,b,k"
"-o, --output","Output folder path where results will be stored. Default is current working directory."
"--save-overlaps","Save overlapping regions/names for all the combinations as bed/txt files. Default is ``False``"
"--overlap-thresh", "Minimum threshold to save the overlapping regions/names as bed/txt. Default is ``1``"
"--figtype","{pdf,svg,ps,tiff,png} Figure type for the plot. e.g. --figtype svg. Default is ``pdf``"
"--figsize","Figure size as width and height.e.g. --figsize 12 12."
"--fontsize","Font size for the plot labels. Default is ``14``"
Expand Down Expand Up @@ -105,6 +106,7 @@ This will save the results in the current working directory with a folder named
"--bedtools-options","List any of the arguments available for bedtool’s intersect command. Type bedtools intersect --help to view all the options. For example: --bedtools-options f=0.8,r,etc"
"-o, --output","Output folder path where plots will store. Default is current working directory."
"--save-overlaps","Save overlapping regions/names for all the combinations as bed/txt files. Default is ``False``"
"--overlap-thresh", "Minimum threshold to save the overlapping regions/names as bed/txt. Default is ``1``"
"--order", "The order of intersections of sets {freq,degree}. e.g. --order degree. Default is ``freq`` "
"--ninter", "Number of top intersections to plot. Default is ``30``"
"--showzero", "Show empty overlap combinations. Default is ``False``"
Expand All @@ -119,7 +121,6 @@ This will save the results in the current working directory with a folder named
"--scriptonly", "Set to generate Rscript only, if R/UpSetR package is not installed. Default is ``False``"
"--showshiny", "Print the combinations of intersections to input to Shiny App. Default is ``False``"

Pairwise intersection module
============================
Once you have installed Intervene, you can type:
Expand Down
2 changes: 1 addition & 1 deletion intervene/__init__.py
@@ -1 +1 @@
__version__ = '0.6.2'
__version__ = '0.6.3'
13 changes: 13 additions & 0 deletions intervene/intervene
Expand Up @@ -21,6 +21,11 @@ from intervene import helpers
from argparse import ArgumentParser, RawTextHelpFormatter
import intervene

import matplotlib
#TrueType fonts for PostScript and PDF files
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42

#main function
def main():

Expand Down Expand Up @@ -66,6 +71,10 @@ def main():
help='Save overlapping regions/names for all the combinations as bed/txt. '
'Default is "%(default)s".\n\n')

venn_parser.add_argument('--overlap-thresh', dest='overlapthresh', type=int, default=1,
help='Minimum threshold to save the overlapping regions/names as bed/txt. '
'Default is: "%(default)s"\n\n')

venn_parser.add_argument('--title', type=str, dest='title',
help='Title of the plot. '
'By default it is not set.\n\n')
Expand Down Expand Up @@ -137,6 +146,10 @@ def main():
help='Save overlapping regions/names for all the combinations as bed/txt.'
'Default is "%(default)s".\n\n')

upset_parser.add_argument('--overlap-thresh', dest='overlapthresh', type=int, default=1,
help='Minimum threshold to save the overlapping regions/names as bed/txt. '
'Default is: "%(default)s"\n\n')

upset_parser.add_argument('--project', type=str, default="Intervene",
help='Project name for the output. '
'Default is: "%(default)s"\n\n')
Expand Down
42 changes: 22 additions & 20 deletions intervene/modules/upset/upset.py
Expand Up @@ -53,15 +53,16 @@ def genomic_upset(options, label_names):

#save the intersected results
if options.saveoverlaps:
file_name = ''
name_itr = 0
for name in t:
if name == '1':
file_name += '_'+label_names[name_itr]
name_itr +=1
file_name = ''.join(t)+file_name
hlp.create_dir(output+'/sets')
x.moveto(output+'/sets/'+file_name+'.bed')
if X >= options.overlapthresh:
file_name = ''
name_itr = 0
for name in t:
if name == '1':
file_name += '_'+label_names[name_itr]
name_itr +=1
file_name = ''.join(t)+file_name
hlp.create_dir(output+'/sets')
x.moveto(output+'/sets/'+file_name+'.bed')

#delete all temp files
helpers.cleanup()
Expand Down Expand Up @@ -95,17 +96,18 @@ def list_upset(options, label_names):

#save the intersected results
if options.saveoverlaps:
file_name = ''
name_itr = 0
for name in t:
if name == '1':
file_name += '_'+label_names[name_itr]
name_itr +=1
file_name = ''.join(t)+file_name
hlp.create_dir(output+'/sets')
inter_file = open(output+'/sets/'+file_name+'.txt', 'w')
inter_file.writelines('\n'.join(list(X)))
inter_file.close()
if len(X) >= options.overlapthresh:
file_name = ''
name_itr = 0
for name in t:
if name == '1':
file_name += '_'+label_names[name_itr]
name_itr +=1
file_name = ''.join(t)+file_name
hlp.create_dir(output+'/sets')
inter_file = open(output+'/sets/'+file_name+'.txt', 'w')
inter_file.writelines('\n'.join(list(X)))
inter_file.close()

return(weights)

Expand Down
5 changes: 5 additions & 0 deletions intervene/modules/venn/list_venn.py
Expand Up @@ -8,6 +8,11 @@
import matplotlib.patches as patches
from matplotlib import colors
import math
import matplotlib

#TrueType fonts for PostScript and PDF files
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42

default_colors = [
# r, g, b, a
Expand Down

0 comments on commit 6740905

Please sign in to comment.