SPACEc 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- SPACEc-0.0.2.dist-info/LICENSE.txt +21 -0
- SPACEc-0.0.2.dist-info/METADATA +135 -0
- SPACEc-0.0.2.dist-info/RECORD +21 -0
- SPACEc-0.0.2.dist-info/WHEEL +5 -0
- SPACEc-0.0.2.dist-info/top_level.txt +1 -0
- spacec/__init__.py +38 -0
- spacec/_shared/segmentation.py +194 -0
- spacec/_shared/segmentation_unused.py +80 -0
- spacec/helperfunctions/__init__.py +4 -0
- spacec/helperfunctions/_general.py +1076 -0
- spacec/helperfunctions/_qptiff_converter.py +44 -0
- spacec/plotting/__init__.py +40 -0
- spacec/plotting/_general.py +4665 -0
- spacec/plotting/_qptiff_converter.py +40 -0
- spacec/plotting/_segmentation.py +227 -0
- spacec/preprocessing/__init__.py +8 -0
- spacec/preprocessing/_general.py +431 -0
- spacec/tools/__init__.py +32 -0
- spacec/tools/_general.py +3561 -0
- spacec/tools/_qptiff_converter.py +144 -0
- spacec/tools/_segmentation.py +895 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import tifffile
|
|
3
|
+
from scipy import ndimage as ndi
|
|
4
|
+
from skimage.transform import resize
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def downscale_tissue(
|
|
8
|
+
file_path,
|
|
9
|
+
DNAslice=0,
|
|
10
|
+
downscale_factor=64,
|
|
11
|
+
sigma=5.0,
|
|
12
|
+
padding=50,
|
|
13
|
+
savefig=False,
|
|
14
|
+
showfig=True,
|
|
15
|
+
output_dir="./",
|
|
16
|
+
output_fname="",
|
|
17
|
+
figsize=(10, 5), # new parameter for figure size
|
|
18
|
+
):
|
|
19
|
+
print("Reading in the qptiff file, might take awhile!")
|
|
20
|
+
currim = tifffile.imread(file_path)
|
|
21
|
+
nucim = currim[DNAslice]
|
|
22
|
+
del currim
|
|
23
|
+
print(f"Loaded nuclear image of dimension (Y,X) = {nucim.shape}")
|
|
24
|
+
resized_im = resize(
|
|
25
|
+
nucim,
|
|
26
|
+
(nucim.shape[0] // downscale_factor, nucim.shape[1] // downscale_factor),
|
|
27
|
+
anti_aliasing=True,
|
|
28
|
+
)
|
|
29
|
+
resized_im = ndi.gaussian_filter(resized_im, sigma=sigma)
|
|
30
|
+
|
|
31
|
+
if showfig:
|
|
32
|
+
fig, axs = plt.subplots(1, 2, figsize=figsize) # use figsize parameter here
|
|
33
|
+
axs[0].imshow(nucim)
|
|
34
|
+
axs[0].set_title("Nuclear image")
|
|
35
|
+
axs[1].hist(resized_im)
|
|
36
|
+
axs[1].set_title("Marker expression level histogram")
|
|
37
|
+
if savefig:
|
|
38
|
+
fig.savefig(
|
|
39
|
+
output_dir + output_fname + "_raw_tissue_plot.pdf", bbox_inches="tight"
|
|
40
|
+
)
|
|
41
|
+
else:
|
|
42
|
+
plt.show()
|
|
43
|
+
print("returning scaled down image!")
|
|
44
|
+
return resized_im
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from ._general import (
|
|
2
|
+
BC_projection,
|
|
3
|
+
catplot,
|
|
4
|
+
cn_exp_heatmap,
|
|
5
|
+
cn_map,
|
|
6
|
+
coordinates_on_image,
|
|
7
|
+
count_patch_proximity_res,
|
|
8
|
+
create_pie_charts,
|
|
9
|
+
distance_graph,
|
|
10
|
+
dumbbell,
|
|
11
|
+
plot_top_n_distances,
|
|
12
|
+
ppa_res_donut,
|
|
13
|
+
stacked_bar_plot,
|
|
14
|
+
zcount_thres,
|
|
15
|
+
)
|
|
16
|
+
from ._qptiff_converter import tissue_lables
|
|
17
|
+
from ._segmentation import segmentation_ch, show_masks
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
# segmentation
|
|
21
|
+
"segmentation_ch",
|
|
22
|
+
"show_masks",
|
|
23
|
+
# general
|
|
24
|
+
"coordinates_on_image",
|
|
25
|
+
"catplot",
|
|
26
|
+
"stacked_bar_plot",
|
|
27
|
+
"create_pie_charts",
|
|
28
|
+
"cn_exp_heatmap",
|
|
29
|
+
"catplot",
|
|
30
|
+
"cn_map",
|
|
31
|
+
"dumbbell",
|
|
32
|
+
"count_patch_proximity_res",
|
|
33
|
+
"zcount_thres",
|
|
34
|
+
"BC_projection",
|
|
35
|
+
"plot_top_n_distances",
|
|
36
|
+
"distance_graph",
|
|
37
|
+
# qptiff converter
|
|
38
|
+
"tissue_lables",
|
|
39
|
+
"ppa_res_donut",
|
|
40
|
+
]
|