Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make this package a package #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
21 changes: 21 additions & 0 deletions .github/workflows/python-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build
on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install build dependencies
run: pip install --upgrade build
- name: Build package
run: python3 -m build
# TODO: add step to publish to pypi
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[![Build Python Package](https://github.com/lysogeny/ResolveTools/actions/workflows/python-build.yaml/badge.svg)](https://github.com/lysogeny/ResolveTools/actions/workflows/python-build.yaml)

# resolve-tools
Analyzing Resolve Data.
42 changes: 42 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "resolve_tools"
dependencies = [
# File formats
"readlif>=0.6.0",
"tifffile>=2022.5.4",
# Image processing
"scikit-image>=0.19.2",
"opencv-python>=4.7.0",
"mclahe@git+https://github.com/VincentStimper/mclahe",
# Missing dependency from mclahe
"tensorflow>=2.8.2",
# Various data analysis tools
"glmpca>=0.1.0",
"scikit-misc>=0.1.4",
"pandas>=1.4.2",
"numpy>=1.22.1",
"scipy>=1.8.1",
"openpyxl>=3.0.10",
"numba>=0.56.4",
"loompy>=3.0.7",
"scanpy>=1.9.1",
]
version = "0.0.1"
authors = [
{ name="Valentin Wüst", email="[email protected]" },
]
description = "Analyse Resolve Molecular Cartography data"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]

[project.urls]
"Homepage" = "https://github.com/anders-biostat/ResolveTools"
"Bug Tracker" = "https://github.com/anders-biostat/ResolveTools/issues"
15 changes: 0 additions & 15 deletions requirements.txt

This file was deleted.

6 changes: 3 additions & 3 deletions scripts/baysor/01.1_transcripts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
sys.path.insert(0,'/data/')

from ResolveTools.baysor.utils import counts_resolve_to_baysor
from ResolveTools.utils.utils import printwtime
from resolve_tools.baysor.utils import counts_resolve_to_baysor
from resolve_tools.utils.utils import printwtime
import re
import os

Expand All @@ -14,4 +14,4 @@

counts_resolve_to_baysor("/data/resolve/04_registration3D/"+filename,
"/data/baysor/02_transcripts_wmesmer/"+filename.replace(".txt","_baysor_wmesmer.txt"),
segmaskpath="/data/confocal/02_mesmer_nuclei/Confocal_"+roikey+"_DAPI_mesmer_nuclei_post.npz")
segmaskpath="/data/confocal/02_mesmer_nuclei/Confocal_"+roikey+"_DAPI_mesmer_nuclei_post.npz")
2 changes: 1 addition & 1 deletion scripts/baysor/03.1_combine.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys
sys.path.insert(0,'/data/')
from ResolveTools.baysor.utils import combine_baysor_transcripts
from resolve_tools.baysor.utils import combine_baysor_transcripts



Expand Down
6 changes: 3 additions & 3 deletions scripts/baysor/scripts/final_01_process_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages

from ResolveTools.baysor.utils import split_baysor_ROIs, assign_counts_from_Baysor
from ResolveTools.baysor.visualization import plot_celltypedist
from ResolveTools.utils.utils import printwtime
from resolve_tools.baysor.utils import split_baysor_ROIs, assign_counts_from_Baysor
from resolve_tools.baysor.visualization import plot_celltypedist
from resolve_tools.utils.utils import printwtime

## Split Results

Expand Down
6 changes: 3 additions & 3 deletions scripts/baysor/scripts/final_02_process_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages

from ResolveTools.baysor.roi import apply_combine_baysor_output
from ResolveTools.baysor.visualization import plot_celltypedist
from ResolveTools.utils.utils import printwtime
from resolve_tools.baysor.roi import apply_combine_baysor_output
from resolve_tools.baysor.visualization import plot_celltypedist
from resolve_tools.utils.utils import printwtime

result = sys.argv[1] # results_N21_wmesmer_combined

