Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multichip-snakemake
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andrey ARISTOV
multichip-snakemake
Commits
f75d0136
Unverified
Commit
f75d0136
authored
1 year ago
by
Andrey Aristov
Browse files
Options
Downloads
Patches
Plain Diff
make crops
parent
ba088c21
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Snakefile
+11
-1
11 additions, 1 deletion
Snakefile
make_crops.py
+41
-0
41 additions, 0 deletions
make_crops.py
with
52 additions
and
1 deletion
Snakefile
+
11
−
1
View file @
f75d0136
rule combine_tables:
rule combine_tables:
input:
input:
table1="{folder}/day1/table.csv",
table1="{folder}/day1/table.csv",
table2="{folder}/day2/table.csv"
table2="{folder}/day2/table.csv",
crops = "{folder}/day2/BF_TRITC_aligned.crops.zarr"
params:
params:
threshold="20" #minimum number of cells for day 2
threshold="20" #minimum number of cells for day 2
...
@@ -26,6 +27,15 @@ rule align_and_count:
...
@@ -26,6 +27,15 @@ rule align_and_count:
shell:
shell:
"python align.py {input.data} {output.zarr} {input.concentrations} {input.template} {input.labels} {output.table} 1"
"python align.py {input.data} {output.zarr} {input.concentrations} {input.template} {input.labels} {output.table} 1"
rule make_crops:
input:
data = "{folder}/day{day}/BF_TRITC_aligned.zarr"
output:
zarr = directory("{folder}/day{day}/BF_TRITC_aligned.crops.zarr")
shell:
"python make_crops.py {input.data} {output.zarr}"
rule correct_xy:
rule correct_xy:
input:
input:
zarr = "{folder}/day{day}/BF_TRITC_aligned-to-correct.zarr",
zarr = "{folder}/day{day}/BF_TRITC_aligned-to-correct.zarr",
...
...
This diff is collapsed.
Click to expand it.
make_crops.py
0 → 100644
+
41
−
0
View file @
f75d0136
import
pandas
as
pd
import
os
import
dask.array
as
da
import
re
import
fire
EXPECTED_SHAPE
=
(
6
,
3
,
7152
,
22192
)
def
main
(
aligned_path
,
out_path
,
size
=
300
):
centers
=
pd
.
read_csv
(
"
v3/centers_bin16.csv
"
,
index_col
=
0
).
values
*
8
_
=
get_crops
(
aligned_path
,
out_path
,
centers
=
centers
,
size
=
size
)
return
0
def
crop2d
(
img
,
center
:
tuple
,
size
:
int
):
im
=
img
[
...,
int
(
center
[
0
])
-
size
//
2
:
int
(
center
[
0
])
+
size
//
2
,
int
(
center
[
1
])
-
size
//
2
:
int
(
center
[
1
])
+
size
//
2
,
]
return
im
def
get_crops
(
path_to_zarr
,
out_path
,
centers
,
size
):
if
os
.
path
.
exists
(
out_path
):
print
(
f
"
already exists, reading
"
)
return
da
.
from_zarr
(
out_path
)
date
=
(
re
.
compile
(
"
[0-9]{8}
"
).
findall
(
path_to_zarr
)[
0
])
data
=
da
.
from_zarr
(
path_to_zarr
+
"
/0/
"
)
print
(
f
"
{
date
}
:
{
data
.
shape
}
\n
"
)
if
not
data
.
shape
==
EXPECTED_SHAPE
:
return
crops
=
da
.
stack
(
map
(
lambda
c
:
crop2d
(
data
[:,:
2
],
c
,
size
),
centers
)).
rechunk
()
da
.
to_zarr
(
crops
,
out_path
)
print
(
f
"
Saved
{
crops
.
shape
}
to
{
out_path
}
"
)
return
crops
if
__name__
==
"
__main__
"
:
fire
.
Fire
(
main
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment