From 19a711b1f74101b262fad66b194929bea2a0487c Mon Sep 17 00:00:00 2001 From: "Akshata N. Rudrapatna" <139808049+ANRudrapatna@users.noreply.github.com> Date: Tue, 14 Jul 2026 13:03:30 -0400 Subject: [PATCH] Update average.py Issue: the default behavior of maxATAC functions that generate averaged/normalized bigWig files is to generate bigWig files with 10 zoom levels (i.e., pre-computed summary statistics that enable quick zooming of bigWig files). This is extremely memory-intensive, but lower values of this parameter result in delayed loading of files in e.g., IGV. Solution: Added a new argument ("max_zooms") for the maxATAC average and normalize functions in parser.py, which defaults to 5. This will allow users to specify how many zoom levels they wish to retain in the final bigWig file (0-10). I successfully tested the argument for the above functions by specifying --max_zooms 5 in my function call. Also added code to convert values in the array used to generate the bigWig file from FP32 to FP16 values. This code was also successfully tested and resulted in additional memory savings of ~4%. --- maxatac/analyses/average.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maxatac/analyses/average.py b/maxatac/analyses/average.py index 4352a55..8b4d392 100644 --- a/maxatac/analyses/average.py +++ b/maxatac/analyses/average.py @@ -24,7 +24,7 @@ def run_averaging(args): 4) Loop through each entry in the chromosome sizes dictionary and calculate the average across all inputs 5) Write the bigwig file - :param args: bigwig_files, output_dir, name, chromosomes, chromosome_sizes + :param args: bigwig_files, output_dir, name, chromosomes, chromosome_sizes, max_zooms :return: A bigwig file """ @@ -60,7 +60,7 @@ def run_averaging(args): header = [(x, chromosome_sizes_dictionary[x]) for x in sorted(args.chromosomes)] # Write the header to the file - output_bw.addHeader(header) + output_bw.addHeader(header, maxZooms = args.max_zooms) # TODO Use parallel processing to speed up. Must write chromosomes in same order as header # Loop through the chromosomes and average the values across files @@ -86,7 +86,7 @@ def run_averaging(args): ends=chrom_length, span=1, step=1, - values=chrom_vals.tolist() + values=chrom_vals.astype(np.float16).tolist() ) # Measure time of averaging @@ -99,4 +99,4 @@ def run_averaging(args): logging.info("Total averaging time: %d:%d:%d.\n" % (hours, mins, secs)) - logging.info("Results saved to: " + output_bigwig_filename) \ No newline at end of file + logging.info("Results saved to: " + output_bigwig_filename)