Expand Down
4 changes: 2 additions & 2 deletions scripts/baysor/scripts/final_03_add_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
sys.path.insert(0,'/data/')
import os

from ResolveTools.utils.utils import printwtime
from ResolveTools.segmentation.brainregions import add_region_toadata
from resolve_tools.utils.utils import printwtime
from resolve_tools.segmentation.brainregions import add_region_toadata

result = sys.argv[1] # results_N21_wmesmer_combined

Expand Down
4 changes: 2 additions & 2 deletions scripts/baysor/scripts/final_04_add_stain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
sys.path.insert(0,'/data/')
import os

from ResolveTools.utils.utils import printwtime
from ResolveTools.baysor.utils import add_stain_to_ROI
from resolve_tools.utils.utils import printwtime
from resolve_tools.baysor.utils import add_stain_to_ROI

result = sys.argv[1] # results_N21_wmesmer_combined

Expand Down
4 changes: 2 additions & 2 deletions scripts/baysor/scripts/final_05_combine_final.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
sys.path.insert(0,'/data/')
import os

from ResolveTools.utils.utils import printwtime
from ResolveTools.baysor.utils import combine_adatas
from resolve_tools.utils.utils import printwtime
from resolve_tools.baysor.utils import combine_adatas

result = sys.argv[1] # results_N21_wmesmer_combined

Expand Down
8 changes: 4 additions & 4 deletions scripts/baysor/scripts/final_06_add_QC.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import numpy as np
import pandas as pd
import seaborn as sns
from ResolveTools.utils.utils import printwtime
from ResolveTools.analysis.post import read_add_combined
from ResolveTools.segmentation.counts import read_loom
from ResolveTools.analysis.pseudotime import get_human_glmpca_data, get_meanpseudotime, plot_PT_shares
from resolve_tools.utils.utils import printwtime
from resolve_tools.analysis.post import read_add_combined
from resolve_tools.segmentation.counts import read_loom
from resolve_tools.analysis.pseudotime import get_human_glmpca_data, get_meanpseudotime, plot_PT_shares

result = sys.argv[1] # results_N21_wmesmer_combined
resultfolder = "/data/baysor/04_baysor/"+result
Expand Down
4 changes: 2 additions & 2 deletions scripts/baysor/scripts/final_07_assignment_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import os
import matplotlib.pyplot as plt

from ResolveTools.baysor.visualization import plot_final_assignment_post
from ResolveTools.utils.utils import printwtime
from resolve_tools.baysor.visualization import plot_final_assignment_post
from resolve_tools.utils.utils import printwtime

## Split Results

Expand Down
6 changes: 3 additions & 3 deletions scripts/confocal/01.1_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import os
import sys
sys.path.insert(0,'/data/')
from ResolveTools.image.utils import save_tiff
from ResolveTools.image.lif import LifFile, read_lif_image
from resolve_tools.image.utils import save_tiff
from resolve_tools.image.lif import LifFile, read_lif_image

from tqdm import tqdm

Expand Down Expand Up @@ -41,4 +41,4 @@ def make_small_max(name, factor=8):

for name in tqdm(run1+run2):
print(name)
make_small_max(name)
make_small_max(name)
10 changes: 5 additions & 5 deletions scripts/confocal/01.2.1_clip_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import sys
sys.path.insert(0,'/data/')

from ResolveTools.image.utils import save_tiff, claher, read_single_modality_confocal
from ResolveTools.image.lif import LifFile, read_lif_image
from ResolveTools.registration.registerSIFT import find_homography, warp_image, transform_coordinate, scale_homography,\
from resolve_tools.image.utils import save_tiff, claher, read_single_modality_confocal
from resolve_tools.image.lif import LifFile, read_lif_image
from resolve_tools.registration.registerSIFT import find_homography, warp_image, transform_coordinate, scale_homography,\
get_transformed_corners
from ResolveTools.segmentation.brainregions import processes_regionsegmentation_initial
from ResolveTools.utils.utils import printwtime
from resolve_tools.segmentation.brainregions import processes_regionsegmentation_initial
from resolve_tools.utils.utils import printwtime

