check this: def blocksumpairwise(clr, fields, transforms, clrweightname, regions, span):…
- User
check this:
def _blocksum_pairwise(clr, fields, transforms, clr_weight_name, regions, span): """ calculates block summary for a collection of rectangular regions defined as pairwise combinations of all regions.
Return: a dictionary of block-wide sums for all "fields": keys are (i,j)-like, where i and j are 0-based indexes of "regions", and a combination of (i,j) defines rectangular block. Note: Input pixels are assumed to be "symmetric-upper", and "regions" to be sorted according to the order of chromosomes in "clr", thus i < j. """ lo, hi = span bins = clr.bins()[:] pixels = clr.pixels()[lo:hi] pixels = cooler.annotate(pixels, bins, replace=False) pixels["r1"] = assign_supports(pixels, regions, suffix="1") pixels["r2"] = assign_supports(pixels, regions, suffix="2") # pre-filter asymetric pixels only that have notnull weights if clr_weight_name is None: pixels = pixels.dropna(subset=["r1", "r2"]) else: pixels = pixels.dropna( subset=["r1", "r2", clr_weight_name + "1", clr_weight_name + "2"] ) pixels = pixels[pixels["r1"] != pixels["r2"]] # apply transforms, e.g. balancing etc for field, t in transforms.items(): pixels[field] = t(pixels) # pairwise-combinations of regions define asymetric pixels-blocks pixel_groups = pixels.groupby(["r1", "r2"]) return { (int(i), int(j)): group[fields].sum(skipna=False) for (i, j), group in pixel_groups }allow alternate reductions for aggregation across diagonals #507 for example, standard deviation (or variance) instead of sum/mean.
how would you add that to the current function
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.