evaluate

crystal.evaluate contains functions to evaluate methods for modeling clusters.

crystal.evaluate.evaluate(bed_iter, regions, sizes=None, label='', ax=None, **plot_kwargs)[source]

Evaluate the accuracy of a method (model_fn) by comparing how many fall into a set of “truth” regions vs. outside.

Parameters:

bed_iter : iterable

iterable with each element of (chrom, start, end, p-value, n_sites) can be regions or features.

regions : file

BED file of regions.

sizes : tuple(int,)

which size regions to test. default (None) is all sizes.

label : str

label for plot legend

ax : axis

crystal.evaluate.plot_roc(ax, r, plot_kwargs={})[source]

Plot ROC for a given result.

Parameters:

ax: matplotlib axis

r: dict

return value from evaluate_method()

crystal.evaluate.plot_times(ax, results, labels, colors=None)[source]

Plot the times taken for each result in results from evalute_method()

Parameters:

ax: matplotlib axis

results: list of list of dict

list of return values from model_clusters()

colors: list

list of colors for matplotlib

crystal.evaluate.write_modeled_regions(modeled_clusters, p_cutoff, out_fh)[source]

Write a region bed file suitable for use in evaluate_modeled_regions().

Parameters:

modeled_clusters : list

output from model_clusters()

p_cutoff : float

values < this are set as true

out_fh : filehandle

where to write the data

crystal.evaluate.write_region_bed(feature_iter, true_regions, out_fh)[source]

Write a region bed file suitable for use in evaluate_modeled_regions(). given true regions (likely from an external program, otherwise use write_modeled_regions()).

Parameters:

feature_iter : iterable of Features

true_regions : file

BED file containing true regions

out_fh : filehandle

where to write the data