def find_corners():
printwtime("Loading Images")
Expand Down
6 changes: 3 additions & 3 deletions scripts/confocal/01.4_make_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import sys
sys.path.insert(0,'/data/')
from ResolveTools.image.utils import save_tiff, save_tiff_from_float, claher, read_single_modality_confocal
from ResolveTools.utils.utils import printwtime
from resolve_tools.image.utils import save_tiff, save_tiff_from_float, claher, read_single_modality_confocal
from resolve_tools.utils.utils import printwtime

path = "/data/confocal/01_image/"
images = os.listdir(path)
Expand All @@ -17,4 +17,4 @@
img = read_single_modality_confocal(path+image, norm=False)
save_tiff(path+image.replace(".tif","_max.tif"), img.max(axis=0)[None])
save_tiff_from_float(path+image.replace(".tif","_max_claher.tif"), claher(img.max(axis=0))[None])
del img
del img
4 changes: 2 additions & 2 deletions scripts/confocal/02.1_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import sys
sys.path.insert(0,'/data/')

from ResolveTools.segmentation.postprocess import postprocess_raw_mesmer_masks
from ResolveTools.utils.utils import printwtime
from resolve_tools.segmentation.postprocess import postprocess_raw_mesmer_masks
from resolve_tools.utils.utils import printwtime

printwtime("Loading Mask")
file = np.load("/data/confocal/"+sys.argv[1])
Expand Down
6 changes: 3 additions & 3 deletions scripts/confocal/02.4_postprocess_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import sys
sys.path.insert(0,'/data/')

from ResolveTools.segmentation.utils import segmentation_to_meta_df, save_sampled_boundary
from resolve_tools.segmentation.utils import segmentation_to_meta_df, save_sampled_boundary
from skimage.segmentation import find_boundaries
from ResolveTools.utils.utils import printwtime
from resolve_tools.utils.utils import printwtime
import re

filename = sys.argv[1]
Expand All @@ -25,4 +25,4 @@
df.to_csv(filename.replace("post.npz", "post_meta.csv"))

inner = find_boundaries(mask, mode="inner")
save_sampled_boundary(mask, inner, filename.replace("post.npz", "post_boundary.npz"), N=60, seed=42)
save_sampled_boundary(mask, inner, filename.replace("post.npz", "post_boundary.npz"), N=60, seed=42)
6 changes: 3 additions & 3 deletions scripts/confocal/03.1_annotation_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import sys
sys.path.insert(0,'/data/')
from ResolveTools.image.utils import resize_shrink, read_single_modality_confocal
from ResolveTools.utils.utils import printwtime
from resolve_tools.image.utils import resize_shrink, read_single_modality_confocal
from resolve_tools.utils.utils import printwtime

factor = 2
path = "/data/confocal/01_image/"
Expand All @@ -29,4 +29,4 @@
final[..., 2] = dapimax
final[..., 1] = wgamax

cv2.imwrite(pathout+'Confocal_'+roi+'_annotation_tempalte.jpg', (final*255).astype("H"), [cv2.IMWRITE_JPEG_QUALITY, 100])
cv2.imwrite(pathout+'Confocal_'+roi+'_annotation_tempalte.jpg', (final*255).astype("H"), [cv2.IMWRITE_JPEG_QUALITY, 100])
6 changes: 3 additions & 3 deletions scripts/confocal/03.2_annotation_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import sys
sys.path.insert(0,'/data/')
from ResolveTools.segmentation.brainregions import processes_regionsegmentation_initial
from ResolveTools.utils.utils import printwtime
from resolve_tools.segmentation.brainregions import processes_regionsegmentation_initial
from resolve_tools.utils.utils import printwtime

