Esempio n. 1
0
def pVal4mari(tabPath,tTx,tTxDN,tTxUP):
    """
    tTx=   total transcripts,
    tTxUP= total Tx sig up Reg
    tTxDN= total Tx sig dwn reg,

    Takes named tuple data table in format:
    type,total,down,up,tDE

    Returns list of pValues in format:
    [(type1,pVal_dwn1,pVal_up1,pVal_tde1),
    ...,
    (typeN,pVal_dwnN,pVal_upN,pVal_tdeN)]
    """
    from scipherSrc.defs.files_io import tableFile2namedTuple
    from scipy.stats import hypergeom
    def cHgPvl(x,M,n,N):
        """
        x=randVar
        M=popSize
        n=totalSuccesses
        N=samplSize
        """
        return 1-hypergeom.cdf(x,M,n,N)+hypergeom.pmf(x,M,n,N)

    namdTup = tableFile2namedTuple(tabPath,sep=',')
    rData = []
    for i in range(len(namdTup)):
        t = namdTup[i]
        pDwn = cHgPvl(int(t.down),tTx,int(t.total),tTxDN)
        pUp  = cHgPvl(int(t.up),tTx,int(t.total),tTxUP)
        pDE  = cHgPvl(int(t.tDE),tTx,int(t.total),(tTxDN+tTxUP))
        rData.append((t.type,pDwn,pUp,pDE))
    return rData
Esempio n. 2
0
                      help="""REQUIRED - Exact Title of Column holding the name of the chrom on which each block resides. Exp: name -or- Chromosome/plasmid (default=%default)""")
    parser.add_option('--strand',dest="strand",type="str", default=None, 
                      help="""Exact Title of Column holding the strand indicator. Exp: strand. If None: all will be assigned '+' strand. (default=%default)""")
    parser.add_option('--thkStrt',dest="thkStrt",type="str", default=None, 
                      help="""Exact Title of Column holding the position of the thickStart. Exp: start_of_coding (default=%default)""")
    parser.add_option('--thkEnd',dest="thkEnd",type="str", default=None, 
                      help="""Exact Title of Column holding the position of the thickEnd. Exp: end_of_coding (default=%default)""")
    parser.add_option('--rgb',dest="rgb",type="str", default="0,0,0", 
                      help="""Space-less string to assign the color for this track. Exp: 0,0,0=black; 255,0,0=red; 0,255,0=green; 0,0,255=blue (default=%default)""")
    parser.add_option('--cigars',dest="cigars",type="str", default=False, 
                      help="""Exact Title of Column holding the cigar strings. Exp: cigar_string (default=%default)""")
    cigTypes = ['ensembl','exonerate']
    parser.add_option('--cigar-type',dest="cigar_type",type="str", default=False, 
                      help="""Type of cigar string.  REQUIRED when using '--cigars'.  Options: %s (default=%default)""" % (cigTypes))

    
    (opts, args) = parser.parse_args()
    
    if len(args) != 1:
        parser.print_help()
        exit()
    
    
    features   = tableFile2namedTuple(args[0],sep=opts.sep)
    rowsByAlgn = groupFeatureAlignments(features,opts)
    
    print """track name=%s description="%s" useScore=0""" % (opts.track_name, opts.description)
    
    for alnmnt in rowsByAlgn:
        printBEDline(rowsByAlgn[alnmnt],opts)
    
Esempio n. 3
0
        dest="cigars",
        type="str",
        default=False,
        help=
        """Exact Title of Column holding the cigar strings. Exp: cigar_string (default=%default)"""
    )
    cigTypes = ['ensembl', 'exonerate']
    parser.add_option(
        '--cigar-type',
        dest="cigar_type",
        type="str",
        default=False,
        help=
        """Type of cigar string.  REQUIRED when using '--cigars'.  Options: %s (default=%default)"""
        % (cigTypes))

    (opts, args) = parser.parse_args()

    if len(args) != 1:
        parser.print_help()
        exit()

    features = tableFile2namedTuple(args[0], sep=opts.sep)
    rowsByAlgn = groupFeatureAlignments(features, opts)

    print """track name=%s description="%s" useScore=0""" % (opts.track_name,
                                                             opts.description)

    for alnmnt in rowsByAlgn:
        printBEDline(rowsByAlgn[alnmnt], opts)