pypi figwig 0.3.2
figwig 0.3.2

56 minutes ago

figwig 0.3.2 lets a figwig file be opened as a reader of some of its tracks, and lets a read take windows on chromosomes the file does not have. It is for code that is handed a reader and reads every track of it, such as data loaders and tangermeme's extract_loci, and for loci from builds with extra contigs.

Commits

  • RELEASE bump version to 0.3.2 with changelog entries (#67)
  • ADD FigWigReader(path, tracks=...) and read(absent='zero') (#66)
  • TEST the path from fragments files to loader reads by every route, channel order over 300 bigWigs, bw2fw over several groups in pieces, bigWig reads after a fork, and the read planner's thresholds (#65)

Reading

New: FigWigReader(path, tracks=...). A reader opened this way holds some of a file's tracks, chosen by name, by index, or by a dict of attributes that select matches. It acts as if the file held only those tracks:

  • tracks, stats and select list them.
  • The tracks argument of read, sums, tile_sums and read_entries indexes them.
  • A read without tracks reads them all, in the order given.

Before, code that reads every track of the reader it is handed, such as a data loader or a package that takes a list of signal files, could only be given the whole file, or a reader plus a list of tracks carried beside it. The reader pickles with its tracks. Reads of a reader of the whole file are unchanged, and timed the same as 0.3.1 within noise.

New: read(..., absent="zero"). FigWigReader.read and read_figwig can now read a window on a chromosome the file does not have as 0 throughout, or as no entries with sparse=True. By default such a window still raises a ValueError. Before, loci from a peak file with contigs of another build had to be filtered against chrom_sizes first. A caller that wanted a bigWig's behaviour, zeros for those windows, had to read the rest and put the rows back in place itself.

Tests

  • tests/test_pipeline.py follows a fragments file of four cells to the arrays a data loader reads, by every route: bam2bw, bw2fw, bam2fw per file and per barcode, and fw2bw, in cut-site and coverage modes. It checks each route against counts made with numpy. Before, each command had been tested only against the one before it.
  • A read of 300 bigWigs checks that channel i holds file i.
  • bw2fw of 19 bigWigs, in groups and written in pieces, matches a one-piece write byte for byte.
  • A bigWig read in a forked process after a threaded read is tested, and fails after a minute rather than hanging.
  • figwig reads are checked against numpy at both extremes of six read-planner thresholds.

What is new

A figwig file of many tracks can now be handed, a few tracks at a time, to code that takes a reader and reads all of it. A read can now treat windows on unknown chromosomes as zeros. Back-compatible: existing calls behave as in 0.3.1, and the two additions are opt-in.

Don't miss a new figwig release

NewReleases is sending notifications on new releases.