-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gpratt
committed
Jan 27, 2016
1 parent
33c65c0
commit 411c86d
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
__author__ = 'gpratt' | ||
|
||
import pandas as pd | ||
import cPickle as pickle | ||
import os | ||
import numpy as np | ||
import argparse | ||
|
||
|
||
def output_region_density(fn): | ||
with open(fn) as f_handle: | ||
result = pickle.load(f_handle) | ||
name = os.path.basename(fn).split(".")[0] | ||
regions_dict = {} | ||
for region in result['distributions']: | ||
region_type_dict = {} | ||
for region_type in ['total', 'individual']: | ||
count, bins = np.histogram(result['distributions'][region][region_type], bins=100, normed=True) | ||
region_type_dict[region_type] = {key: value for key, value in zip(np.arange(0,1, .01), count)} | ||
regions_dict[region] = pd.DataFrame(region_type_dict).T | ||
pd.concat(regions_dict).to_csv(name + ".distributions.csv") | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description="Takes a pickle file from the output of clip_analysis and outputs the region distributions as csv in histogram form") | ||
parser.add_argument("-i", "--input", help="pickle file from clip analysis to parse") | ||
args = parser.parse_args() | ||
|
||
output_region_density(args.input) |