Skip to content

Commit

Permalink
added activity plot filtering parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rfarouni committed Dec 12, 2017
1 parent 8626f42 commit 64ed75f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Epigenetic Variability and Motif Analysis Pipeline
--------------------------------------------------
**Current version**: 0.5.2
**Current version**: 0.5.3

[![Build Status](https://travis-ci.org/pinellolab/haystack_bio.svg?branch=master)](https://travis-ci.org/pinellolab/haystack_bio)

Expand Down
4 changes: 2 additions & 2 deletions haystack/download_genome.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

from haystack_common import initialize_genome
from haystack_common import initialize_genome, HAYSTACK_VERSION
import argparse
import sys
HAYSTACK_VERSION = "0.5.2"

def get_args_download_genome():
# mandatory
parser = argparse.ArgumentParser(description='download_genome parameters')
Expand Down
4 changes: 1 addition & 3 deletions haystack/find_hotspots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#from pybedtools import BedTool
import multiprocessing
import glob
from haystack_common import determine_path, check_file, check_required_packages, initialize_genome
from haystack_common import determine_path, check_file, check_required_packages, initialize_genome, HAYSTACK_VERSION

import logging
logging.basicConfig(level=logging.INFO,
Expand All @@ -21,8 +21,6 @@
debug = logging.debug
info = logging.info

HAYSTACK_VERSION = "0.5.2"

do_not_recompute = None
keep_intermediate_files= None

Expand Down
4 changes: 2 additions & 2 deletions haystack/find_motifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import pickle as cp

# commmon functions
from haystack_common import determine_path, which, check_file, initialize_genome
HAYSTACK_VERSION = "0.5.2"
from haystack_common import determine_path, which, check_file, initialize_genome, HAYSTACK_VERSION

# dependencies
from bioutilities import Coordinate, Sequence, Fimo
import numpy as np
Expand Down
19 changes: 13 additions & 6 deletions haystack/generate_tf_activity_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import argparse
from itertools import chain
import logging
from haystack_common import determine_path, check_file
from haystack_common import determine_path, check_file, HAYSTACK_VERSION

HAYSTACK_VERSION = "0.5.2"

logging.basicConfig(level=logging.INFO,
format='%(levelname)-5s @ %(asctime)s:\n\t %(message)s \n',
Expand Down Expand Up @@ -77,6 +76,14 @@ def get_args_activity():
parser.add_argument('--plot_all',
help='Disable the filter on the TF activity and correlation (default z-score TF>0 and rho>0.3)',
action='store_true')
parser.add_argument('--rho_cutoff',
type=float,
default=0.3,
help='The cutoff absolute correlation value (0.0 to 1) for which activity plots are generated (default: 0.3)')
parser.add_argument('--tf_value_cuttoff',
type=float,
default=0.0,
help='The cutoff z-score tf_value for which activity plots are generated (default: 0.0) ')
parser.add_argument('--version',
help='Print version and exit.',
action='version',
Expand Down Expand Up @@ -209,16 +216,16 @@ def main(input_args=None):

if USE_ZSCORE:
# correlation
ro = np.corrcoef(tf_values, ds_values)[0, 1]
rho = np.corrcoef(tf_values, ds_values)[0, 1]

tf_value = tf_values[target_cell_type]
ds_value = ds_values[target_cell_type]

info('Gene:%s TF z-score:%.2f Targets z-score:%.2f Correlation:%.2f' % (
gene_name, tf_value, ds_value, ro))
gene_name, tf_value, ds_value, rho))

# make plots
if (tf_value > 0 and np.abs(ro) > 0.3) or args.plot_all:
if (tf_value > args.tf_value_cuttoff and np.abs(rho) > args.rho_cutoff) or args.plot_all:
x_min = min(-4, tf_values.min() * 1.1)
x_max = max(4, tf_values.max() * 1.1)
y_min = min(-4, ds_values.min() * 1.1)
Expand All @@ -237,7 +244,7 @@ def main(input_args=None):
numpoints=1)

ax.set_aspect('equal')
plt.text(x_min * 0.98, y_max * 0.85, r'$\rho$=%.2f' % ro, fontsize=14)
plt.text(x_min * 0.98, y_max * 0.85, r'$\rho$=%.2f' % rho, fontsize=14)
plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)

Expand Down
4 changes: 4 additions & 0 deletions haystack/haystack_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
debug = logging.debug
info = logging.info


__version__ = "0.5.3"
HAYSTACK_VERSION=__version__

def check_file(filename):
try:
with open(filename): pass
Expand Down
24 changes: 20 additions & 4 deletions haystack/run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import subprocess as sb

from haystack_common import check_file
from haystack_common import check_file, HAYSTACK_VERSION

import logging
logging.basicConfig(level=logging.INFO,
Expand All @@ -25,7 +25,6 @@
#from memory_profiler import profile
#f = open('pipeline_memory.txt', 'w+')

HAYSTACK_VERSION = "0.5.2"

def get_args_pipeline():
# mandatory
Expand Down Expand Up @@ -89,6 +88,14 @@ def get_args_pipeline():
default='_|chrX|chrY')
parser.add_argument('--read_ext', type=int, help='Read extension in bps (default: 200)', default=200)
parser.add_argument('--temp_directory', help='Directory to store temporary files (default: /tmp)', default='/tmp')
parser.add_argument('--rho_cutoff',
type=float,
default=0.3,
help='The cutoff absolute correlation value (0.0 to 1) for which activity plots are generated (default: 0.3)')
parser.add_argument('--tf_value_cuttoff',
type=float,
default=0.0,
help='The cutoff z-score tf_value for which activity plots are generated (default: 0.0) ')
parser.add_argument('--version', help='Print version and exit.', action='version',
version='Version %s' % HAYSTACK_VERSION)

Expand Down Expand Up @@ -289,16 +296,25 @@ def main(input_args=None):
'HAYSTACK_MOTIFS_on_%s' % sample_name)

if os.path.exists(motifs_output_folder):
cmd_to_run='haystack_tf_activity_plane %s %s %s --output_directory %s' %(motifs_output_folder,sample_names_tf_activity_filename,sample_name,tf_activity_directory)
cmd_to_run='haystack_tf_activity_plane %s %s %s --output_directory %s' %(motifs_output_folder,
sample_names_tf_activity_filename,
sample_name,
tf_activity_directory)

if motif_mapping_filename:
cmd_to_run+=' --motif_mapping_filename %s' % motif_mapping_filename

if plot_all:
cmd_to_run+=' --plot_all'

if rho_cutoff:
cmd_to_run += ' --rho_cutoff %f' % rho_cutoff

if tf_value_cuttoff:
cmd_to_run += ' --tf_value_cuttoff %f' % tf_value_cuttoff

print(cmd_to_run)
sb.call(cmd_to_run,shell=True)
sb.call(cmd_to_run, shell=True)


if __name__ == '__main__':
Expand Down

0 comments on commit 64ed75f

Please sign in to comment.