Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import argparse
import sys
import os
import re
import time
import multiprocessing
import logging
import subprocess
from Bio import SeqIO
import Bio.SeqIO.FastaIO as bio
import numpy as np
from collections import defaultdict
from scipy import stats
import pyBigWig
from statsmodels.sandbox.stats.multicomp import multipletests
def main():
read_file = "test.txt"
motifs_array = []
p_values_array = []
with open(read_file) as r_file:
for r_line in r_file:
r_line_array = re.split(r'\s', r_line.rstrip('\n'))
if float(r_line_array[1]) > 9.7e-90:
motifs_array.append(r_line_array[0])
p_values_array.append(float(r_line_array[1]))
r_file.close()
#apply bonferroni correction
p_adjusted = multipletests(p_values_array, method = 'bonferroni')[1]
dict_motifs_pvalues = {}
for i in range(len(motifs_array)):
motif = motifs_array[i]
dict_motifs_pvalues[motif] = dict_motifs_pvalues.get(motif, {})
dict_motifs_pvalues[motif] = {'fisher_p_value': p_values_array[i], 'adjusted_p_value': p_adjusted[i]}
#now sort the data after adjusted p_value
sorted_dict = sorted(dict_motifs_pvalues.items(), key = lambda x : (x[1]['adjusted_p_value']), reverse = False)
for i in range(35):
print(sorted_dict[i])
if __name__ == "__main__":
main()