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

Constructing spatial neighborhood with custom parameters #126

Merged
merged 21 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions preprocessing/neighbors/config.json

This file was deleted.

Copy link
Collaborator

@niklasmueboe niklasmueboe Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delaunay: false. I think for this one we won't need a config at all. And delaunay should always be true

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"delaunay":false
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
out_dir = Path(args.out_dir)

spatial_connectivities_file = out_dir / "spatial_connectivities.mtx"
##spatial_distances_file = out_dir / "spatial_distances.mtx"


# Use these filepaths and inputs ...
coord_file = args.coordinates
Expand Down Expand Up @@ -89,11 +91,12 @@ def get_anndata(args):
sq.gr.spatial_neighbors(adata, delaunay=delaunay, coord_type="generic")

neighbors = adata.obsp["spatial_connectivities"].astype(int)
##distance = adata.obsp["spatial_distances"].astype(float)

## Write output
import scipy as sp

out_dir.mkdir(parents=True, exist_ok=True)

sp.io.mmwrite(spatial_connectivities_file, neighbors)
##sp.io.mmwrite(spatial_distances_file, distance)
3 changes: 3 additions & 0 deletions preprocessing/neighbors/n_neighbourhood/config/config_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"n_neighs":6
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
out_dir = Path(args.out_dir)

spatial_connectivities_file = out_dir / "spatial_connectivities.mtx"
##spatial_distances_file = out_dir / "spatial_distances.mtx"

# Use these filepaths and inputs ...
coord_file = args.coordinates
Expand Down Expand Up @@ -94,11 +95,12 @@ def get_anndata(args):
sq.gr.spatial_neighbors(adata, n_neighs=n_neighs, coord_type="generic")

neighbors = adata.obsp["spatial_connectivities"].astype(int)
##distance = adata.obsp["spatial_distances"].astype(float)

## Write output
import scipy as sp

out_dir.mkdir(parents=True, exist_ok=True)

sp.io.mmwrite(spatial_connectivities_file, neighbors)

##sp.io.mmwrite(spatial_distances_file, distance)
3 changes: 3 additions & 0 deletions preprocessing/neighbors/n_rings/config/config_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"n_rings":1
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
out_dir = Path(args.out_dir)

spatial_connectivities_file = out_dir / "spatial_connectivities.mtx"
##spatial_distances_file = out_dir / "spatial_distances.mtx"

# Use these filepaths and inputs ...
coord_file = args.coordinates
Expand Down Expand Up @@ -96,11 +97,12 @@ def get_anndata(args):
sq.gr.spatial_neighbors(adata,n_rings=n_rings, coord_type="grid")

neighbors = adata.obsp["spatial_connectivities"].astype(int)
##distance = adata.obsp["spatial_distances"].astype(float)

## Write output
import scipy as sp

out_dir.mkdir(parents=True, exist_ok=True)

sp.io.mmwrite(spatial_connectivities_file, neighbors)

##sp.io.mmwrite(spatial_distances_file, distance)
3 changes: 3 additions & 0 deletions preprocessing/neighbors/radius/config/config_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"radius":1
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
out_dir = Path(args.out_dir)

spatial_connectivities_file = out_dir / "spatial_connectivities.mtx"
##spatial_distances_file = out_dir / "spatial_distances.mtx"

# Use these filepaths and inputs ...
coord_file = args.coordinates
Expand Down Expand Up @@ -94,11 +95,12 @@ def get_anndata(args):
sq.gr.spatial_neighbors(adata, radius=radius, coord_type='generic')

neighbors = adata.obsp["spatial_connectivities"].astype(int)
##distance = adata.obsp["spatial_distances"].astype(float)

## Write output
import scipy as sp

out_dir.mkdir(parents=True, exist_ok=True)

sp.io.mmwrite(spatial_connectivities_file, neighbors)

##sp.io.mmwrite(spatial_distances_file, distance)