agora.io.writer.Writer¶
- class agora.io.writer.Writer(filename, compression=None)¶
Bases:
BridgeH5
Class in charge of transforming data into compatible formats
Decoupling interface from implementation!
- Parameters
- filename: str Name of file to write into
- flag: str, default=None
Flag to pass to the default file reader. If None the file remains closed.
- compression: str, default=None
Compression method passed on to h5py writing functions (only used for
- dataframes and other array-like data.)
- Attributes
- cell_tree
Methods
get_info_tree
([fields])Returns traps, time points and labels for this position in form of a tree in the hierarchy determined by the argument fields.
write
(path[, data, meta, overwrite])- Parameters
close
find_ids
get_consecutives
get_existing_ids
get_npairs
get_npairs_over_time
write_arraylike
write_dset
write_index
write_meta
write_pd
- __init__(filename, compression=None)¶
Methods
__init__
(filename[, compression])close
()find_ids
(existing, new)get_consecutives
(tree, nstepsback)get_existing_ids
(f, paths)get_info_tree
([fields])Returns traps, time points and labels for this position in form of a tree in the hierarchy determined by the argument fields.
get_npairs
([nstepsback, tree])get_npairs_over_time
([nstepsback])write
(path[, data, meta, overwrite])- Parameters
write_arraylike
(f, path, data, **kwargs)write_dset
(f, path, data)write_index
(f, path, pd_index, **kwargs)write_meta
(f, path, attr, data)write_pd
(f, path, df, **kwargs)Attributes
cell_tree
- get_info_tree(fields: Union[tuple, list] = ('trap', 'timepoint', 'cell_label'))¶
Returns traps, time points and labels for this position in form of a tree in the hierarchy determined by the argument fields. Note that it is compressed to non-empty elements and timepoints.
Default hierarchy is: - trap
time point
cell label
This function currently produces trees of depth 3, but it can easily be extended for deeper trees if needed (e.g. considering groups, chambers and/or positions).
input :fields: Fields to fetch from ‘cell_info’ inside the hdf5 storage
returns :tree: Nested dictionary where keys (or branches) are the upper levels
and the leaves are the last element of :fields:.
- write(path: str, data: Optional[Iterable] = None, meta: Dict = {}, overwrite: Optional[str] = None)¶
- Parameters
- pathstr
Path inside h5 file to write into.
- dataIterable, default = None
- metaDict, default = {}