Data I/O Module
Data I/O functions for qi2lab 3D MERFISH.
This module provides utilities for reading and writing data in various formats used by qi2lab 3D MERFISH datasets.
History:
- 2024/12: Refactored repo structure.
- 2024/12: Updated docstrings.
- 2024/07: Removed native NDTiff reading package; integrated tifffile/zarr. Reduced dask dependencies.
Functions:
Name | Description |
---|---|
create_mtx | Create a sparse matrix in MTX format from Baysor output. |
read_config_file | Read config data from csv file. |
read_fluidics_program | Read fluidics program from CSV file as pandas dataframe. |
read_metadatafile | Read metadata from csv file. |
return_data_zarr | Return NDTIFF data as a numpy array via tiffile. |
time_stamp | Generate timestamp string. |
write_metadata | Write dictionary as CSV file. |
write_sparse_mtx | Write sparse matrix in MTX format. |
write_tsv | Write data to TSV file. |
create_mtx(spots_path, output_dir_path, confidence_cutoff=0.7)
Create a sparse matrix in MTX format from Baysor output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spots_path | Union[Path, str] | Path to spots file | required |
output_dir_path | Union[Path, str] | Path to output directory | required |
confidence_cutoff | float | Confidence cutoff for transcript assignment | 0.7 |
Source code in src/merfish3danalysis/utils/dataio.py
read_config_file(config_path)
Read config data from csv file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path | Union[Path, str] | Location of configuration file | required |
Returns:
Name | Type | Description |
---|---|---|
dict_from_csv | dict | instrument configuration metadata |
Source code in src/merfish3danalysis/utils/dataio.py
read_fluidics_program(program_path)
Read fluidics program from CSV file as pandas dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
program_path | Union[Path, str] | location of fluidics program | required |
Returns:
Name | Type | Description |
---|---|---|
df_fluidics | Dataframe | dataframe containing fluidics program |
Source code in src/merfish3danalysis/utils/dataio.py
read_metadatafile(fname)
Read metadata from csv file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fname | Union[str, Path] | filename | required |
Returns:
Name | Type | Description |
---|---|---|
metadata | Dict | metadata dictionary |
Source code in src/merfish3danalysis/utils/dataio.py
return_data_zarr(dataset_path, ch_idx, ch_idx_offset=0)
Return NDTIFF data as a numpy array via tiffile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_path | Union[Path, str] | pycromanager dataset object | required |
ch_idx | int | channel index in ZarrTiffStore file | required |
ch_idx_offset | Optional[int] | channel index offset for unused phase channels | 0 |
Returns:
Name | Type | Description |
---|---|---|
data | ArrayLike | data stack |
Source code in src/merfish3danalysis/utils/dataio.py
time_stamp()
Generate timestamp string.
Returns:
Name | Type | Description |
---|---|---|
timestamp | str | timestamp formatted as string |
write_metadata(data_dict, save_path)
Write dictionary as CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict | dict | metadata dictionary | required |
save_path | Union[str, Path] | path for file | required |
Source code in src/merfish3danalysis/utils/dataio.py
write_sparse_mtx(output_dir_path, matrix, cells, features)
Write sparse matrix in MTX format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_dir_path | Union[Path, str] | Path to output directory | required |
matrix | ArrayLike | Sparse matrix | required |
cells | Sequence[str] | Cell names | required |
features | Sequence[str] | Feature names | required |
Source code in src/merfish3danalysis/utils/dataio.py
write_tsv(filename, data)
Write data to TSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename | Union[str, Path] | Filename | required |
data | Sequence[Union[str, Sequence[str]]] | Data to write | required |