-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests + move segmentation src + add CI
- Loading branch information
1 parent
1030d80
commit 7e0ad3e
Showing
9 changed files
with
150 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Hest tests | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop"] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
- name: Install python dependencies | ||
run: | | ||
python -m pip install -e . | ||
- name: Install apt dependencies | ||
run: | | ||
apt install libvips libvips-dev openslide-tools | ||
- name: Run reader tests | ||
run: | | ||
python reader_tests.py | ||
- name: Run hestdata tests | ||
run: | | ||
python hestdata_tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import os | ||
import unittest | ||
from os.path import join as _j | ||
|
||
import scanpy as sc | ||
|
||
from hest.readers import VisiumReader | ||
from hest.utils import get_path_relative | ||
|
||
|
||
class TestHESTData(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(self): | ||
self.cur_dir = get_path_relative(__file__, '') | ||
cur_dir = self.cur_dir | ||
self.output_dir = _j(cur_dir, 'output_tests', 'reader_tests') | ||
os.makedirs(self.output_dir, exist_ok=True) | ||
|
||
|
||
def test_visium_reader_img_matrix_spatial(self): | ||
cur_dir = self.cur_dir | ||
fullres_img_path = _j(cur_dir, './assets/WSA_LngSP9258463.jpg') | ||
bc_matrix_path = _j(cur_dir, './assets/filtered_feature_bc_matrix.h5') | ||
spatial_coord_path = _j(cur_dir, './assets/spatial') | ||
|
||
|
||
st = VisiumReader().read( | ||
fullres_img_path, # path to a full res image | ||
bc_matrix_path, # path to filtered_feature_bc_matrix.h5 | ||
spatial_coord_path=spatial_coord_path # path to a space ranger spatial/ folder containing either a tissue_positions.csv or tissue_position_list.csv | ||
) | ||
|
||
st.save(_j(self.output_dir, 'img+filtered_matrix+spatial'), pyramidal=True) | ||
st.save_spatial_plot(_j(self.output_dir, 'img+filtered_matrix+spatial'), self.output_dir) | ||
|
||
|
||
st.dump_patches( | ||
self.output_dir, | ||
'demo', | ||
target_patch_size=224, | ||
target_pixel_size=0.5 | ||
) | ||
|
||
|
||
def test_visium_reader_img_matrix(self): | ||
cur_dir = self.cur_dir | ||
fullres_img_path = _j(cur_dir, './assets/WSA_LngSP9258463.jpg') | ||
bc_matrix_path = _j(cur_dir, './assets/filtered_feature_bc_matrix.h5') | ||
|
||
# if both the alignment file and the spatial folder are missing, attempt autoalignment | ||
st = VisiumReader().read( | ||
fullres_img_path, # path to a full res image | ||
bc_matrix_path, # path to filtered_feature_bc_matrix.h5 | ||
) | ||
st.save(_j(self.output_dir, 'img+filtered_matrix'), pyramidal=True) | ||
st.save_spatial_plot(_j(self.output_dir, 'img+filtered_matrix'), self.output_dir) | ||
|
||
st.dump_patches( | ||
self.output_dir, | ||
'demo', | ||
target_patch_size=224, | ||
target_pixel_size=0.5 | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file was deleted.
Oops, something went wrong.