Example #1
0
def dataview_populate(json, index, params):
    """
    Populates a data view.
    Operates on a single data and populates the data in the json from it.
    """

    results = index.query(start=params.start, end=params.end, label=params.chrom)
    
    fitdata = []
    data = map(list, (results.idx,results.val))
    xscale = (params.start, params.end)
    
    for row in json:
        style = row['style']
        if style.startswith('FIT'):
            # fit the data
            fitdata = fitlib.gaussian_smoothing(data[0], data[1], sigma=params.sigma, epsilon=0.01 )
            fitdata = map(list, fitdata)
            row['data'] = fitdata
        elif  style.startswith('SEGMENT'):
            assert fitdata, 'smoothing must be applied first'
            peakdata = fitlib.fixed_width_predictor( x=fitdata[0], y=fitdata[1], params=params )
            row['data'] = peakdata
        else:
            row['data'] = data
        
        row['xscale'] = xscale
        row['w'] = params.image_width

    return json
 def predict(x, y):
     fx, fy = fitlib.gaussian_smoothing(x=x,
                                        y=y,
                                        sigma=options.sigma,
                                        epsilon=options.level)
     peaks = fitlib.detect_peaks(x=fx, y=fy)
     if options.mode != 'all':
         peaks = fitlib.select_peaks(peaks=peaks,
                                     exclusion=options.exclude,
                                     threshold=options.level)
     return peaks
Example #3
0
 def predict(x, y):
     fx, fy = fitlib.gaussian_smoothing(x=x, y=y, sigma=options.sigma, epsilon=options.level )
     peaks = fitlib.detect_peaks(x=fx, y=fy )
     if options.mode != 'all':
         peaks = fitlib.select_peaks(peaks=peaks, exclusion=options.exclude, threshold=options.level)
     return peaks
def fit(x, y, params):
    "Fits the x and y data"
    fx, fy = fitlib.gaussian_smoothing(x, y, sigma=params.sigma, epsilon=0.01 )
    return list(fx), list(fy)