path = "/data/confocal/03_annotation/"
process = list(filter(lambda x: "_annotation.png" in x, os.listdir("/data/confocal/03_annotation")))
Expand All @@ -17,4 +17,4 @@
referenceimg = "/data/confocal/01_image/Confocal_"+roi+"_DAPI.tif"
annotpath = path+"Confocal_"+roi+"_annotated_regions.npz"

processes_regionsegmentation_initial(imagepath, referenceimg, annotpath)
processes_regionsegmentation_initial(imagepath, referenceimg, annotpath)
6 changes: 3 additions & 3 deletions scripts/confocal/03.3_annotation_allmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import sys
sys.path.insert(0,'/data/')
from ResolveTools.segmentation.brainregions import regionkey, regioncolors
from ResolveTools.utils.utils import printwtime
from resolve_tools.segmentation.brainregions import regionkey, regioncolors
from resolve_tools.utils.utils import printwtime

path = "/data/confocal/03_annotation/"
files = list(filter(lambda x: "_annotated_regions.npz" in x, os.listdir("/data/confocal/03_annotation")))
Expand All @@ -23,4 +23,4 @@

df = df.loc[[i for i in df.index if i in regionkey.keys()]].copy()
df.index = [regionkey[i] for i in df.index]
df.to_csv(path+"Confocal_annotation_overview.csv")
df.to_csv(path+"Confocal_annotation_overview.csv")
8 changes: 4 additions & 4 deletions scripts/resolve/03.1_register2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import sys
sys.path.insert(0,'/data/')

from ResolveTools.image.utils import save_tiff, claher, resize_shrink
from ResolveTools.registration.registerSIFT import find_homography, find_homographies, warp_image,\
from resolve_tools.image.utils import save_tiff, claher, resize_shrink
from resolve_tools.registration.registerSIFT import find_homography, find_homographies, warp_image,\
transform_coordinate, scale_homography, get_transformed_corners,\
homography_shift_target
from ResolveTools.registration.registerTiles import tile_2Dimage
from ResolveTools.utils.utils import printwtime
from resolve_tools.registration.registerTiles import tile_2Dimage
from resolve_tools.utils.utils import printwtime

name = sys.argv[1]

Expand Down
6 changes: 3 additions & 3 deletions scripts/resolve/04.1_register3D.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
sys.path.insert(0,'/data/')
from ResolveTools.registration.register3D import register_3d_counts
from ResolveTools.utils.utils import printwtime
from resolve_tools.registration.register3D import register_3d_counts
from resolve_tools.utils.utils import printwtime

import re
import os
Expand All @@ -22,4 +22,4 @@
"/data/resolve/04_registration3D/T6GBM_"+name+"_transcripts_registered3D.txt",
segmentationfile="/data/confocal/02_mesmer_nuclei/Confocal_" + name + "_DAPI_mesmer_nuclei_post.npz", segmentationkey="mask_post",
verbose=True, binsize=1000, shiftstep=0.4,
plotfile="/data/resolve/02_QC/T6GBM_" + name + "_zShift.jpeg", plottitle=name)
plotfile="/data/resolve/02_QC/T6GBM_" + name + "_zShift.jpeg", plottitle=name)
6 changes: 3 additions & 3 deletions scripts/resolve/05.1_counts_naive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import re
import sys
sys.path.insert(0,'/data/')
from ResolveTools.segmentation.counts import assign_counts_from_segmentation
from ResolveTools.utils.utils import printwtime
from resolve_tools.segmentation.counts import assign_counts_from_segmentation
from resolve_tools.utils.utils import printwtime

path = "/data/resolve/04_registration3D/"

Expand All @@ -18,4 +18,4 @@
"/data/confocal/02_mesmer_nuclei/Confocal_" + name + "_DAPI_mesmer_nuclei_post_meta.csv",
"/data/resolve/05_counts_naive/T6GBM_" + name + "_counts_naive.loom",
name,
True)
True)
Empty file added src/resolve_tools/__init__.py
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.