Blood Analyzer Software (B.A.S.) is a data visualization and explorative tool, it allows to analyze blood samples from an hematological analyzer and reformat the data into a tabular format.
Blood Analyzer Software is a Python-based program. The Python language has an Installation page for Windows & Mac users.
Alternatively, you can install Python in your Linux-based machine with the following steps:
#Step 1: Open up your terminal by pressing Ctrl + Alt + T.
#Step 2: Update & Upgrade your local system's repository list by entering the following command
$ sudo apt update & apt upgrade
#Step 3: Download the latest version of Python
$ sudo apt install python3Make sure you have the following packages installed in your Python environment:
- PyQt5 >= 5.9.0 (https://pypi.org/project/PyQt5/) (https://anaconda.org/anaconda/pyqt)
- matplotlib >= 3.5.0 (https://pypi.org/project/matplotlib/)
- pandas >= 1.5.0 (https://pypi.org/project/pandas/)
- numpy >= 1.23.0 (https://pypi.org/project/numpy/)
- Pillow >= 9.2.0 (https://pypi.org/project/Pillow/)
- xml (https://docs.python.org/3/library/xml.etree.elementtree.html)
pip list
pip install uninstalled_package
conda list
conda install uninstalled_packageOpen Terminal or your IDE of preference within your 'projects' folder and take the following steps:
#Step 1: Get sources from GitHub
$ git clone https://github.com/jazg97/BloodAnalyzerSoftware.git
$ cd BloodAnalyzerSoftware
$ python3 feature_code.pyThe project has the following structure:
.
│
├── data
│ ├── 20211027165438.xml
│ ├── 20221031134832.xml
│ │
├── docs
├── code
│ ├── cleaning_csv.py
│ ├── generating_plots.py
│ ├── GUI.py
│ ├── parsing_multiple_files.py
│ ├── parsing_xml.py
│ ├── utils.py
│ │
├── figures
│ ├── multiple_ids_feature_ex1.png
│ ├── multiple_ids_feature_ex2.png
├── exemplaryFiles
│ ├── exemplary_csv.csv
│ ├── exemplary_csv_w_meta.csv
│ ├── exemplary_meta.xlsx
The Blood Analyzer Software (B.A.S.) is a data visualization and explorative tool, consequently most of its features are related to these tasks.
- Generate csv files from xml files: Choose a directory that contains all the XML of interest and obtain a csv file with all its data reformatted.
- Plot time-series by feature family, patients' ID and dates: Visualize time-series from ids of interest, see trends and compare subpopulations.
- Import metadata: Add new data into the csv file which could further help in the analysis of the study.
- Generate scatter plot with metadata fields
- Global plot: Obtain global statistics related to metadata of interest.
- Time-series: Visualize time-series from ids of interested located inside the metadata file.
There are two options to access the program. You can run the program 'GUI.py' from the command line or open the executable. These are the main sections and features accesible in the program.
1. Appropiate format for XML files
When exporting a file from the Hematology Analyzer you need to fill out some fields in the machine in order to assign correctly important information for its analysis.
Some fields, such as Tier-ID, Name, and Haltername will be used to differentiate between samples, and as such its recommended to fill them out following some guidelines.
- Tier-ID: This will be the patient's ID and it's recommended to assign an integer number and not a combination of characters with numbers if not necessary.
- Name: This will be the type of blood source, such as systemic blood (BLOOD), bone marrow (BM), spleen (SPLEEN), femur (FEMUR), etc. It's important to maintain a consistent system of naming blood sources for their analysis.
- Haltername: This will be the 'owner' or head of laboratory in charge of the study and this field will be used to avoid mixing samples.
When generating a CSV file, these fields will have its correspondent name.
| FIELD_SID_PATIENT_ID | FIELD_SID_ANIMAL_NAME | FIELD_SID_OWNER_LASTNAME | ANALYSIS_DATE | ... |
|---|---|---|---|---|
| 120 | BLOOD | OWNER #1 | dd-mm-YYYY | ... |
| 140 | FEMUR | ONWER #2 | dd-mm-YYYY | ... |
| ... | ... | ... | ... | ... |
1. Generate new `CSV` file without GUI
You can generate CSV files without launching B.A.S, follow these steps:
$ cd BloodAnalyzerSoftware
$ python3 ./code/generate_csv.py <input_data_directory> <output_directory>/<output_filename>.csv2. Generate new csv file in GUI
You can open the GUI over the command line by carrying out the steps described below:
$ cd BloodAnalyzerSoftware
$ python3 ./code/GUI.pyAltenatively, you can just run the .exe. Either way, here are the steps you need to follow to create a new CSV file inside the GUI.
1. Select and Filter Data
Once you have accessed a dataset, you can explore and visualize its data following these instructions.
1. Recommended file format
You need to format your metadata as shown below and save it as a CSV or XSLX file.
| animal_id | Genotype | Treatment | Date-of-interest | ... |
|---|---|---|---|---|
| ID #1 | Control+ | Treat #1 | dd-mm-YYYY | ... |
| ID #2 | Test- | Treat #2 | dd-mm-YYYY | ... |
| ... | ... | ... | ... | ... |
It is especially important to write the ID identically as it's in the original CSV file, as without this, it won't be associated correctly inside the program.
2. Upload metadata
You can load the metadata file into the dataset following accessing the Import Menu.
1. Select metadata
Similar to ID and Family selection, you can select metadata of interest and choose between plotting global or time-series results of your experiment.
1. Export data
You can export a subset of a CSV file by selecting and filtering the dataset, similar to the steps done when generating a time-series plot.
1. Modify canvas setings with Toolbar
Additionally, there is the option to modify most of the canvas settings with its Toolbar, which is located right above it. This toolbar have the following buttons:
1. Import new xml files to current analysis
If some file was skipped during the CSV file generation, there is an option to add an specific XML file if necessary. You just need to follow the following steps:
If you'd like to contribute to this project, please follow these steps:
- Fork the repository
- Create a new branch for your changes
- Make your changes and commit them with descriptive commit messages
- Push your changes to your fork
- Create a pull request from your fork to the main repository
Blood Analyzer Software is released under the MIT License - Jose Zapana & Eric Schmitt - 2023.